/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\TPO_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TPO_TCRET_TAXITEM') 
 CREATE TABLE T_TPO_TCRET_TAXITEM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FMERGECODE VARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXRATE VARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXMETHOD VARCHAR(200) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(200) DEFAULT ' ' NOT NULL,
FSUMITEM CHAR(1) DEFAULT ' ' NOT NULL,
FLONGNUMBER VARCHAR(200) DEFAULT ' ' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FISLEAF CHAR(1) DEFAULT ' ' NOT NULL,
FLEVEL BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FFILTERCONDITION NCLOB,
FFCONDITIONJSON NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TPO_TCRET_TAXITEM_L') 
 CREATE TABLE T_TPO_TCRET_TAXITEM_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TPO_TCRET_TAXRATE') 
 CREATE TABLE T_TPO_TCRET_TAXRATE (
FID BIGINT DEFAULT 0 NOT NULL,
FSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FPOLICYBASIS VARCHAR(50) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(100) DEFAULT ' ' NOT NULL,
FTAXPAYERTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_TPO_TCRET_TAXRATE_L') 
 CREATE TABLE T_TPO_TCRET_TAXRATE_L (
FPKID VARCHAR(18) 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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME ='FFILTERCONDITION') 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FFILTERCONDITION NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_TPO_TAXITEMRATE' AND KSQL_COL_NAME ='FFCONDITIONJSON') 
 ALTER TABLE T_TPO_TAXITEMRATE ADD (FFCONDITIONJSON NCLOB );

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