/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_DELIVERYSCHENTRY' AND KSQL_COL_NAME IN ('FSUMOUTSTOCKBASEQTY')) 
 ALTER TABLE T_PUR_DELIVERYSCHENTRY ADD (FSUMOUTSTOCKBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_DELIVERYSCHENTRY' AND KSQL_COL_NAME IN ('FSUMOUTSTOCKQTY')) 
 ALTER TABLE T_PUR_DELIVERYSCHENTRY ADD (FSUMOUTSTOCKQTY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CLAIM') 
 CREATE TABLE T_PUR_CLAIM (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPURORGID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FCFMID BIGINT DEFAULT 0 NOT NULL,
FCANCELID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FCFMDATE DATETIME,
FCANCELDATE DATETIME,
FBILLDATE DATETIME,
FHOPENDATE DATETIME,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FCONTACTERID BIGINT DEFAULT 0 NOT NULL,
FCLAIMTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FSUMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRID BIGINT DEFAULT 0 NOT NULL,
FCFMSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FCLAIMDESC NVARCHAR(512) DEFAULT ' ' NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FVERSIONSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FSRCBILLTYPE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CLAIMENTRY') 
 CREATE TABLE T_PUR_CLAIMENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FCLASSIFY BIGINT DEFAULT 0 NOT NULL,
FCLAIMTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCLAIMTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCLAIMAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECEIPTBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FGOODSID BIGINT DEFAULT 0 NOT NULL,
FGOODSDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FRCVORGID BIGINT DEFAULT 0 NOT NULL,
FPURORGID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FMAINBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CLAIMRECORDATTA') 
 CREATE TABLE T_PUR_CLAIMRECORDATTA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_CLAIMRECORDENTRY') 
 CREATE TABLE T_PUR_CLAIMRECORDENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCLAIMEXPLAIN NVARCHAR(512) DEFAULT ' ' NOT NULL,
FCLAIMANTID BIGINT DEFAULT 0 NOT NULL,
FCLAIMANTTIME DATETIME,
FDISPOSALTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FDISPOSALNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FDISPOSALERID BIGINT DEFAULT 0 NOT NULL,
FDISPOSALERTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_PROB_ENTRYENTITY') 
 CREATE TABLE T_PUR_PROB_ENTRYENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FPOBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPOBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FRECEIPTBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FRECEIPTBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FGOODSID BIGINT DEFAULT 0 NOT NULL,
FGOODSDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FDETAILS NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDETAILS_TAG NCLOB,
FQUAPROBLEM CHAR(1) DEFAULT ' ' NOT NULL,
FLOTNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FRECURRENCE CHAR(1) DEFAULT ' ' NOT NULL,
FFEEDBACKDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFEEDBACKDESC_TAG NCLOB,
FFACEBACKTIME DATETIME,
FFEEDBACKERID BIGINT DEFAULT 0 NOT NULL,
FFEEDBACKSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FRCVORGID BIGINT DEFAULT 0 NOT NULL,
FSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FCURRID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FMAINBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_PROB_FEEDBACKATTA') 
 CREATE TABLE T_PUR_PROB_FEEDBACKATTA (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_PROB_NOTICE') 
 CREATE TABLE T_PUR_PROB_NOTICE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) 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,
FBILLDATE DATETIME,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FCONTACTERID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSRCBILLTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FORIGIN CHAR(1) DEFAULT ' ' NOT NULL,
FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL,
FHOPENDATE DATETIME
);



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