-- Drop table

-- DROP TABLE  t_im_mdc_omcmplinbill;
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcmplinbill') 
CREATE TABLE  t_im_mdc_omcmplinbill (
	fid BIGINT DEFAULT 0 NOT NULL,
	fbillno NVARCHAR(30) DEFAULT ' ' NOT NULL,
	fbillstatus NVARCHAR(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,
	fcreatetime DATETIME,
	forgid BIGINT DEFAULT 0 NOT NULL,
	fbilltypeid BIGINT DEFAULT 0 NOT NULL,
	fbizorgid BIGINT DEFAULT 0 NOT NULL,
	fbizdeptid BIGINT DEFAULT 0 NOT NULL,
	fdeptid BIGINT DEFAULT 0 NOT NULL,
	foperatorgroupid BIGINT DEFAULT 0 NOT NULL,
	foperatorid 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,
	fbillcretype NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fbookdate DATETIME,
	fsupplierid BIGINT DEFAULT 0 NOT NULL,
	ftransactepathid BIGINT DEFAULT 0 NOT NULL,
	fisinitbill CHAR(1) DEFAULT '0' NOT NULL,
	fsupplytrans CHAR(1) DEFAULT '0' NOT NULL,
	fcurrencyid BIGINT DEFAULT 0 NOT NULL,
	fsettlecurrencyid BIGINT DEFAULT 0 NOT NULL,
	fexratetable BIGINT DEFAULT 0 NOT NULL,
	fexratedate DATETIME,
	fexchangerate DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fpaymode NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fsettletypeid BIGINT DEFAULT 0 NOT NULL,
	fpayconditionid BIGINT DEFAULT 0 NOT NULL,
	fistax CHAR(1) DEFAULT '1' NOT NULL,
	forgfield BIGINT DEFAULT 0 NOT NULL
	
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcmplinbill_l') 
CREATE TABLE  t_im_mdc_omcmplinbill_l (
	fpkid NVARCHAR(36) DEFAULT ' ' NOT NULL,
	fid BIGINT DEFAULT 0 NOT NULL,
	flocaleid NVARCHAR(10) DEFAULT ' ' NOT NULL,
	fcomment NVARCHAR(512) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcpbillentry') 
CREATE TABLE  t_im_mdc_omcpbillentry (
	fid BIGINT DEFAULT 0 NOT NULL,
	fentryid BIGINT DEFAULT 0 NOT NULL,
	fseq BIGINT DEFAULT 0 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 NVARCHAR(512) DEFAULT ' ' NOT NULL,
	fownertype NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fkeepertype NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fownerid BIGINT DEFAULT 0 NOT NULL,
	fkeeperid BIGINT DEFAULT 0 NOT NULL,
	flotnumber NVARCHAR(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 NVARCHAR(50) DEFAULT ' ' NOT NULL,
	foutownerid BIGINT DEFAULT 0 NOT NULL,
	foutkeepertype NVARCHAR(50) DEFAULT ' ' NOT NULL,
	foutkeeperid BIGINT DEFAULT 0 NOT NULL,
	fprovideraddress NVARCHAR(300) DEFAULT ' ' NOT NULL,
	fphone NVARCHAR(50) DEFAULT ' ' NOT NULL	
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcpbillentry_l')
 CREATE TABLE  t_im_mdc_omcpbillentry_l (
	fpkid NVARCHAR(36) DEFAULT ' ' NOT NULL,
	fentryid BIGINT DEFAULT 0 NOT NULL,
	flocaleid NVARCHAR(10) DEFAULT ' ' NOT NULL,
	fprovideraddress NVARCHAR(300) DEFAULT ' ' NOT NULL
);


-- Drop table

-- DROP TABLE  t_im_mdc_omcpbillentry_m;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcpbillentry_m') 
CREATE TABLE  t_im_mdc_omcpbillentry_m (
	fid BIGINT DEFAULT 0 NOT NULL,
	fentryid BIGINT DEFAULT 0 NOT NULL,
	fsuplot NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fentryreqorgid BIGINT DEFAULT 0 NOT NULL,
	fentrysettleorgid BIGINT DEFAULT 0 NOT NULL,
	fispresent CHAR(1) DEFAULT '0' NOT NULL,
	ftaxrateid BIGINT DEFAULT 0 NOT NULL,
	fprice DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fpriceandtax DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fdiscounttype NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fdiscountrate DECIMAL(23,10) DEFAULT 0 NOT NULL,
	factualprice DECIMAL(23,10) DEFAULT 0 NOT NULL,
	factualtaxprice DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fdiscountamount DECIMAL(23,10) DEFAULT 0 NOT NULL,
	famount DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fcuramount DECIMAL(23,10) DEFAULT 0 NOT NULL,
	ftaxamount DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fcurtaxamount DECIMAL(23,10) DEFAULT 0 NOT NULL,
	famountandtax DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fcuramountandtax DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fprovidersupplierid BIGINT DEFAULT 0 NOT NULL,
	finvoicesupplierid BIGINT DEFAULT 0 NOT NULL,
	freceivesupplierid BIGINT DEFAULT 0 NOT NULL,
	fproviderlinkmanid BIGINT DEFAULT 0 NOT NULL,
	ftaxratefield DECIMAL(23,10) DEFAULT 0 NOT NULL,
	freceivedate DATETIME,
	fproducttype NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fqualitystatus NVARCHAR(50) DEFAULT ' ' NOT NULL
);


-- Drop table

-- DROP TABLE  t_im_mdc_omcpbillentry_r;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcpbillentry_r') 
CREATE TABLE  t_im_mdc_omcpbillentry_r (
	fid BIGINT DEFAULT 0 NOT NULL,
	fentryid BIGINT DEFAULT 0 NOT NULL,
	fsrcbillentity NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fsrcbillid BIGINT DEFAULT 0 NOT NULL,
	fsrcbillentryid BIGINT DEFAULT 0 NOT NULL,
	fsrcbillnumber NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fsrcbillentryseq BIGINT DEFAULT 0 NOT NULL,
	flogisticsbill CHAR(1) DEFAULT '0' NOT NULL,
	fmversion BIGINT DEFAULT 0 NOT NULL,
	fsrcsystem NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fsrcsysbillid NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fsrcsysbillentryid NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fmainbillentity NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fmainbillnumber NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fmainbillid BIGINT DEFAULT 0 NOT NULL,
	fmainbillentryid BIGINT DEFAULT 0 NOT NULL,
	fmainbillentryseq BIGINT DEFAULT 0 NOT NULL,
	freturnqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	freturnbaseqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fremainreturnqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fremainreturnbaseqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fjoinpriceqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fjoinpricebaseqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fremainjoinpriceqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fremainjoinpricebaseqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fverifyqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fverifybaseqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	funverifyqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	funverifybaseqty DECIMAL(23,10) DEFAULT 0 NOT NULL,
	fgroupnumber NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fgroupseq NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fmanubill NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fmanubillid BIGINT DEFAULT 0 NOT NULL,
	fmanuentry NVARCHAR(50) DEFAULT ' ' NOT NULL,
	fmanuentryid BIGINT DEFAULT 0 NOT NULL	
);

-- Drop table

-- DROP TABLE  t_im_mdc_omcpbillentry_x;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 't_im_mdc_omcpbillentry_x') 
CREATE TABLE  t_im_mdc_omcpbillentry_x (
	fid BIGINT DEFAULT 0 NOT NULL,
	fentryid BIGINT DEFAULT 0 NOT NULL	
);

