/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SRC_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_CONTRACTENTRY') 
 CREATE TABLE T_SRC_CONTRACTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRANK INT DEFAULT 0 NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FSYSRESULT CHAR(1) DEFAULT ' ' NOT NULL,
FRESULT CHAR(1) DEFAULT ' ' NOT NULL,
FORDERRATIO DECIMAL(19,6) DEFAULT 0 NOT NULL,
FPACKAGENAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPKGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPKGTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMATERIALMODEL NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCATEGORYID BIGINT DEFAULT 0 NOT NULL,
FBIDMATERIALID BIGINT DEFAULT 0 NOT NULL,
FDISTRICTID BIGINT DEFAULT 0 NOT NULL,
FAREAID BIGINT DEFAULT 0 NOT NULL,
FLGORTID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FPRICE_UOM INT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXITEMID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FTAXPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCCURRID BIGINT DEFAULT 0 NOT NULL,
FEXCHTYPEID BIGINT DEFAULT 0 NOT NULL,
FEXCHRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FLOCPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCTAXPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCTAXAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEFFECTDATE DATETIME,
FDUEDATE DATETIME,
FMAXPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAXTAXPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOTE NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENTRYSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FSUPPLIERTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLIERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDCTRATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FDCTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FFEERATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FTRANSCOST DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREBATE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FDECREASE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FVIEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FPACKAGEID BIGINT DEFAULT 0 NOT NULL,
FPURLISTID BIGINT DEFAULT 0 NOT NULL,
FACTPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTTAXPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBRAND NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLIERNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FSUPPLIERNOTE NVARCHAR(512) DEFAULT ' ' NOT NULL,
FCONTRACTQTY INT DEFAULT 0 NOT NULL,
FCONTRACTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONTRACTTAXAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SRC_FEESURPLUS') 
 CREATE TABLE T_SRC_FEESURPLUS (
FID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSURPLUSAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLID VARCHAR(100) DEFAULT ' ' NOT NULL,
FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FFEEITEMID BIGINT DEFAULT 0 NOT NULL,
FSOURCEID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FISSURPLUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FFEEAMOUNT') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FFEEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FSURPLUSAMOUNT') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FSURPLUSAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FUSESURPLUS') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FUSESURPLUS DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FTRANSFERAMOUNT') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FTRANSFERAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FTRANSFERUSERID') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FTRANSFERUSERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FTRANSFERDATE') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FTRANSFERDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FTRANSFEROPINION') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FTRANSFEROPINION NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FSURPLUSID') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FSURPLUSID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FUSEDATE') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FUSEDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PAYMENTENTRY' AND KSQL_COL_NAME ='FPRESURPLUSAMOUNT') 
 ALTER TABLE T_SRC_PAYMENTENTRY ADD (FPRESURPLUSAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SRC_PURLISTENTRY_F' AND KSQL_COL_NAME ='FQUOTEDATE') 
 ALTER TABLE T_SRC_PURLISTENTRY_F ADD (FQUOTEDATE DATETIME );

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