-- 变更单主、副账簿分录建表语句
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_CHANGEBILLMAINENTRY') 
 CREATE TABLE T_FA_CHANGEBILLMAINENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FREALCARDID BIGINT DEFAULT 0 NOT NULL,
FDEPREUSEID BIGINT DEFAULT 0 NOT NULL,
FFINCARDID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FREASON VARCHAR(256) DEFAULT ' ' NOT NULL,
FBEFORIGINALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGINALVALCHG DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTORIGINALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEFPRERESIDUALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTPRERESIDUALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEFASSETCATID BIGINT DEFAULT 0 NOT NULL,
FAFTASSETCATID BIGINT DEFAULT 0 NOT NULL,
FBEFUSESTATUSID BIGINT DEFAULT 0 NOT NULL,
FAFTUSESTATUSID BIGINT DEFAULT 0 NOT NULL,
FBEFHEADUSEDEPTID BIGINT DEFAULT 0 NOT NULL,
FAFTHEADUSEDEPTID BIGINT DEFAULT 0 NOT NULL,
FBEFHEADUSEPERSONID BIGINT DEFAULT 0 NOT NULL,
FAFTHEADUSEPERSONID BIGINT DEFAULT 0 NOT NULL,
FBEFSTOREPLACEID BIGINT DEFAULT 0 NOT NULL,
FAFTSTOREPLACEID BIGINT DEFAULT 0 NOT NULL,
FBEFISSTORAGED CHAR(1) DEFAULT '0' NOT NULL,
FAFTISSTORAGED CHAR(1) DEFAULT '0' NOT NULL,
FBEFDEPREMETHODID BIGINT DEFAULT 0 NOT NULL,
FAFTDEPREMETHODID BIGINT DEFAULT 0 NOT NULL,
FISADJUSTDEPRE CHAR(1) DEFAULT '0' NOT NULL,
FBEFREALACCOUNTDATE DATETIME,
FAFTREALACCOUNTDATE DATETIME,
FBIZDATE DATETIME,
FBEFORIGINMETHODID BIGINT DEFAULT 0 NOT NULL,
FAFTORIGINMETHODID BIGINT DEFAULT 0 NOT NULL,
FBEFUNITID BIGINT DEFAULT 0 NOT NULL,
FAFTUNITID BIGINT DEFAULT 0 NOT NULL,
FBEFASSETAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTASSETAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEFASSETNAME VARCHAR(300) DEFAULT ' ' NOT NULL,
FAFTASSETNAME VARCHAR(300) DEFAULT ' ' NOT NULL,
FBEFSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FAFTSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
FBEFCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL,
FAFTCOSTCENTRERID BIGINT DEFAULT 0 NOT NULL,
FBEFWORKLOADUNITID BIGINT DEFAULT 0 NOT NULL,
FAFTWORKLOADUNITID BIGINT DEFAULT 0 NOT NULL,
FBEFPREUSINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTPREUSINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHANGEMODEID BIGINT DEFAULT 0 NOT NULL,
FDELETEMODEID BIGINT DEFAULT 0 NOT NULL,
FADDMODEID BIGINT DEFAULT 0 NOT NULL,
FBEFDEPREDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTDEPREDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_CHANGEBILLOTHERENTRY') 
 CREATE TABLE T_FA_CHANGEBILLOTHERENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FREALCARDID BIGINT DEFAULT 0 NOT NULL,
FDEPREUSEID BIGINT DEFAULT 0 NOT NULL,
FFINCARDID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FREASON VARCHAR(256) DEFAULT ' ' NOT NULL,
FBEFORIGINALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIGINALVALCHG DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTORIGINALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEFPRERESIDUALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTPRERESIDUALVAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBEFDEPREMETHODID BIGINT DEFAULT 0 NOT NULL,
FAFTDEPREMETHODID BIGINT DEFAULT 0 NOT NULL,
FISADJUSTDEPRE CHAR(1) DEFAULT '0' NOT NULL,
FBIZDATE DATETIME,
FBEFWORKLOADUNITID BIGINT DEFAULT 0 NOT NULL,
FAFTWORKLOADUNITID BIGINT DEFAULT 0 NOT NULL,
FBEFPREUSINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTPREUSINGAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHANGEMODEID BIGINT DEFAULT 0 NOT NULL,
FDELETEMODEID BIGINT DEFAULT 0 NOT NULL,
FADDMODEID BIGINT DEFAULT 0 NOT NULL,
FBEFDEPREDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAFTDEPREDAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL
);