-- ABS-25929 / ABS-50642
--------------- CUSTOMER --------------- 
ALTER TABLE CUSTOMER ADD CUSTOMGARMENTCHARGE VARCHAR2(1) DEFAULT 'N' NOT NULL 
                     CONSTRAINT YN_VALIDATIONFIELD379 CHECK (CUSTOMGARMENTCHARGE IN ('Y', 'N'));

--------------- PRODUCT --------------- 
ALTER TABLE PRODUCT ADD CUSTOMGARMENTCHARGE VARCHAR2(1) DEFAULT 'N' NOT NULL 
                     CONSTRAINT YN_VALIDATIONFIELD380 CHECK (CUSTOMGARMENTCHARGE IN ('Y', 'N'));
                     
--------------- INVOICELINETYPE ---------------   
COMMENT ON COLUMN INVOICELINETYPE.TYPE
  IS '01= Rent 02= Delivery (wash) 03= Soil Weight 04= Clean Weight 05= Sales 06= Repair 07= Replacement charge 08= Automatic Replacement (non-garm) 09= Loss charge 10= Remaining value charge 11= Overuse charge 12= Prep / Emblem charge 13= Finance charge 14= Cash Delay line 15= Miscellaneous Invoice line 16= Special Charge 17= Minimum invoice amount 18= Tax 19= Emblem Rent 20= Locker Rent 21= Locker service 22= Lease 23= Stock Charge 24= Lost Customer Residual Value Charge 25= Lost Revenue Charge 26= Residential wash 27= Residential labels 28= Service costs 29= Capped Excess Amounts 30= Client rent 31= Budget 32= Down Payment 33= Statement fee 34 = Custom Garment Charge';

ALTER TABLE INVOICELINETYPE DROP CONSTRAINT TYPE_valid;

ALTER TABLE INVOICELINETYPE
  ADD CONSTRAINT TYPE_valid CHECK (TYPE BETWEEN 1 AND 34);
	
INSERT INTO INVOICELINETYPE
            (INVOICELINETYPE_ID,
             TYPE,
             FACTORYDESCRIPTION,
             INCLUDEINMINIMUMCALC,
             TAXTYPE,
             DEFINETURNOVERGROUP,
             DEFINESPECIALCHARGE,
             SUPRESSPRINTING,
             SYSTEMUSER_ID,
             TIMESTAMP)
          VALUES
            (34,
             34,
             'Custom Garment Charge',
             'Y',
             2,
             'Y',
             'Y',
             0,
             GETMINSYSTEMUSER(),
             SYSDATE);
COMMIT;

INSERT INTO INVOICELINETYPE_DESC
          (INVOICELINETYPE_ID,
           LANGUAGE_ID,
           DESCRIPTION,
           SYSTEMUSER_ID,
           TIMESTAMP)
          SELECT X.INVOICELINETYPE_ID,
                 L.LANGUAGE_ID,
                 X.FACTORYDESCRIPTION,
                 X.SYSTEMUSER_ID,
                 X.TIMESTAMP
            FROM INVOICELINETYPE X, LANGUAGES L
            WHERE X.INVOICELINETYPE_ID = 34;
COMMIT;

--------------- INVOICELINESUBTYPE ---------------
INSERT INTO INVOICELINESUBTYPE I
      (I.INVOICELINESUBTYPE_ID,
       SUBTYPE,
       INVOICELINETYPE_ID,
       FACTORYDESCRIPTION,
       SYSTEMUSER_ID,
       TIMESTAMP)
      SELECT SEQ_INVOICELINESUBTYPE.NEXTVAL,
             0,
             34,
             'Custom Garment Charge',
             GETMINSYSTEMUSER(),
             SYSDATE
        FROM DUAL;
COMMIT;
        
INSERT INTO INVOICELINESUBTYPE_DESC
      (INVOICELINESUBTYPE_ID,
       LANGUAGE_ID,
       DESCRIPTION,
       SYSTEMUSER_ID,
       TIMESTAMP)
      SELECT I.INVOICELINESUBTYPE_ID,
             L.LANGUAGE_ID,
             I.FACTORYDESCRIPTION,
             GETMINSYSTEMUSER(),
             SYSDATE
        FROM INVOICELINESUBTYPE I, LANGUAGES L
       WHERE L.TRANSLATEDESCRIPTION = 'Y' AND I.SUBTYPE = 0 AND I.INVOICELINETYPE_ID = 34;
COMMIT;

