/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCCIT_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCCIT_POLICY' AND KSQL_COL_NAME ='FDEDUCT13') 
 ALTER TABLE T_TCCIT_POLICY ADD (FDEDUCT13 CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCCIT_POLICY' AND KSQL_COL_NAME ='FDEDUCT14') 
 ALTER TABLE T_TCCIT_POLICY ADD (FDEDUCT14 CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCCIT_POLICY' AND KSQL_COL_NAME ='FDEDUCT15') 
 ALTER TABLE T_TCCIT_POLICY ADD (FDEDUCT15 CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCCIT_POLICY' AND KSQL_COL_NAME ='FDEDUCT16') 
 ALTER TABLE T_TCCIT_POLICY ADD (FDEDUCT16 CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_NON_INSURANCE_DET') 
 CREATE TABLE T_TCCIT_NON_INSURANCE_DET (
FID BIGINT DEFAULT 0 NOT NULL,
FTAXACCOUNTSERIALNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSKSSQQ DATETIME,
FSKSSQZ DATETIME,
FSUBJECTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FTABLE BIGINT DEFAULT 0 NOT NULL,
FAMOUNTFIELD BIGINT DEFAULT 0 NOT NULL,
FTABLETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE BIGINT DEFAULT 0 NOT NULL,
FDATADIRECTION VARCHAR(50) DEFAULT ' ' NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFETCHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFILTERCONDITION VARCHAR(2000) DEFAULT ' ' NOT NULL,
FRULEID BIGINT DEFAULT 0 NOT NULL,
FENTRYTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FITEMNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FABSOLUTE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_NON_INSURANCE_SUM') 
 CREATE TABLE T_TCCIT_NON_INSURANCE_SUM (
FID BIGINT DEFAULT 0 NOT NULL,
FITEMNO BIGINT DEFAULT 0 NOT NULL,
FITEMTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FZZJE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSKSSQQ DATETIME,
FSKSSQZ DATETIME,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FLIMITBASE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXINCOME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNSTZJE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNONALLOWAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRULEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_INSURANCE_DET') 
 CREATE TABLE T_TCCIT_INSURANCE_DET (
FID BIGINT DEFAULT 0 NOT NULL,
FTAXACCOUNTSERIALNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSKSSQQ DATETIME,
FSKSSQZ DATETIME,
FSUBJECTID VARCHAR(50) DEFAULT ' ' NOT NULL,
FTABLE BIGINT DEFAULT 0 NOT NULL,
FAMOUNTFIELD BIGINT DEFAULT 0 NOT NULL,
FTABLETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE BIGINT DEFAULT 0 NOT NULL,
FDATADIRECTION VARCHAR(50) DEFAULT ' ' NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFETCHAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFILTERCONDITION VARCHAR(2000) DEFAULT ' ' NOT NULL,
FRULEID BIGINT DEFAULT 0 NOT NULL,
FENTRYTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FITEMNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FABSOLUTE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_INSURANCE_SUMMARY') 
 CREATE TABLE T_TCCIT_INSURANCE_SUMMARY (
FID BIGINT DEFAULT 0 NOT NULL,
FITEMNO BIGINT DEFAULT 0 NOT NULL,
FITEMTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSKSSQQ DATETIME,
FSKSSQZ DATETIME
);


 EXEC p_AlterColumn 'T_TCCIT_BEFORETAX_SUMMARY', 'FZZJE', 'DECIMAL(23,10)', 'NOT NULL', '1111', '0';

 EXEC p_AlterColumn 'T_TCCIT_BEFORETAX_SUMMARY', 'FNSTZJE', 'DECIMAL(23,10)', 'NOT NULL', '1111', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_CARRY_FWD_LOSS') 
 CREATE TABLE T_TCCIT_CARRY_FWD_LOSS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBOOKEDDATE DATETIME,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNTINGDOC VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_GOV_SUBSIDY_DEFER') 
 CREATE TABLE T_TCCIT_GOV_SUBSIDY_DEFER (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONTRACTSTART DATETIME,
FCONTRACTEND DATETIME,
FGOVDEPARTMENT VARCHAR(50) DEFAULT ' ' NOT NULL,
FACCOUNTINGMETHOD VARCHAR(50) DEFAULT ' ' NOT NULL,
FSUBSIDYTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FRELATEASSETCODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE VARCHAR(255) DEFAULT ' ' NOT NULL,
FLJSDBZAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLJJZSYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSYWJZAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_REC_SUBSIDY') 
 CREATE TABLE T_TCCIT_REC_SUBSIDY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBOOKEDDATE DATETIME,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACOUNTINGDOC VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_BOOK_INCOME_REG') 
 CREATE TABLE T_TCCIT_BOOK_INCOME_REG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBOOKEDDATE DATETIME,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNTINGDOC VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_NOT_TACCRUAL_BAS') 
 CREATE TABLE T_TCCIT_NOT_TACCRUAL_BAS (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONTRACTSTART DATETIME,
FCONTRACTEND DATETIME,
FLJTAXINCOME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLJBOOKINCOME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSYJZAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINCOMETYPE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCCIT_TAX_INCOME_REG') 
 CREATE TABLE T_TCCIT_TAX_INCOME_REG (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBOOKEDDATE DATETIME,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACCOUNTINGDOC VARCHAR(50) DEFAULT ' ' NOT NULL,
FNOTE VARCHAR(255) DEFAULT ' ' NOT NULL
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TCCIT_table.sql **/
