/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_RPASCHEME') 
 CREATE TABLE T_AR_RPASCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FEXECUTERID BIGINT DEFAULT 0 NOT NULL,
FEXCEPLANDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSHEDULEPLANID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_RPASCHEME_L') 
 CREATE TABLE T_AR_RPASCHEME_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_RPASCHEMEORGENTRY') 
 CREATE TABLE T_AR_RPASCHEMEORGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_RPASCHERULEENTRY') 
 CREATE TABLE T_AR_RPASCHERULEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSETTLERELATION VARCHAR(30) DEFAULT ' ' NOT NULL,
FTIMEORDER VARCHAR(30) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSTACTMATCH VARCHAR(5) DEFAULT ' ' NOT NULL,
FCURRENCYMATCH VARCHAR(5) DEFAULT '0' NOT NULL,
FMATCHFIELDINFO VARCHAR(2000) DEFAULT ' ' NOT NULL,
FMAINBILL VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTBILL VARCHAR(30) DEFAULT ' ' NOT NULL,
FMAINFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMAINFILTER_TAG NCLOB,
FASSTFILTER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSTFILTER_TAG NCLOB,
FMAINDATESRC NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSTDATESRC NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_SETTLEIMPORT') 
 CREATE TABLE T_AR_SETTLEIMPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLSRCTYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBATCHNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSETTLERELATION VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FMAINBILLNUM NVARCHAR(80) DEFAULT ' ' NOT NULL,
FMAINBILLID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FMAINASSTACTID BIGINT DEFAULT 0 NOT NULL,
FASSTACTNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FMAINBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FPAYABLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALSETTLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALTOTALSETTLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTOTALUNSETTLEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQUOTATION VARCHAR(30) DEFAULT '0' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FAUDITDATE DATETIME,
FEXRATETABLE BIGINT DEFAULT 0 NOT NULL,
FEXRATEDATE DATETIME,
FSETTLERESULT VARCHAR(30) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_SETTLEIMPORTENTRY') 
 CREATE TABLE T_AR_SETTLEIMPORTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FASSTACT NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSTACTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLNUM NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FQUOTATION VARCHAR(30) DEFAULT '0' NOT NULL,
FBILLDATE DATETIME,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPAYABLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETTLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSETTLELOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNSETTLEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL,
FEXRATEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_RPASETTLELOG') 
 CREATE TABLE T_AR_RPASETTLELOG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(5) 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,
FEXECUTORID BIGINT DEFAULT 0 NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FUSETIME BIGINT DEFAULT 0 NOT NULL,
FEXECUTETYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FEXECUTESTATE VARCHAR(5) DEFAULT ' ' NOT NULL,
FISSTOP CHAR(1) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSCHEMENUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSCHEMENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FSCHEMERULEID BIGINT DEFAULT 0 NOT NULL,
FSETTLERELATION VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINCOUNT INT DEFAULT 0 NOT NULL,
FMAINENTRYCOUNT INT DEFAULT 0 NOT NULL,
FASSTCOUNT INT DEFAULT 0 NOT NULL,
FASSTENTRYCOUNT INT DEFAULT 0 NOT NULL,
FSETTLERECORDCOUNT INT DEFAULT 0 NOT NULL,
FMAINEXECUTEDCOUNT INT DEFAULT 0 NOT NULL,
FASSTEXECUTEDCOUNT INT DEFAULT 0 NOT NULL,
FEXECUTEPROCESS VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FASSTBILLENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINSETTLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTSETTLEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FERRORDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FERRORDESC_TAG NCLOB
);



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