-- ABS-30049
---------   BACKORDERWOL   -----------
ALTER TABLE BACKORDERWOL ADD (QUANTITYFILLED NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN BACKORDERWOL.QUANTITYFILLED IS 'Quantity that has been issued (or put away in case of replenishment work order)';

---------   BACKORDERWOLE   -----------
ALTER TABLE BACKORDERWOLE ADD (QUANTITYFILLED NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN BACKORDERWOLE.QUANTITYFILLED IS 'Quantity that has been issued (or put away in case of replenishment work order)';

---------   BACKORDEREXECUTIONWOL   -----------
ALTER TABLE BACKORDEREXECUTIONWOL ADD (QUANTITYFILLED NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN BACKORDEREXECUTIONWOL.QUANTITYFILLED IS 'Quantity that has been issued (or put away in case of replenishment work order)';


---------   BACKORDEREXECUTIONWOLE   -----------
ALTER TABLE BACKORDEREXECUTIONWOLE ADD (QUANTITYFILLED NUMBER DEFAULT 0 NOT NULL);

COMMENT ON COLUMN BACKORDEREXECUTIONWOLE.QUANTITYFILLED IS 'Quantity that has been issued (or put away in case of replenishment work order)';

---------   WORKORDERLINEPREPARATION   -----------
CREATE TABLE WORKORDERLINEPREPARATION (
	WORKORDERLINE_ID NUMBER NOT NULL,
	RECEIVEINSTOCKHISTORY_ID NUMBER NOT NULL,
	QTYPREPARED NUMBER DEFAULT 1 NOT NULL,
	QTYFILLED NUMBER DEFAULT 0 NOT NULL,
	SYSTEMUSER_ID NUMBER NOT NULL,
	TIMESTAMP DATE NOT NULL
);

COMMENT ON COLUMN WORKORDERLINEPREPARATION.QTYPREPARED IS 'Number of items that have been allocated from the checked-in items that were received in this RIS transaction for this work order line.';

COMMENT ON COLUMN WORKORDERLINEPREPARATION.QTYFILLED IS 'Number of items that has been issued from the allocated items for this work order line.';

ALTER TABLE WORKORDERLINEPREPARATION ADD CONSTRAINT XPKWORKORDERLINEPREPARATION PRIMARY KEY
(WORKORDERLINE_ID, RECEIVEINSTOCKHISTORY_ID);

CREATE INDEX XIF1WORKORDERLINEPREPARATION ON WORKORDERLINEPREPARATION (WORKORDERLINE_ID ASC);

CREATE INDEX XIF2WORKORDERLINEPREPARATION ON WORKORDERLINEPREPARATION (RECEIVEINSTOCKHISTORY_ID ASC);

ALTER TABLE WORKORDERLINEPREPARATION ADD CONSTRAINT WORKORDERLINEPREPARATION_WOLID FOREIGN KEY
(WORKORDERLINE_ID) REFERENCES WORKORDERLINE (WORKORDERLINE_ID) ON DELETE CASCADE;

ALTER TABLE WORKORDERLINEPREPARATION ADD CONSTRAINT WORKORDERLINEPREPARATION_RISID FOREIGN KEY
(RECEIVEINSTOCKHISTORY_ID) REFERENCES RECEIVEINSTOCKHISTORY (RECEIVEINSTOCKHISTORY_ID) ON DELETE CASCADE;

---------   WORKORDERLINEEMBLEMPREP   -----------
CREATE TABLE WORKORDERLINEEMBLEMPREP (
	WORKORDERLINEEMBLEM_ID NUMBER NOT NULL,
	RECEIVEINSTOCKHISTORY_ID NUMBER NOT NULL,
	QTYPREPARED NUMBER DEFAULT 1 NOT NULL,
	QTYFILLED NUMBER DEFAULT 0 NOT NULL,
	SYSTEMUSER_ID NUMBER NOT NULL,
	TIMESTAMP DATE NOT NULL
);

COMMENT ON COLUMN WORKORDERLINEEMBLEMPREP.QTYPREPARED IS 'Number of items that have been allocated from the checked-in items that were received in this RIS transaction for this work order line.';

COMMENT ON COLUMN WORKORDERLINEEMBLEMPREP.QTYFILLED IS 'Number of items that has been issued from the allocated items for this work order line.';

ALTER TABLE WORKORDERLINEEMBLEMPREP ADD CONSTRAINT XPKWORKORDERLINEEMBLEMPREP PRIMARY KEY
(WORKORDERLINEEMBLEM_ID, RECEIVEINSTOCKHISTORY_ID);

CREATE INDEX XIF1WORKORDERLINEEMBLEMPREP ON WORKORDERLINEEMBLEMPREP (WORKORDERLINEEMBLEM_ID ASC);

CREATE INDEX XIF2WORKORDERLINEEMBLEMPREP ON WORKORDERLINEEMBLEMPREP (RECEIVEINSTOCKHISTORY_ID ASC);

ALTER TABLE WORKORDERLINEEMBLEMPREP ADD CONSTRAINT WORKORDERLINEEMBLEMPREP_WOLEID FOREIGN KEY
(WORKORDERLINEEMBLEM_ID) REFERENCES WORKORDERLINEEMBLEM (WORKORDERLINEEMBLEM_ID) ON DELETE CASCADE;

ALTER TABLE WORKORDERLINEEMBLEMPREP ADD CONSTRAINT WORKORDERLINEEMBLEMPREP_RISHID FOREIGN KEY
(RECEIVEINSTOCKHISTORY_ID) REFERENCES RECEIVEINSTOCKHISTORY (RECEIVEINSTOCKHISTORY_ID) ON DELETE CASCADE;