/**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_PAYPROPERTYEXC') 
 CREATE TABLE T_AR_PAYPROPERTYEXC (
FDATAID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_PAYPROPERTYUSEREG') 
 CREATE TABLE T_AR_PAYPROPERTYUSEREG (
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FDATAID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FADMINORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(30) DEFAULT ' ' NOT NULL,
FISASSIGN CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_PAYPROPERTY' AND KSQL_COL_NAME IN ('FCREATEORGID')) 
 ALTER TABLE T_AR_PAYPROPERTY ADD (FCREATEORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_PAYPROPERTY' AND KSQL_COL_NAME IN ('FORGID')) 
 ALTER TABLE T_AR_PAYPROPERTY ADD (FORGID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_PAYPROPERTY' AND KSQL_COL_NAME IN ('FCTRLSTRATEGY')) 
 ALTER TABLE T_AR_PAYPROPERTY ADD (FCTRLSTRATEGY VARCHAR(30) DEFAULT ' ' NOT NULL );
 EXEC p_AlterColumn 'T_AR_FINARBILLENTRY', 'FCOREBILLID', 'BIGINT', 'NOT NULL', '0011', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSBILL') 
 CREATE TABLE T_AR_BUSBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBIZDATE DATETIME,
FDUEDATE DATETIME,
FBILLTYPE BIGINT DEFAULT 0 NOT NULL,
FASSTACTTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FASSTACTID BIGINT DEFAULT 0 NOT NULL,
FRECORGID BIGINT DEFAULT 0 NOT NULL,
FPAYMODE VARCHAR(30) DEFAULT ' ' NOT NULL,
FPAYCOND BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(30) DEFAULT ' ' NOT NULL,
FISADJUST CHAR(1) DEFAULT '0' NOT NULL,
FSETTLEMENTTYPEID BIGINT DEFAULT 0 NOT NULL,
FRECAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECLOCALAMT DECIMAL(23,10) 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,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FISFULLINVOICE CHAR(1) DEFAULT '0' NOT NULL,
FINVOICEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEDLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOINVOICEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOINVOICELOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNINVOICEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNINVOICEDLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSALESORGID BIGINT DEFAULT 0 NOT NULL,
FSALESGROUPID BIGINT DEFAULT 0 NOT NULL,
FSALESMANID 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,
FSOURCEBILLTYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FSOURCEBILLID VARCHAR(255) DEFAULT ' ' NOT NULL,
FISPERIOD CHAR(1) DEFAULT '0' NOT NULL,
FISVOUCHER CHAR(1) DEFAULT ' ' NOT NULL,
FSOURCEBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSBILLENTRY') 
 CREATE TABLE T_AR_BUSBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FSPECTYPE VARCHAR(255) DEFAULT ' ' NOT NULL,
FASSISTANTATTRID VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSEITEMID BIGINT DEFAULT 0 NOT NULL,
FMEASUREUNITID BIGINT DEFAULT 0 NOT NULL,
FQUANTITY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEUNIT BIGINT 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,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXLOCALAMT 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,
FDISCOUNTLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTTAXUNITPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECLOCALAMT 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,
FCOREBILLID BIGINT DEFAULT 0 NOT NULL,
FCOREBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FINVOICEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEDLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOINVOICEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOINVOICELOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNINVOICEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNINVOICEDLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICECODE VARCHAR(30) DEFAULT ' ' NOT NULL,
FINVOICENO VARCHAR(30) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSRCENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSPLANENTRY') 
 CREATE TABLE T_AR_BUSPLANENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPLANDUEDATE DATETIME,
FPLANSETTLETYPE BIGINT DEFAULT 0 NOT NULL,
FPLANPRICETAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANPRICETAXLOCAL DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINVOICEDLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOINVOICEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNOINVOICELOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNINVOICEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNINVOICEDLOCAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FPLANREMARK NVARCHAR(255) DEFAULT ' ' NOT NULL
);



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