/**Begin D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\IM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_BIZTYPEENTRY') 
 CREATE TABLE T_IM_BIZTYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INTERORGSETTLECFG') 
 CREATE TABLE T_IM_INTERORGSETTLECFG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBILL BIGINT DEFAULT 0 NOT NULL,
FBALANCEORG NVARCHAR(80) DEFAULT ' ' NOT NULL,
FBALANCEORGNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOWNERORG NVARCHAR(80) DEFAULT ' ' NOT NULL,
FOWNERORGNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FBILLFILTERSTR NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVTYPEENTRY') 
 CREATE TABLE T_IM_INVTYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FISDEFAULT CHAR(1) DEFAULT '0' NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_OUTINVTYPEENTRY') 
 CREATE TABLE T_IM_OUTINVTYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FISDEFAULT CHAR(1) DEFAULT '0' NOT NULL,
FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_SETTLERELATIONS_L') 
 CREATE TABLE T_IM_SETTLERELATIONS_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_SETTLERELATIONDETAIL') 
 CREATE TABLE T_IM_SETTLERELATIONDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FSUPPLIER BIGINT DEFAULT 0 NOT NULL,
FDEMAND BIGINT DEFAULT 0 NOT NULL,
FSALEORG BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERSTOREORG BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERWAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FSUPPLIERLOCATION BIGINT DEFAULT 0 NOT NULL,
FPURORG BIGINT DEFAULT 0 NOT NULL,
FDEMANDWAREHOUSEORG BIGINT DEFAULT 0 NOT NULL,
FDEMANDWAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FDEMANDLOCATION BIGINT DEFAULT 0 NOT NULL,
FINTERORGSETTLERULE BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_SETTLERELATIONS') 
 CREATE TABLE T_IM_SETTLERELATIONS (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(120) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE NVARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FTRANSITONWER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FCOSTBEAR NVARCHAR(60) DEFAULT ' ' NOT NULL,
FDAMAGECOSTBEAR NVARCHAR(60) DEFAULT ' ' NOT NULL,
FOWNER BIGINT DEFAULT 0 NOT NULL,
FSETTLEORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVENTORY_L') 
 CREATE TABLE T_IM_INVENTORY_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INTERORGPRICE') 
 CREATE TABLE T_IM_INTERORGPRICE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INTERORGPRICE_L') 
 CREATE TABLE T_IM_INTERORGPRICE_L (
FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEPICT NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INTERORGPRICEINFO') 
 CREATE TABLE T_IM_INTERORGPRICEINFO (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FBIZTYPE BIGINT DEFAULT 0 NOT NULL,
FMATERIALGROUP BIGINT DEFAULT 0 NOT NULL,
FMATERIAL BIGINT DEFAULT 0 NOT NULL,
FSETTLESOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FTAXSOURCE CHAR(1) DEFAULT ' ' NOT NULL,
FCURRENCYSOURCE CHAR(1) DEFAULT '0' NOT NULL,
FADDNRATIO DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADDNFIXEDPRICE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCUSTOMPRICEPLUGIN NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPRICELEVEL INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVENTORY') 
 CREATE TABLE T_IM_INVENTORY (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FGROUPID BIGINT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FINVDC CHAR(1) DEFAULT 'A' NOT NULL,
FTRANSCEIVERTYPEID BIGINT DEFAULT 0 NOT NULL,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FISOUTUPDATE CHAR(1) DEFAULT '0' NOT NULL,
FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FOUTKEEPERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FISINUPDATE CHAR(1) DEFAULT '0' NOT NULL,
FISPRESET CHAR(1) DEFAULT '0' NOT NULL,
FBILLFORMID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISNOTUPDATE CHAR(1) DEFAULT '0' NOT NULL
);


 --- drop TABLE --------- 请认真检查该脚本 ------------------- 
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVSCHEME') 
 DROP TABLE T_IM_INVSCHEME;


/**End D:\nextcloud\dev2main2bizline\PDM_UPGRADE\pdm1\IM_table.sql **/
