/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\SM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_RETURNAPPLY') 
 CREATE TABLE T_SM_RETURNAPPLY (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FBLLSSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FDEPTID BIGINT DEFAULT 0 NOT NULL,
FOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FCLOSESTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCLOSERID BIGINT DEFAULT 0 NOT NULL,
FCLOSEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_RETURNAPPLY_C') 
 CREATE TABLE T_SM_RETURNAPPLY_C (
FID BIGINT DEFAULT 0 NOT NULL,
FCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FLINKMANID BIGINT DEFAULT 0 NOT NULL,
FADDRESS NVARCHAR(255),
FRECCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FRECLINKMANID BIGINT DEFAULT 0 NOT NULL,
FSETTLECUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FPAYINGCUSTOMERID BIGINT DEFAULT 0 NOT NULL,
FRECEIVEADDRESS NVARCHAR(255)
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_RETURNAPPLY_F') 
 CREATE TABLE T_SM_RETURNAPPLY_F (
FID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSETTLECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSETTLETYPEID BIGINT DEFAULT 0 NOT NULL,
FSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECCONDITIONID BIGINT DEFAULT 0 NOT NULL,
FISTAX CHAR(1) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_RETURNAPPLYENTRY_F') 
 CREATE TABLE T_SM_RETURNAPPLYENTRY_F (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYSETTLEORGID BIGINT DEFAULT 0 NOT NULL,
FPRICEUNITID BIGINT DEFAULT 0 NOT NULL,
FPRICEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICEUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FTAXRATEID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICEANDRAX DECIMAL(19,6) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FTAXAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FDISCOUNTTYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FAMOUNTANDTAX DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCURAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCURAMOUNTANDTAX DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCURTAXAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_SM_RETURNAPPLYENTRY') 
 CREATE TABLE T_SM_RETURNAPPLYENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FROWCLOSESTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FASSOCIATEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FENTRYINVORGID BIGINT DEFAULT 0 NOT NULL,
FOWNERTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FISPRESENT CHAR(1) DEFAULT '0' NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSOCIATEDBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRETURNBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBIZUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYBIZUNIT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALESORGID BIGINT DEFAULT 0 NOT NULL,
FUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBIZUNITRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSRCBILLENTITY VARCHAR(36) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FMAINBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FMAINBILLENTITY VARCHAR(36) DEFAULT ' ' NOT NULL,
FMAINBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255)
);



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