/**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_GLIMPORTLOG') 
 CREATE TABLE T_AR_GLIMPORTLOG (
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,
FIMPORTSTATE VARCHAR(5) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FARFINBILLCOUNT INT DEFAULT 0 NOT NULL,
FAPFINBILLCOUNT INT DEFAULT 0 NOT NULL,
FARBUSBILLCOUNT INT DEFAULT 0 NOT NULL,
FPAIDBILLCOUNT INT DEFAULT 0 NOT NULL,
FAPBUSBILLCOUNT INT DEFAULT 0 NOT NULL,
FRECEIVEDBILLCOUNT INT DEFAULT 0 NOT NULL,
FERRORDESC VARCHAR(255) DEFAULT ' ' NOT NULL,
FERRORDESC_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_GLIMPORTBILL' AND KSQL_COL_NAME ='FSCHEMEID') 
 ALTER TABLE T_AR_GLIMPORTBILL ADD (FSCHEMEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_GLIMPORTSCHEMEENTRY' AND KSQL_COL_NAME ='FBALANCEMAPPINGFIELD') 
 ALTER TABLE T_AR_GLIMPORTSCHEMEENTRY ADD (FBALANCEMAPPINGFIELD VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_GLIMPORTSCHEMEENTRY' AND KSQL_COL_NAME ='FBALANCEMAPPINGFIELDNAME') 
 ALTER TABLE T_AR_GLIMPORTSCHEMEENTRY ADD (FBALANCEMAPPINGFIELDNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_REVCFMBILLENTRY' AND KSQL_COL_NAME ='FINVOICECUSTOMERID')
 ALTER TABLE T_AR_REVCFMBILLENTRY ADD (FINVOICECUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_REVCFMBILLENTRY' AND KSQL_COL_NAME ='FDELIVERCUSTOMERID')
 ALTER TABLE T_AR_REVCFMBILLENTRY ADD (FDELIVERCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_REVCFMBILL' AND KSQL_COL_NAME ='FPAYMENTCUSTOMERID')
 ALTER TABLE T_AR_REVCFMBILL ADD (FPAYMENTCUSTOMERID BIGINT DEFAULT 0 NOT NULL );
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_table.sql **/
