/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT')
 CREATE TABLE T_FPM_REPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(30) 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,
FBIZDATE DATETIME,
FCREATETIME DATETIME,
FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FBODYSYS BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDECLARESTARTDATE DATETIME,
FDECLAREDEADLINE DATETIME,
FPLANSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCURRPROCESSOR BIGINT DEFAULT 0 NOT NULL,
FREPORTPERIOD BIGINT DEFAULT 0 NOT NULL,
FREPORTORG BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEBAKID BIGINT DEFAULT 0 NOT NULL,
FEXRATETABLE BIGINT DEFAULT 0 NOT NULL,
FEXCHANGERATEDATE DATETIME,
FROLLNUM INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_L') 
 CREATE TABLE T_FPM_REPORT_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORTDATADETAIL') 
 CREATE TABLE T_FPM_REPORTDATADETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMAINDIMDATAID BIGINT DEFAULT 0 NOT NULL,
FOPUSERTYPE NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPUSERID BIGINT DEFAULT 0 NOT NULL,
FBANKCATEID BIGINT DEFAULT 0 NOT NULL,
FCONTRACTNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONTRACTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPLANDATE DATETIME,
FBANKACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FDETAILEXT1 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAILEXT5 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAILEXT3 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAILEXT2 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAILEXT4 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDETAILEXT6 NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORTDATAMAIN') 
 CREATE TABLE T_FPM_REPORTDATAMAIN (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSYSTEMID BIGINT DEFAULT 0 NOT NULL,
FORGMEMID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYMEMID BIGINT DEFAULT 0 NOT NULL,
FPERIODMEMID BIGINT DEFAULT 0 NOT NULL,
FSUBJECTMEMID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYMEMID BIGINT DEFAULT 0 NOT NULL,
FSETTLETYPEMEMID BIGINT DEFAULT 0 NOT NULL,
FEXTMEM1ID BIGINT DEFAULT 0 NOT NULL,
FEXTMEM2ID BIGINT DEFAULT 0 NOT NULL,
FEXTMEM3ID BIGINT DEFAULT 0 NOT NULL,
FPLANAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FLOCKAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FREALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FVERSION INT DEFAULT 0 NOT NULL,
FORIGINDATAROW INT DEFAULT 0 NOT NULL,
FORIGINDATACOL INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_CURRENCY') 
 CREATE TABLE T_FPM_REPORT_CURRENCY (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);



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