/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\PMS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SPLENTRY' AND KSQL_COL_NAME ='FADJUSTBILLID') 
 ALTER TABLE T_SM_SPLENTRY ADD (FADJUSTBILLID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_SM_SPLENTRY' AND KSQL_COL_NAME ='FADJUSTBILLNO') 
 ALTER TABLE T_SM_SPLENTRY ADD (FADJUSTBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_ADJCUSENTRY') 
 CREATE TABLE T_SM_ADJCUSENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FCUSTOMERGROUPID BIGINT DEFAULT 0 NOT NULL,
FCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FCUSADJUSTFLAG VARCHAR(5) DEFAULT ' ' NOT NULL,
FSRCCUSTOMERENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_ADJPRIENTRY') 
 CREATE TABLE T_SM_ADJPRIENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALGROUPID BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FPRICEFLOOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICECEILING DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICEEFFECTDATE DATETIME,
FPRICEEXPIRYDATE DATETIME,
FREMARK NVARCHAR(255),
FPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATEID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTFLAG VARCHAR(5) DEFAULT ' ' NOT NULL,
FSRCPRICEENTRYID BIGINT DEFAULT 0 NOT NULL,
FADJPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJPRICEFLOOR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJPRICECEILING DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJPRICEANDTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJTAXRATEID BIGINT DEFAULT 0 NOT NULL,
FADJPRICEEFFECTDATE DATETIME,
FADJPRICEEXPIRYDATE DATETIME,
FSRCPRICELISTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_SALEPRICEADJUST') 
 CREATE TABLE T_SM_SALEPRICEADJUST (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FPRICELISTTYPEID BIGINT DEFAULT 0 NOT NULL,
FPRICELISTGROUPID BIGINT DEFAULT 0 NOT NULL,
FAPPLYMATERIAL VARCHAR(5) DEFAULT ' ' NOT NULL,
FAPPLYCUSTOMER VARCHAR(5) DEFAULT ' ' NOT NULL,
FISTAX CHAR(1) DEFAULT '1' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITTIME DATETIME,
FDESCRIPTION NVARCHAR(512),
FORGID BIGINT DEFAULT 0 NOT NULL,
FSALEPRICELISTID BIGINT DEFAULT 0 NOT NULL,
FADJUSTMODE VARCHAR(10) DEFAULT ' ' NOT NULL,
FVALIDSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FVALIDERID BIGINT DEFAULT 0 NOT NULL,
FVALIDTIME DATETIME,
FBATCHADJNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL
);


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

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