-- ABS-36168/ ABS-41577

---CONTRACTATTRIBUTE table---
INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (1,
   1,
   1,
   'CustomerRelated',
   'cmbCustomerRelated',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (5,
   2,
   1,
   'AllowAutomaticSales',
   'cbAllowAutomaticSales',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (55,
   7,
   5,
   'SplitInvoicesPerActivity',
   'cbSplitInvoicesPerActivity',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (63,
   7,
   13,
   'ChargeLossForPoolItems',
   'cbChargeLossForPoolAfterXDays',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (64,
   7,
   14,
   'ChargeLossForUniquePoolDays',
   'sfChargeLossForPoolNoDays',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (98,
   1,
   5,
   'SoilCount',
   'cbSoilCount',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID,
   GROUPNUMBER,
   SEQUENCENUMBER,
   FACTORYNAME,
   INTERNALNAME,
   SYSTEMUSER_ID,
   TIMESTAMP)
VALUES
  (99,
   1,
   6,
   'InternetOrdering',
   'cbInternetOrdering',
   GETMINSYSTEMUSER(),
   sysdate);
COMMIT;

UPDATE CONTRACTATTRIBUTE CA
SET CA.GROUPNUMBER = 8, CA.SEQUENCENUMBER = 4
WHERE CA.CONTRACTATTRIBUTE_ID = 83;
COMMIT;

UPDATE CONTRACTATTRIBUTE CA
SET CA.GROUPNUMBER = 8, CA.SEQUENCENUMBER = 9
WHERE CA.CONTRACTATTRIBUTE_ID = 88;
COMMIT;

UPDATE CONTRACTATTRIBUTE CA
SET CA.GROUPNUMBER = 8, CA.SEQUENCENUMBER = 10
WHERE CA.CONTRACTATTRIBUTE_ID = 89;
COMMIT;

UPDATE CONTRACTATTRIBUTE CA
SET CA.SEQUENCENUMBER = 26
WHERE CA.CONTRACTATTRIBUTE_ID = 97;
COMMIT;

---CONTRACTDISCOUNTLIST table---
DROP INDEX XAK1CONTRACTDISCOUNTLIST;

CREATE UNIQUE INDEX XAK1CONTRACTDISCOUNTLIST ON CONTRACTDISCOUNTLIST (CONTRACT_ID ASC, GENERALDISCOUNTLIST_ID ASC, STARTDATE ASC, PRICETYPE ASC);

---CONTRACTPRICELIST table---
DROP INDEX XAK1CONTRACTPRICELIST;

CREATE UNIQUE INDEX XAK1CONTRACTPRICELIST ON CONTRACTPRICELIST (CONTRACT_ID ASC, GENERALPRICELIST_ID ASC, STARTDATE ASC, PRICETYPE ASC);

---CONTRACTDISCOUNTLIST table---
ALTER TABLE CONTRACTDISCOUNTLIST MODIFY (GENERALDISCOUNTLIST_ID NULL);

---CONTRACTCOMPONENTGRMCHANGES table---
ALTER TABLE CONTRACTCOMPONENTGRMCHANGES RENAME TO CONTRACTCOMPONENTGRMCHARGES;

ALTER TABLE CONTRACTCOMPONENTGRMCHARGES RENAME CONSTRAINT XPKCONTRACTCOMPONENTGRMCHANGES TO XPKCONTRACTCOMPONENTGRMCHARGES;

ALTER INDEX XIF1CONTRACTCOMPGRMCHANGES RENAME TO XIF1CONTRACTCOMPGRMCHARGES;