-- ABS-29178

---STOCKROOM table---
ALTER TABLE STOCKROOM ADD (CHECKINLOCATION_ID NUMBER NULL,
                           PREWASHLOCATION_ID NUMBER NULL,
                           CHECKINAREACUST VARCHAR2(12) NULL,
                           CHECKINAREASPEC VARCHAR2(12) NULL,
                           WMSOVERFLOWLOCATION_ID NUMBER NULL);

COMMENT ON COLUMN STOCKROOM.CHECKINLOCATION_ID
  IS 'Will only be filled when module ADVANCEDPURCHASING is active';
COMMENT ON COLUMN STOCKROOM.PREWASHLOCATION_ID
  IS 'Will only be filled when module ADVANCEDPURCHASING is active';
COMMENT ON COLUMN STOCKROOM.CHECKINAREACUST
  IS 'Area code for a virtual check-in of items on a PO that have to be shipped to a customer.
Will only be filled when module ADVANCEDPURCHASING is active';
COMMENT ON COLUMN STOCKROOM.CHECKINAREASPEC
  IS 'Area code for a virtual check-in of items on a PO that have to be shipped to a specific delivery address.
Will only be filled when module ADVANCEDPURCHASING is active';
COMMENT ON COLUMN STOCKROOM.WMSOVERFLOWLOCATION_ID
  IS 'Will only be filled when module WMSINTERFACE is active';
 
CREATE INDEX XIF7STOCKROOM ON STOCKROOM (CHECKINLOCATION_ID ASC);
CREATE INDEX XIF8STOCKROOM ON STOCKROOM (PREWASHLOCATION_ID ASC);
CREATE INDEX XIF9STOCKROOM ON STOCKROOM (WMSOVERFLOWLOCATION_ID ASC);
 
ALTER TABLE STOCKROOM
  ADD CONSTRAINT STOCKROOM_CHECKINLOCATION FOREIGN KEY (CHECKINLOCATION_ID)
  REFERENCES STOCKROOMLOCATION (STOCKROOMLOCATION_ID);
ALTER TABLE STOCKROOM
  ADD CONSTRAINT STOCKROOM_PREWASHLOCATION FOREIGN KEY (PREWASHLOCATION_ID)
  REFERENCES STOCKROOMLOCATION (STOCKROOMLOCATION_ID);
ALTER TABLE STOCKROOM
  ADD CONSTRAINT STOCKROOM_WMSOVERFLOWLOC FOREIGN KEY (WMSOVERFLOWLOCATION_ID)
  REFERENCES STOCKROOMLOCATION (STOCKROOMLOCATION_ID);

---LOCATIONTYPE table---
insert into locationtype
  (locationtype_id,
   code,
   factorydescription,
   systemuser_id,
   timestamp,
   pickinglocation,
   valuecontribution,
   priority,
   active,
   useforpurchreqcalculation)
values
  (13,
   'CHECKIN',
   'Check-in',
   getminsystemuser(),
   getcurrentdatetime(),
   'N',
   'Y',
   0,
   'Y',
   1);
commit;

insert into locationtype_desc
  (locationtype_id, language_id, description, systemuser_id, timestamp)
  select locationtype_id, getminlanguage(), code, systemuser_id, timestamp
    from locationtype
   where locationtype.code = 'CHECKIN';
commit;