/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_BUSBILL_E' AND KSQL_COL_NAME ='FISINTERTAX') 
 ALTER TABLE T_AR_BUSBILL_E ADD (FISINTERTAX CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_AR_FINARBILL_E' AND KSQL_COL_NAME ='FISINTERTAX') 
 ALTER TABLE T_AR_FINARBILL_E ADD (FISINTERTAX CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSBILLTAXENTRY') 
 CREATE TABLE T_AR_BUSBILLTAXENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FTAXCATEGORYID BIGINT,
FISINPRICETAX CHAR(1),
FISINPUTTAX CHAR(1),
FTAXRATEID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXTIME NVARCHAR(255),
FINCLUDETAIL CHAR(1),
FDISCOUNTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINCLUDEDISCOUNT CHAR(1),
FINCLUDEVAT CHAR(1),
FTAXBASE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANDEDUCTIBLE CHAR(1),
FDEDUCTIONRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTIBLE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNONDEDUCTIBLE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_FINARBILLTAXENTRY') 
 CREATE TABLE T_AR_FINARBILLTAXENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FTAXCATEGORYID BIGINT,
FISINPRICETAX CHAR(1),
FISINPUTTAX CHAR(1),
FTAXRATEID BIGINT DEFAULT 0 NOT NULL,
FTAXRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAXTIME NVARCHAR(255),
FINCLUDETAIL CHAR(1),
FDISCOUNTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINCLUDEDISCOUNT CHAR(1),
FINCLUDEVAT CHAR(1),
FTAXBASE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCANDEDUCTIBLE CHAR(1),
FDEDUCTIONRATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEDUCTIBLE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FNONDEDUCTIBLE DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_FINARBILLENTRY_E') 
 CREATE TABLE T_AR_FINARBILLENTRY_E (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FVATTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECTAX DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_AR_BUSBILLENTRY_E') 
 CREATE TABLE T_AR_BUSBILLENTRY_E (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FVATTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECTAX DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONFIRMEDAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNCONFIRMAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);
/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\AR_table.sql **/
