/**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_REVCFMBILL') 
 CREATE TABLE T_AR_REVCFMBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZDATE DATETIME,
FBILLSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
FSOURCEBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FBASECURRENCYID BIGINT DEFAULT 0 NOT NULL,
FEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNVERIFYAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FVERIFYSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FRECORGID BIGINT DEFAULT 0 NOT NULL,
FPAYPROPERTYID BIGINT DEFAULT 0 NOT NULL,
FSALESMANID BIGINT DEFAULT 0 NOT NULL,
FSALESGROUPID BIGINT DEFAULT 0 NOT NULL,
FSALESORGID BIGINT DEFAULT 0 NOT NULL,
FISVOUCHER CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_REVCFMBILLENTRY') 
 CREATE TABLE T_AR_REVCFMBILLENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FASSISTANTATTRID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL,
FQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNITCOEFFICIENT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNITQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISPRESENT CHAR(1) DEFAULT '0' NOT NULL,
FUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNTMODE VARCHAR(30) DEFAULT ' ' NOT NULL,
FDISCOUNTRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDISCOUNTAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCOREBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FCOREBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCOREBILLENTRYSEQ INT DEFAULT 0 NOT NULL,
FVERIFIEDQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFIEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNVERIFYAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FSOURCEBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FCOREBILLID BIGINT DEFAULT 0 NOT NULL,
FCOREBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_FINARBILLENTRY' AND KSQL_COL_NAME ='FCONFIRMEDAMT') 
 ALTER TABLE T_AR_FINARBILLENTRY ADD (FCONFIRMEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_FINARBILLENTRY' AND KSQL_COL_NAME ='FUNCONFIRMAMT') 
 ALTER TABLE T_AR_FINARBILLENTRY ADD (FUNCONFIRMAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_BUSBILL_E' AND KSQL_COL_NAME ='FISSELFWOFF') 
 ALTER TABLE T_AR_BUSBILL_E ADD (FISSELFWOFF CHAR(1) DEFAULT '0' NOT NULL );

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