/**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_VERIFYRECORD') 
 CREATE TABLE T_AR_VERIFYRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLDATE DATETIME,
FBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FVERIFYSEQ INT DEFAULT 0 NOT NULL,
FASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPAYABLEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FVERIFYRELATION VARCHAR(30) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FMEASUREUNIT BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' 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,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FISVOUCHER CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_VERIFYRECORDENTRY') 
 CREATE TABLE T_AR_VERIFYRECORDENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBILLDATE DATETIME,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255),
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FPAYABLEAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAINVERIFYAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERIFYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMAINVERIFYQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FBILLENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_CLOSERECORD') 
 CREATE TABLE T_AR_CLOSERECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCLOSEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_BALANCE' AND KSQL_COL_NAME ='FCLOSEID') 
 ALTER TABLE T_AR_BALANCE ADD (FCLOSEID BIGINT DEFAULT 0 NOT NULL );

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