--ABS-6133

---CUSTOMER table---
ALTER TABLE CUSTOMER ADD (LINENREDUCEFACTOR NUMBER DEFAULT 0 NOT NULL 
                          CONSTRAINT LINENREDUCEFACTOR_VALID1_1 CHECK (LINENREDUCEFACTOR BETWEEN 0 AND 6));
                          

COMMENT ON COLUMN CUSTOMER.LINENREDUCEFACTOR
  IS '0 = Not applicable (Linen delivery smoothener not used)
1 = Reduce factor A
2 = Reduce factor B
3 = Reduce factor C
4 = No reduce allowed
5 = Allow use of reduction (factor not used)
6 = No reduce allowes (factor not used)';


---STANDARDDELIVERY table---
ALTER TABLE STANDARDDELIVERY ADD (LINENREDUCTION NUMBER(1) DEFAULT 0 NOT NULL 
                                  CONSTRAINT LINENREDUCTION_VALID1_1 CHECK (LINENREDUCTION BETWEEN 0 AND 2));
                          

COMMENT ON COLUMN STANDARDDELIVERY.LINENREDUCTION
  IS '0 = Not applicable / Linen Delivery smoothener not used
1 = Linen Reduction is allowed
2 = Linen Reduction is not allowed';


---PACKINGNOTE table---
ALTER TABLE PACKINGNOTE ADD (REDUCEFACTOR NUMBER(1) DEFAULT 0 NOT NULL 
                             CONSTRAINT REDUCEFACTOR_VALID1_1 CHECK (REDUCEFACTOR BETWEEN 0 AND 4));
                          

COMMENT ON COLUMN PACKINGNOTE.REDUCEFACTOR
  IS '0 = Not applicable / Reduce not allowed
1 = Reduce factor A
2 = Reduce factor B
3 = Reduce factor C
4 = Reduce (no factor)';


---PACKINGNOTELINE table---
ALTER TABLE PACKINGNOTELINE ADD (REDUCEQUANTITY NUMBER DEFAULT 0 NOT NULL);
    

---STATUS table---
  INSERT INTO STATUS
          (STATUS_ID,
           STATUSTYPE,
           CODE,
           LEGACYSTATUSCODE,
           SYSTEMUSER_ID,
           TIMESTAMP,
           FACTORYDESCRIPTION)
        VALUES
          (SEQ_STATUS.NEXTVAL,
           'PN',
           '60',
           '',
           GETMINSYSTEMUSER(),
           GETCURRENTDATETIME(),
           'Pre-packingnote');
   COMMIT;

INSERT INTO STATUS_DESC
  (STATUS_ID,
   LANGUAGE_ID,
   DESCRIPTION, 
   SYSTEMUSER_ID, 
   TIMESTAMP)
  SELECT STATUS_ID,
         GETMINLANGUAGE(),
         FACTORYDESCRIPTION,
         SYSTEMUSER_ID,
         TIMESTAMP
    FROM STATUS
   WHERE STATUS.STATUSTYPE = 'PN'
     AND STATUS.CODE = '60';
COMMIT;
