IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_TAXYEAR') 
 CREATE TABLE T_TCTB_TAXYEAR (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FTAXATIONSYS BIGINT DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FISPRESET VARCHAR(50) DEFAULT ' ' NOT NULL,
FAPPLICATIONSCOPE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_TAXYEAR_ENTITY') 
 CREATE TABLE T_TCTB_TAXYEAR_ENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTARTYEAR VARCHAR(50) DEFAULT ' ' NOT NULL,
FSTARTMONTHANDDAY DATETIME,
FENDYEAR VARCHAR(50) DEFAULT ' ' NOT NULL,
FENDMONTHANDDAY DATETIME,
FMONTHLY VARCHAR(50) DEFAULT ' ' NOT NULL,
FQUARTER VARCHAR(50) DEFAULT ' ' NOT NULL,
FHALFYEAR VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_TAXYEAR_L') 
 CREATE TABLE T_TCTB_TAXYEAR_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TCTB_TAXYEAR_ORGENTITY') 
 CREATE TABLE T_TCTB_TAXYEAR_ORGENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TCTB_DECLARE_MAIN' AND KSQL_COL_NAME ='FTAXREFUNDSTATUS') 
 ALTER TABLE T_TCTB_DECLARE_MAIN ADD (FTAXREFUNDSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL );
