-- ABS-30087

--------- USERGROUP ---------
ALTER TABLE USERGROUP ADD (ALLOWCONTRACTCOEFFICIENT VARCHAR2(1) DEFAULT 'N' NOT NULL);
ALTER TABLE USERGROUP ADD CONSTRAINT  YN_VALIDATIONFIELD298 CHECK (ALLOWCONTRACTCOEFFICIENT IN  ('Y', 'N'));


--------- CUSTOMER ---------
ALTER TABLE CUSTOMER ADD (USECONTRACTCOEFFICIENT VARCHAR2(1) DEFAULT 'N' NOT NULL,
                         CONTRACTCOEFFICIENT NUMBER(15,3) DEFAULT 0.000 NOT NULL);
                         
ALTER TABLE CUSTOMER ADD CONSTRAINT  YN_VALIDATIONFIELD299 CHECK (USECONTRACTCOEFFICIENT IN  ('Y', 'N'));


--------- CUSTOMERRENTPRICE ---------
ALTER TABLE CUSTOMERRENTPRICE ADD (CONTRACTCOEFFICIENT NUMBER(6,3) NULL);


--------- INVOICELINE ---------
ALTER TABLE INVOICELINE ADD (CONTRACTCOEFFICIENT NUMBER(6,3) NULL);


--------- INVOICEFREQUENCY ---------
COMMENT ON COLUMN INVOICEFREQUENCY.INVOICEFREQUENCYNUMBER
  IS '0=DIRECT 5 = DIRECT WITH ALL SERVICES 10=WEEKLY 20=EVERY 2 WEEKS 30=EVERY 3 WEEKS 40=EVERY 4 WEEKS 45=4-4-5 WEEK SCHEDULE 50=EVERY 8 WEEKS 60=EVERY 13 WEEKS 65=EVERY 16 WEEKS 70=EVERY 26 WEEKS 80=EVERY 52 WEEKS 105=TWICE A MONTH 110=MONTHLY 111=MONTHLY (PRICE*1) 112=MONTHLY WITH COEFFICIENT 115=MONTHLY (PRICE*4.33) 120=EVERY 2 MONTHS 121=2 MONTHLY (PRICE*1) 130=EVERY 3 MONTHS 131=3 MONTHLY (PRICE*1) 140=EVERY 4 MONTHS 141=4 MONTHLY (PRICE*1) 160=EVERY 6 MONTHS 161=6 MONTHLY (PRICE*1) 170=EVERY 12 MONTHS 171=12 MONTHLY (PRICE*1) 200=MANUAL';
  
INSERT INTO INVOICEFREQUENCY
  (INVOICEFREQUENCY_ID,
   INVOICEFREQUENCYNUMBER,
   FACTORYDESCRIPTION,
   SYSTEMUSER_ID,
   TIMESTAMP,
   DEFAULTFREQUENCY,
   PRICEFREQUENCYNUMBER)
  SELECT 112, 112, 'Monthly with coefficient', GETMINSYSTEMUSER(), SYSDATE, 'N', 110 FROM DUAL;
  
COMMIT;


--------- INVOICEFREQUENCY_DESC ---------
INSERT INTO INVOICEFREQUENCY_DESC
  (INVOICEFREQUENCY_ID, LANGUAGE_ID, DESCRIPTION, SYSTEMUSER_ID, TIMESTAMP)
  SELECT X.INVOICEFREQUENCY_ID,
         L.LANGUAGE_ID,
         X.FACTORYDESCRIPTION,
         X.SYSTEMUSER_ID,
         X.TIMESTAMP
    FROM INVOICEFREQUENCY X, LANGUAGES L
   WHERE X.INVOICEFREQUENCY_ID = 112
     AND L.TRANSLATEDESCRIPTION = 'Y';

COMMIT;