/**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_ACCRUALAGING')
 CREATE TABLE T_AR_ACCRUALAGING (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(30) DEFAULT ' ' NOT NULL,
FISPRESET CHAR(1) DEFAULT ' ' NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX INT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX INT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_ACCRUALENTITYOBJ')
 CREATE TABLE T_AR_ACCRUALENTITYOBJ (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FENTITYOBJECT VARCHAR(30) DEFAULT ' ' NOT NULL,
FBASEAMTFIELD VARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BADDEBTACCRUALPLAN')
 CREATE TABLE T_AR_BADDEBTACCRUALPLAN (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(30) DEFAULT ' ' NOT NULL,
FACCRUALMETHOD VARCHAR(30) DEFAULT ' ' NOT NULL,
FACCRUALFREQUENCY VARCHAR(30) DEFAULT ' ' NOT NULL,
FOFFSET VARCHAR(30) DEFAULT ' ' NOT NULL,
FACCRUALAGINGID BIGINT DEFAULT 0 NOT NULL,
FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
FBITINDEX INT DEFAULT 0 NOT NULL,
FSOURCEBITINDEX INT DEFAULT 0 NOT NULL
);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_ACCRUALCUSTOMER')
 CREATE TABLE T_AR_ACCRUALCUSTOMER (
FPKID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BADDEBTACCRUE')
 CREATE TABLE T_AR_BADDEBTACCRUE (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FACCRUALSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FACCRUALSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FPREPERIODID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL
);




IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BADDEBTPREPARE')
 CREATE TABLE T_AR_BADDEBTPREPARE (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FACCRUALDATE DATETIME,
FACCRUALSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FACCRUALMETHOD VARCHAR(50) DEFAULT ' ' NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FACCRUALFREQUENCY VARCHAR(30) DEFAULT ' ' NOT NULL,
FAGINGRANGE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACCRUALPERCENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISOFFSET CHAR(1) DEFAULT '0' NOT NULL,
FISVOUCHER CHAR(1) DEFAULT '0' NOT NULL,
FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FEXRATETABLEID BIGINT DEFAULT 0 NOT NULL,
FEXRATEDATE DATETIME,
FQUOTATION VARCHAR(30) DEFAULT ' ' NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDARDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDARDLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOFFSETAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOFFSETLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUEDLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLASTACCRUEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLASTACCRUEDLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOSSAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOSSLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUALLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLDATE DATETIME
);




IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_ACCRUALPLANENTRY')
 CREATE TABLE T_AR_ACCRUALPLANENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FACCRUALENTITYOBJID BIGINT DEFAULT 0 NOT NULL,
FCONDITION_TAG NCLOB,
FAGINGSTARTDATEFIELD VARCHAR(30) DEFAULT ' ' NOT NULL,
FACCRUALRATE_TAG NCLOB,
FOFFSET NVARCHAR(255) DEFAULT ' ' NOT NULL,
FOFFSET_TAG NCLOB
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_ACCRUALAGINGENTRY')
 CREATE TABLE T_AR_ACCRUALAGINGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSECTION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FISDAYMORE CHAR(1) DEFAULT ' ' NOT NULL,
FSTARTDAY INT DEFAULT 0 NOT NULL,
FENDDAY INT DEFAULT 0 NOT NULL
);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BADDEBTACCRUEENTRY')
 CREATE TABLE T_AR_BADDEBTACCRUEENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FACCRUALENTITYOBJ VARCHAR(50) DEFAULT ' ' NOT NULL,
FACCRUALPERCENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINDIVIDUALREASON NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BADDEBTPREPAREENTRY')
 CREATE TABLE T_AR_BADDEBTPREPAREENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FRECAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDARDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSTANDARDLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOFFSETAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FOFFSETLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUEDLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLASTACCRUEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLASTACCRUEDLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOSSAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOSSLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCURACCRUALLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCENTRYID BIGINT DEFAULT 0 NOT NULL
);

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

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


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

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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSVERIFYRECORD')
 CREATE TABLE T_AR_BUSVERIFYRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FWFNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FWFSEQ VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FWRITEOFFTYPEID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FPAYPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FHEADWFINFO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FHEADWFINFO_TAG NCLOB,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSVERIFYRECORDENTRY')
 CREATE TABLE T_AR_BUSVERIFYRECORDENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FASSTACTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACT BIGINT DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCY BIGINT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FBILLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPRICETAXTOTAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FWOFFBILLID BIGINT DEFAULT 0 NOT NULL,
FWOFFBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FASSBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FASSTBIZDATE DATETIME,
FASSTASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTASSTACT BIGINT DEFAULT 0 NOT NULL,
FASSTCURRENCY BIGINT DEFAULT 0 NOT NULL,
FASSTBASECURRENCY BIGINT DEFAULT 0 NOT NULL,
FASSTMATERIAL BIGINT DEFAULT 0 NOT NULL,
FASSTEXPENSEITEM BIGINT DEFAULT 0 NOT NULL,
FASSUNIT BIGINT DEFAULT 0 NOT NULL,
FASSTBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FASSBILLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTBILLBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTPRICETAXTOTAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTLOCALAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSBILLID BIGINT DEFAULT 0 NOT NULL,
FASSBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FASSTWOFFBILLID BIGINT DEFAULT 0 NOT NULL,
FASSTWOFFBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FBACKWFOP VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAINWFINFO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMAINWFINFO_TAG NCLOB,
FASSWFINFO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSWFINFO_TAG NCLOB
);


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