-- 平衡利库匹配明细
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_BALINV_DETAILENTRY')
 CREATE TABLE T_IM_BALINV_DETAILENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FINVORGID BIGINT DEFAULT 0 NOT NULL,
FMATERIELID BIGINT DEFAULT 0 NOT NULL,
FDEMANDORGID BIGINT DEFAULT 0 NOT NULL,
FDEMANDKIND CHAR(1) DEFAULT ' ' NOT NULL,
FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
FBASEUNITID BIGINT DEFAULT 0 NOT NULL,
FPREVIOUSBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FMATCHBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYUNITID BIGINT DEFAULT 0 NOT NULL,
FMATCHQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUPPLYUNIT2NDID BIGINT DEFAULT 0 NOT NULL,
FMATCHQTY2ND DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSRCSUPPLYBASEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
FDEMANDBILLTYPEID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FDEMANDBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDEMANDDATE DATETIME,
FLEVEL INT DEFAULT 0 NOT NULL,
FDEMANDBILLID BIGINT DEFAULT 0 NOT NULL,
FDEMANDENTRYID BIGINT DEFAULT 0 NOT NULL,
FDEMANDBILLSEQ INT DEFAULT 0 NOT NULL,
FEXTRAINFO NVARCHAR(512) DEFAULT ' ' NOT NULL,
FEXTRAINFONUM NVARCHAR(512) DEFAULT ' ' NOT NULL,
FEXTRAINFO_TAG NCLOB,
FSUPPLYORGID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYBILLTYPEID NVARCHAR(80) DEFAULT ' ' NOT NULL,
FSUPPLYBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUPPLYBILLDATE DATETIME,
FSUPPLYBILLID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYBILLENTRYID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYBILLSEQ INT DEFAULT 0 NOT NULL,
FSUPPLYTYPE CHAR(1) DEFAULT ' ' NOT NULL,
FSUPPLYTYPELEVEL INT DEFAULT 0 NOT NULL,
FSUPPLYMATERIELID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYWAREHOUSEID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYLOCATIONID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYDETAILLEVEL NVARCHAR(255) DEFAULT ' ' NOT NULL,
FINVADVICENO NVARCHAR(80) DEFAULT ' ' NOT NULL,
FINVADVICESEQ INT DEFAULT 0 NOT NULL,
FDEMANDOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDEMANDOWNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYOWNERTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSUPPLYOWNERID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYAUXPTYID BIGINT DEFAULT 0 NOT NULL,
FSUPPLYINVORG BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_BALINV_MATCHDETAIL')
 CREATE TABLE T_IM_BALINV_MATCHDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FCALCULATENUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IM_BALINV_MATCHDETAIL_L')
 CREATE TABLE T_IM_BALINV_MATCHDETAIL_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
);


