/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\FA_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_CONTRACT_L') 
 CREATE TABLE T_FA_LEASE_CONTRACT_L (
FPKID VARCHAR(18) DEFAULT '0' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_PAY_PLAN') 
 CREATE TABLE T_FA_LEASE_PAY_PLAN (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ SMALLINT DEFAULT 0 NOT NULL,
FPLANPAYDATE DATETIME DEFAULT GETDATE() NOT NULL,
FRENTNOTAX DECIMAL(19,4) DEFAULT 0 NOT NULL,
FTAX DECIMAL(19,4) DEFAULT 0 NOT NULL,
FRENTWITHTAX DECIMAL(19,4) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_RENT_SETTLE') 
 CREATE TABLE T_FA_LEASE_RENT_SETTLE (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT 'C' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FSETTLEDATE DATETIME DEFAULT GETDATE() NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FRENT DECIMAL(19,4) DEFAULT 0 NOT NULL,
FIRR DECIMAL(23,10) DEFAULT 0 NOT NULL,
FINTEREST DECIMAL(19,4) DEFAULT 0 NOT NULL,
FPRINCIPAL DECIMAL(19,4) DEFAULT 0 NOT NULL,
FENDLEASELIAB DECIMAL(19,4) DEFAULT 0 NOT NULL,
FLEASECONTRACTID 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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_LEASE_CONTRACT') 
 CREATE TABLE T_FA_LEASE_CONTRACT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FENABLE CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FASSETUNITID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FLEASERID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FASSETCATID BIGINT DEFAULT 0 NOT NULL,
FSTOREPLACEID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FASSETQTY DECIMAL(19,4) DEFAULT 0 NOT NULL,
FCONTRSIGNDATE DATETIME,
FLEASESTARTDATE DATETIME DEFAULT GETDATE() NOT NULL,
FLEASEENDDATE DATETIME DEFAULT GETDATE() NOT NULL,
FLEASEMONTHS SMALLINT DEFAULT 0 NOT NULL,
FFREELEASESTARTDATE DATETIME,
FRENTWITHTAX DECIMAL(19,4) DEFAULT 0 NOT NULL,
FPAYPERIOD VARCHAR(30) DEFAULT 'MONTH' NOT NULL,
FPAYMETHOD VARCHAR(30) DEFAULT 'PRVIEWPAY' NOT NULL,
FINVOICETYPE VARCHAR(30) DEFAULT 'VALUEADDED' NOT NULL,
FTAXRATE DECIMAL(19,4) DEFAULT 0 NOT NULL,
FISDEDUCTIBLE CHAR(1) DEFAULT '1' NOT NULL,
FDEDUCTINPUTTAX DECIMAL(19,4) DEFAULT 0 NOT NULL,
FPREPAYRENT DECIMAL(19,4) DEFAULT 0 NOT NULL,
FDEINPUTTAXFORPRE DECIMAL(19,4) DEFAULT 0 NOT NULL,
FINITCONFIRMDATE DATETIME,
FISEXEMPT CHAR(1) DEFAULT '0' NOT NULL,
FDISCOUNTRATE DECIMAL(19,4) DEFAULT 0 NOT NULL,
FLEASELIAB DECIMAL(19,4) DEFAULT 0 NOT NULL,
FINITCOST DECIMAL(19,4) DEFAULT 0 NOT NULL,
FDEPREMONTHS SMALLINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FLEASEASSETS DECIMAL(19,4) DEFAULT 0 NOT NULL,
FFREELEASEMONTHS SMALLINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME
);



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