/**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_REV_VERIFYRECORD') 
 CREATE TABLE T_AR_REV_VERIFYRECORD (
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,
FWFSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FISVOUCHER CHAR(1) DEFAULT ' ' NOT NULL,
FVOUCHERNUM VARCHAR(50) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FHEADWFINFO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FHEADWFINFO_TAG NCLOB,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATEDATE DATETIME,
FVERIFYTYPE VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_REV_VRRECORDENTRY') 
 CREATE TABLE T_AR_REV_VRRECORDENTRY (
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,
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,
FPAYPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FVERIFYVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITCOEFFICIENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQUOTATION VARCHAR(30) DEFAULT '0' NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FEXRATEDATE DATETIME,
FPRICETAXTOTAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCPRICETAXTOTAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYLOCPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYLOCTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FASSBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FASSBIZDATE DATETIME,
FASSCURRENCY BIGINT DEFAULT 0 NOT NULL,
FASSBASECURRENCY BIGINT DEFAULT 0 NOT NULL,
FASSMATERIALID BIGINT DEFAULT 0 NOT NULL,
FASSEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FASSUNIT BIGINT DEFAULT 0 NOT NULL,
FASSBASEUNIT BIGINT DEFAULT 0 NOT NULL,
FASSBILLQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSBILLBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSPAYPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FASSVERIFYVALUE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSUNITCOEFFICIENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSQUOTATION VARCHAR(30) DEFAULT '0' NOT NULL,
FASSEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSEXRATEDATE DATETIME,
FASSLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYLOCPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYLOCTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSVERIFYLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSBILLID BIGINT DEFAULT 0 NOT NULL,
FASSBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FASSCFMPRICETAXBASE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMLOCTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FASSCFMBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_REV_VRRECORDENTRY_E') 
 CREATE TABLE T_AR_REV_VRRECORDENTRY_E (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FASSBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FASSCOREBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSCOREBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FASSCOREBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FASSSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FCOREBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCOREBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCOREBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FASSSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FVERIFYDIFFAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYDIFFLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYDIFFTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYDIFFLOCTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYDIFFPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYDIFFLOCPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREVBILLNO VARCHAR(50) DEFAULT ' ' NOT NULL,
FREVBILLID BIGINT DEFAULT 0 NOT NULL,
FHADWRITTENOFF CHAR(1) DEFAULT ' ' NOT NULL,
FISWRITTENOFF CHAR(1) DEFAULT ' ' 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
);

-- 坏账计提添加编码和名称字段
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_BADDEBTACCRUE' AND KSQL_COL_NAME ='FNUMBER')
 ALTER TABLE T_AR_BADDEBTACCRUE ADD (FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_BADDEBTACCRUE' AND KSQL_COL_NAME ='FNAME')
 ALTER TABLE T_AR_BADDEBTACCRUE ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );

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