/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\IM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL') 
 CREATE TABLE T_IM_INVINSPECTBILL (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(50) 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,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FBILLTYPEID BIGINT DEFAULT 0 NOT NULL,
FBIZORGID BIGINT DEFAULT 0 NOT NULL,
FBIZDEPTID BIGINT DEFAULT 0 NOT NULL,
FDEPTID BIGINT DEFAULT 0 NOT NULL,
FOPERATORID BIGINT DEFAULT 0 NOT NULL,
FOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FBIZOPERATORGROUPID BIGINT DEFAULT 0 NOT NULL,
FBIZOPERATORID BIGINT DEFAULT 0 NOT NULL,
FBIZTIME DATETIME,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FINVSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCOMMENT NVARCHAR(512) DEFAULT ' ' NOT NULL,
FISVIRTUALBILL CHAR(1) DEFAULT '0' NOT NULL,
FBILLCRETYPE CHAR(1) DEFAULT '0' NOT NULL,
FBOOKDATE DATETIME,
FASYNCSTATUS CHAR(1) DEFAULT 'B' NOT NULL,
FISCHARGEOFFED CHAR(1) DEFAULT '0' NOT NULL,
FISCHARGEOFF CHAR(1) DEFAULT '0' NOT NULL,
FLASTUPDATEUSERID BIGINT DEFAULT 0 NOT NULL,
FUNITSRCTYPE  VARCHAR(30) DEFAULT 'NULL' NOT NULL,
FLASTUPDATETIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILL_L') 
 CREATE TABLE T_IM_INVINSPECTBILL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FCOMMENT NVARCHAR(512) DEFAULT ' '
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY') 
 CREATE TABLE T_IM_INVINSPECTBILLENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLINETYPEID BIGINT DEFAULT 0 NOT NULL,
FMATERIALNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FMATERIALID BIGINT DEFAULT 0 NOT NULL,
FUNITID BIGINT DEFAULT 0 NOT NULL,
FQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FQTYUNIT2ND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FLOTID BIGINT DEFAULT 0 NOT NULL,
FPRODUCEDATE DATETIME,
FEXPIRYDATE DATETIME,
FENTRYCOMMENT VARCHAR(512) DEFAULT ' ' NOT NULL,
FOWNERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FKEEPERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FOWNERID BIGINT DEFAULT 0 NOT NULL,
FKEEPERID BIGINT DEFAULT 0 NOT NULL,
FLOTNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FPROJECTID BIGINT DEFAULT 0 NOT NULL,
FMATERIALMASTERID BIGINT DEFAULT 0 NOT NULL,
FOUTINVSTATUSID BIGINT DEFAULT 0 NOT NULL,
FOUTINVTYPEID BIGINT DEFAULT 0 NOT NULL,
FOUTOWNERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTOWNERID BIGINT DEFAULT 0 NOT NULL,
FOUTKEEPERTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FOUTKEEPERID BIGINT DEFAULT 0 NOT NULL,
FTRACKNUMBERID BIGINT DEFAULT 0 NOT NULL,
FCONFIGUREDCODEID BIGINT DEFAULT 0 NOT NULL,
FNOUPDATEINVFIELDS VARCHAR(100) DEFAULT ' ' NOT NULL,
FSERIALNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FECOSTCENTERID BIGINT DEFAULT 0 NOT NULL,
FENTRYREQORGID BIGINT DEFAULT 0 NOT NULL,
FINSPORG BIGINT DEFAULT 0 NOT NULL,
FQUALIFIEDQTY DECIMAL(10,2) DEFAULT 0 NOT NULL,
FQUALIFIEDBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONCESSIONQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCONCESSIONBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSCRAPBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHECKAGAINQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FCHECKAGAINBASEQTY DECIMAL(10,2) DEFAULT 0 NOT NULL,
FOUTWAREHOUSE BIGINT DEFAULT 0 NOT NULL,
FOUTLOCATION BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_INVINSPECTBILLENTRY_R') 
 CREATE TABLE T_IM_INVINSPECTBILLENTRY_R (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTITY NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSRCBILLNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSRCBILLENTRYSEQ BIGINT DEFAULT 0 NOT NULL,
FLOGISTICSBILL CHAR(1) DEFAULT '0' NOT NULL,
FMVERSION BIGINT DEFAULT 0 NOT NULL,
FSRCSYSTEM NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSBILLID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSRCSYSBILLENTRYID NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_TAILADJUST_SETTING') 
 CREATE TABLE T_IM_TAILADJUST_SETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FOPNUM VARCHAR(50) DEFAULT ' ' NOT NULL,
FCOMMONMAPID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODIFIER BIGINT DEFAULT 0 NOT NULL
);



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