-- ABS-20494

---------- FINISHINGMETHOD  ----------------
ALTER TABLE FINISHINGMETHOD ADD (STOCKREPLENISHMENTDEFAULT VARCHAR2(1) DEFAULT 'N' NOT NULL CONSTRAINT YN_VALIDATIONFIELD264 CHECK (STOCKREPLENISHMENTDEFAULT IN ('Y','N')));

COMMENT ON COLUMN FINISHINGMETHOD.STOCKREPLENISHMENTDEFAULT
  IS 'This setting is only relevant when the module ADVANCEDPURCHASING is in the license';
  
UPDATE FINISHINGMETHOD FM 
SET FM.STOCKREPLENISHMENTDEFAULT = 'Y'
WHERE FM.FINISHINGMETHOD_ID = (SELECT MIN(FM1.FINISHINGMETHOD_ID) FROM FINISHINGMETHOD FM1);

COMMIT;


---------------- WORKORDER  ---------------------
COMMENT ON COLUMN WORKORDER.ORIGIN
  IS '1 = Generated from wearer inventory
2 = Manual created work order
3 = Created by web module
4 = Created by route assistant
5 = Conversion
6 = Sales note
7 = Credit note
8 = Internal Purchase Order
9 = Stock Delivery Order
10 = Mounting Order
11 = Dismounting Order
12 = Stock Replenishment Order';
-- Create/Recreate check constraints 

ALTER TABLE WORKORDER
  ADD CONSTRAINT ORIGIN_VALID1_2
  CHECK (ORIGIN IN (0,1,2,3,4,5,6,7,8,9,10,11,12));


-----------------  REASONCODE  --------------------
ALTER TABLE REASONCODE ADD (STOCKREPLENISHMENTREASON VARCHAR2(1) DEFAULT 'N' NOT NULL CONSTRAINT YN_VALIDATIONFIELD265 CHECK (STOCKREPLENISHMENTREASON IN ('N','Y')));
 
COMMENT ON COLUMN REASONCODE.STOCKREPLENISHMENTREASON
  IS 'Only applicable if ADVANCEDPURCHASING module is in the license';