/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FAFTERDEDUCTDCTRATE')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FAFTERDEDUCTDCTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FAFTERDEDUCTDISCOUNTTYPE')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FAFTERDEDUCTDISCOUNTTYPE VARCHAR(5) DEFAULT 'NULL' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FAFTERDEDUCTAMOUNT')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FAFTERDEDUCTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FAFTERDEDUCTTAX')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FAFTERDEDUCTTAX DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FDEDUCTAMOUNT')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FDEDUCTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FAFTERDEDUCTTAXAMOUNT')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FAFTERDEDUCTTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2_A' AND KSQL_COL_NAME IN ('FAFTERDEDUCTDCTAMOUNT')) 
 ALTER TABLE T_PUR_INVOICENTRY2_A ADD (FAFTERDEDUCTDCTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICE' AND KSQL_COL_NAME IN ('FINSUMTAXAMOUNT')) 
 ALTER TABLE T_PUR_INVOICE ADD (FINSUMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICE' AND KSQL_COL_NAME IN ('FDEDUCTSUMTAXAMOUNT')) 
 ALTER TABLE T_PUR_INVOICE ADD (FDEDUCTSUMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_INVOICENTRY2' AND KSQL_COL_NAME IN ('FSOURCEBILL')) 
 ALTER TABLE T_PUR_INVOICENTRY2 ADD (FSOURCEBILL VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECK' AND KSQL_COL_NAME IN ('FDEDUCTSUMTAXAMOUNT')) 
 ALTER TABLE T_PUR_CHECK ADD (FDEDUCTSUMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CHECKENTRY2' AND KSQL_COL_NAME IN ('FSOURCEBILL')) 
 ALTER TABLE T_PUR_CHECKENTRY2 ADD (FSOURCEBILL VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CLAIM' AND KSQL_COL_NAME IN ('FPROCESSINGTYPE')) 
 ALTER TABLE T_PUR_CLAIM ADD (FPROCESSINGTYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CLAIM' AND KSQL_COL_NAME IN ('FCONTROLCRITERION')) 
 ALTER TABLE T_PUR_CLAIM ADD (FCONTROLCRITERION CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CLAIM' AND KSQL_COL_NAME IN ('FCHECKSUMTAXAMOUNT')) 
 ALTER TABLE T_PUR_CLAIM ADD (FCHECKSUMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CLAIM' AND KSQL_COL_NAME IN ('FINVSUMTAXAMOUNT')) 
 ALTER TABLE T_PUR_CLAIM ADD (FINVSUMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CLAIMENTRY' AND KSQL_COL_NAME IN ('FCHECKTAXAMOUNT')) 
 ALTER TABLE T_PUR_CLAIMENTRY ADD (FCHECKTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_CLAIMENTRY' AND KSQL_COL_NAME IN ('FINVOICETAXAMOUNT')) 
 ALTER TABLE T_PUR_CLAIMENTRY ADD (FINVOICETAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CHECK_GROUP_CONFIG') 
 CREATE TABLE T_PUR_CHECK_GROUP_CONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FGROUPBY NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CHECK_MAPPING') 
 CREATE TABLE T_PUR_CHECK_MAPPING (
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSOURCEBILL NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISPERSET CHAR(1) DEFAULT '0' NOT NULL,
FISENABLE CHAR(1) DEFAULT '1' NOT NULL,
FPLUGINNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSOURCEENTRYKEY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FCHECKTYPE CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CHECK_MFIXEDENTRY') 
 CREATE TABLE T_PUR_CHECK_MFIXEDENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FTARGETOBJCOLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FTARGETOBJCOL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSOURCEBILLCOLNO NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSOURCEBILLCOL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSELECTVALUE CHAR(1) DEFAULT '0' NOT NULL,
FFORMULADESC NVARCHAR(500) DEFAULT ' ' NOT NULL,
FFORMULA NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFORMULA_TAG NCLOB DEFAULT ' ',
FISPRESIT CHAR(1) DEFAULT '0' NOT NULL
);



/**End C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
