IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DISPOSAL') 
 CREATE TABLE T_FA_DISPOSAL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) 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,
FBUYERTYPEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUYERID BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FDISPOSALFARE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISPOSALINCOME DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINVOICEQTYCREATE INT DEFAULT 1 NOT NULL,
FPAYQTYCREATE INT DEFAULT 1 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DISPOSAL_DETAIL') 
 CREATE TABLE T_FA_DISPOSAL_DETAIL (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDETAILREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCLEARBILLID BIGINT DEFAULT 0 NOT NULL,
FREALCARDID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DISPOSAL_INVOICE') 
 CREATE TABLE T_FA_DISPOSAL_INVOICE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPAYEETYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICETYPE BIGINT DEFAULT 0 NOT NULL,
FINVOICENO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FINVOICENUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTAXAMOUNT DECIMAL(19,4) DEFAULT 0 NOT NULL,
FPAYEE BIGINT DEFAULT 0 NOT NULL,
FINVOICEDATE DATETIME,
FTOTALAMOUNT DECIMAL(19,4) DEFAULT 0 NOT NULL,
FALLTAXRATE DECIMAL(19,4) DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DISPOSAL_LK') 
 CREATE TABLE T_FA_DISPOSAL_LK (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DISPOSAL_TC') 
 CREATE TABLE T_FA_DISPOSAL_TC (
FID BIGINT DEFAULT 0 NOT NULL,
FTBILLID BIGINT DEFAULT 0 NOT NULL,
FTTABLEID BIGINT DEFAULT 0 NOT NULL,
FTID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DISPOSAL_WB') 
 CREATE TABLE T_FA_DISPOSAL_WB (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRULEVERID BIGINT DEFAULT 0 NOT NULL,
FRULEITEMID BIGINT DEFAULT 0 NOT NULL,
FOPERATE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTABLEID BIGINT DEFAULT 0 NOT NULL,
FSID BIGINT DEFAULT 0 NOT NULL,
FSBILLID BIGINT DEFAULT 0 NOT NULL,
FWRITEVALUE DECIMAL(23,10) DEFAULT 0.0000000000 NOT NULL
);
