-- ABS-49683
---------   COMPLIANCYGROUPATTRIBUTES  -----------
CREATE TABLE COMPLIANCYGROUPATTRIBUTES
(
CONTRACT_ID NUMBER NOT NULL,
CONTRACTATTRIBUTE_ID NUMBER NOT NULL
);

ALTER TABLE COMPLIANCYGROUPATTRIBUTES ADD CONSTRAINT XPKCOMPLIANCYGROUPATTRIBUTES PRIMARY KEY(CONTRACT_ID, CONTRACTATTRIBUTE_ID);

CREATE INDEX XIF1COMPLIANCYGROUPATTRIBUTES ON COMPLIANCYGROUPATTRIBUTES (CONTRACT_ID ASC);

CREATE INDEX XIF2COMPLIANCYGROUPATTRIBUTES ON COMPLIANCYGROUPATTRIBUTES (CONTRACTATTRIBUTE_ID ASC);

ALTER TABLE COMPLIANCYGROUPATTRIBUTES ADD CONSTRAINT COMPLIANCYGROUPATTRIBUTES_CID FOREIGN KEY (CONTRACT_ID)
REFERENCES CONTRACT (CONTRACT_ID) ON DELETE CASCADE;

ALTER TABLE COMPLIANCYGROUPATTRIBUTES ADD CONSTRAINT COMPLIANCYGROUPATTRIBUTES_CAID FOREIGN KEY (CONTRACTATTRIBUTE_ID)
REFERENCES CONTRACTATTRIBUTE (CONTRACTATTRIBUTE_ID);

---------   CONTRACTPRODUCTBILLING  -----------
ALTER TABLE CONTRACTPRODUCTBILLING ADD (COMPLIANCYRULE NUMBER NULL
					CONSTRAINT COMPLIANCYRULE_VALID1_2 CHECK ((COMPLIANCYRULE IN (0,1,2) AND COMPLIANCYRULE IS NOT NULL) OR (COMPLIANCYRULE IS NULL)));

COMMENT ON COLUMN CONTRACTPRODUCTBILLING.COMPLIANCYRULE IS '0 = Contract suggested, can be overruled 
1 = Contract enforced, can only be overruled by maintenance user
2 = Contract enforced
No default (Null)';

---------   CONTRACTPRODUCTORDERDELIVERY  -----------
ALTER TABLE CONTRACTPRODUCTORDERDELIVERY ADD (COMPLIANCYRULE NUMBER NULL
						CONSTRAINT COMPLIANCYRULE_VALID1_3 CHECK ((COMPLIANCYRULE IN (0,1,2) AND COMPLIANCYRULE IS NOT NULL) OR (COMPLIANCYRULE IS NULL)));

COMMENT ON COLUMN CONTRACTPRODUCTORDERDELIVERY.COMPLIANCYRULE IS '0 = Contract suggested, can be overruled 
1 = Contract enforced, can only be overruled by maintenance user
2 = Contract enforced
No default (Null)';

---------   CONTRACTPRODUCTMISCELLANEOUS  -----------
ALTER TABLE CONTRACTPRODUCTMISCELLANEOUS ADD (COMPLIANCYRULE NUMBER NULL
						CONSTRAINT COMPLIANCYRULE_VALID1_4 CHECK ((COMPLIANCYRULE IN (0,1,2) AND COMPLIANCYRULE IS NOT NULL) OR (COMPLIANCYRULE IS NULL)));

COMMENT ON COLUMN CONTRACTPRODUCTMISCELLANEOUS.COMPLIANCYRULE IS '0 = Contract suggested, can be overruled 
1 = Contract enforced, can only be overruled by maintenance user
2 = Contract enforced
No default (Null)';

---------   CONTRACTPRODUCTBGPROTECTION  -----------
CREATE TABLE CONTRACTPRODUCTBGPROTECTION 
(
CONTRACTPRODUCT_ID NUMBER NOT NULL,
MMSPECIFICPERCENTAGE NUMBER NULL CONSTRAINT MMSPECIFICPERCENTAGE_VALID1_1 CHECK ((MMSPECIFICPERCENTAGE BETWEEN 0.0 AND 100.0) OR (MMSPECIFICPERCENTAGE IS NULL)),
GARMENTSETUP VARCHAR2(1) NULL CONSTRAINT YN_VALIDATIONFIELD402 CHECK (GARMENTSETUP IN ('Y','N')),
GARMENTMAINTENANCE VARCHAR2(1) NULL CONSTRAINT YN_VALIDATIONFIELD403 CHECK (GARMENTMAINTENANCE IN ('Y','N')),
GARMENTLOSS VARCHAR2(1) NULL CONSTRAINT YN_VALIDATIONFIELD404 CHECK (GARMENTLOSS IN ('Y','N')),
GARMENTREPAIR VARCHAR2(1) NULL CONSTRAINT YN_VALIDATIONFIELD405 CHECK (GARMENTREPAIR IN ('Y','N')),
COMPLIANCYRULE NUMBER NULL CONSTRAINT COMPLIANCYRULE_VALID1_5 CHECK ((COMPLIANCYRULE IN (0,1,2) AND COMPLIANCYRULE IS NOT NULL) OR (COMPLIANCYRULE IS NULL)),
SYSTEMUSER_ID NUMBER NOT NULL,
TIMESTAMP DATE NOT NULL
);

COMMENT ON COLUMN CONTRACTPRODUCTBGPROTECTION.COMPLIANCYRULE IS '0 = Contract suggested, can be overruled 
1 = Contract enforced, can only be overruled by maintenance user
2 = Contract enforced
No default (Null)';

ALTER TABLE CONTRACTPRODUCTBGPROTECTION ADD CONSTRAINT XPKCONTRACTPRODUCTBGPROTECTION PRIMARY KEY (CONTRACTPRODUCT_ID);

ALTER TABLE CONTRACTPRODUCTBGPROTECTION ADD CONSTRAINT CONTRACTPRODUCTBGPROTECTION_C FOREIGN KEY (CONTRACTPRODUCT_ID)
REFERENCES CONTRACTPRODUCT (CONTRACTPRODUCT_ID) ON DELETE CASCADE;

---------   CONTRACTATTRIBUTE  -----------
DROP INDEX XAK2CONTRACTATTRIBUTE;

ALTER TABLE CONTRACTATTRIBUTE MODIFY (INTERNALNAME VARCHAR2(50));

ALTER TABLE CONTRACTATTRIBUTE DROP CONSTRAINT GROUPNUMBER_VALID;

ALTER TABLE CONTRACTATTRIBUTE ADD CONSTRAINT GROUPNUMBER_VALID1_1 CHECK (GROUPNUMBER BETWEEN 1 AND 14);

COMMENT ON COLUMN CONTRACTATTRIBUTE.GROUPNUMBER IS '1 = Miscellaneous
2 = Garments - Settings
3 = Garments – Locker Management
4 = Garments - Charges
5 = Garments – Wearer Functions
6 = Garments – Emblem Templates
7 = Invoicing
8 = Payment
9 = Residential
10 = Contract Product – Billing
11 = Contract Product – Pricing
12 = Contract Product – Logistics
13 = Contract Product – Miscellaneous
14 = Contract Product - Budget Protection';

COMMENT ON COLUMN CONTRACTATTRIBUTE.SEQUENCENUMBER IS '0 – 999
Sequence number can be used to specify the sequence within the group, so the attributes can be displayed in a logical order, and attributes that belong together are shown behind each other.
Sequence of 0 implies an attribute group name / header';

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (100, 10, 0, 'ContractProductBilling', 'Table_CONTRACTPRODUCTBILLING', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (101, 11, 0, 'ContractProductPricing', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (102, 12, 0, 'ContractProductLogistics', 'Table_CONTRACTPRODUCTORDERDELIVERY', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (103, 13, 0, 'ContractProductMiscellaneous', 'Table_CONTRACTPRODUCTMISCELLANEOUS', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (106, 14, 0, 'ContractProductBudgetProtection', 'plpcBudgetProtectionField', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (107, 10, 1, 'BillingMethod', 'cmbBillingMethod', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (108, 10, 2, 'ChangesPerWeek', 'rbChangesPerWeek', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (109, 10, 3, 'ChargeOverUse', 'cbChargeOveruse1', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (110, 10, 4, 'RentPricePerFrequency', 'cbInvoiceFrequencyRelatedRentPrice', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (111, 10, 5, 'ChargeWashesOnlyForCOG', 'cbChargeWashesOnlyCOG', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (112, 10, 6, 'InventoryBillingType', 'btnGroupInvBillingType', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (113, 10, 7, 'MinimumTurnAround', 'rbMinTurnArround', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (114, 10, 8, 'MinimumFrequency', 'cmbCalcRentEvery', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (115, 10, 9, 'ChargeLossForPool_YN', 'cbChargeLossForPool', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (116, 10, 10, 'ChargeLossUniquePoolDays', 'spAfterDays', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (117, 10, 11, 'PriceUsage', 'rbPriceUsage', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (118, 10, 12, 'ChargeRentNoReturnPoolWeeksAfterWks', 'spAfterWeeks', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (119, 10, 13, 'ChargeRentNotReturned', 'cmbChargeRentNotReturned', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (120, 10, 14, 'PercentageAfterDepreciation', 'spAfterDeprecCharge', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (121, 10, 15, 'InvoiceFreqRelatedPrice', 'cbInvoiceFrequencyRelatedRentPrice', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (122, 10, 16, 'InvWashBasedOnSoilCount', 'cbInvWashBasedOnSoil', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (123, 10, 17, 'ChargeWashesPack', 'cmbChargeWashesFor4', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (124, 10, 18, 'ReturnStockAllowed', 'cbReturnStockAllowed5', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (125, 10, 19, 'SeasonType_ID', 'cmbSeasonType', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (126, 10, 20, 'SeasonalRent', 'cmbSeasonalRent', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (127, 10, 21, 'ChargeWashInactiveSeason', 'cbChargeRentInactive', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (128, 10, 22, 'ResidualValueScheme_ID', 'cmbResidualValueScheme', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (129, 10, 23, 'SRCMethod', 'cbrbSystematicReplacement', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (130, 10, 24, 'SCRPercentageSoilCount', 'dfPercOfSoilCount', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (131, 10, 25, 'SRCPercentageInventory', 'dfPercOfCircInv', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (132, 10, 26, 'SRCPercentageBilledQty', 'dfPercOfBilledQty', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (133, 10, 27, 'SRCFrequency', 'cmbCalculateEvery', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (134, 10, 28, 'SRCChargeRent', 'cbSRCChargeRent', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (135, 10, 29, 'ShowFOCRentOnInvoice', 'cbShowFOCInv', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (136, 10, 30, 'ResetRVUponReIssue', 'cbResetRvUponReissue', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (137, 10, 31, 'DeliverReplacementQty', 'cbDeliverReplaceQty', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (138, 11, 1, 'RentPrice', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (139, 11, 2, 'WashPrice', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (140, 11, 3, 'SalesPrice', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (141, 11, 4, 'ReplacementPrice', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (142, 11, 5, 'InsurancePrice', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (143, 11, 6, 'RentDiscount', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (144, 11, 7, 'WashDiscount', '-', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (145, 12, 1, 'DelayedEvenExchange', 'rbDelayedEvenExchange', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (146, 12, 2, 'DEEDeliveryFrequency', 'cbDeeDeliveryFrequency', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (147, 12, 3, 'StraightEvenExchange', 'cbStraightEvenExchange', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (148, 12, 4, 'OrderViaWeb', 'cbOrderViaWeb', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (149, 12, 5, 'SoilCountMethod', 'cmbSoilCountMethod', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (150, 12, 6, 'CleanCount', 'cbCleanCounted', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (151, 12, 7, 'CodeUniquely', 'cbCodeUniquely', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (152, 12, 8, 'OnSiteInventoryCount', 'cbOnSiteInventoryCount', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (153, 12, 9, 'AutomaticSales', 'cbAutomaticSales', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (154, 12, 10, 'CustomerRelatedGarments', 'cbCustomerRelated', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (155, 12, 11, 'AutoReplAfterLifeTime', 'cbAutoReplAfterLifeTime', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (156, 12, 12, 'AllowReturnToStock', 'cmbAllowReturnToStock', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (157, 12, 13, 'RaggedItemAction', 'cmbRaggedItemAction', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (158, 13, 1, 'CustomCode', 'txtCode', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (159, 13, 2, 'CustomDescription', 'txtDescription', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (160, 13, 3, 'EANNumber', 'dfEANNumber', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (161, 13, 4, 'NANNumber', 'txtNANNumber', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (162, 13, 5, 'SalesEmployee_ID', 'srfSalesPerson', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (163, 13, 6, 'CommissionPayable', 'cbCommissionPayable', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (164, 13, 7, 'SalesEmployee2_ID', 'srfSalesEmployee2', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (165, 13, 8, 'ContractPurchaseOrder_ID', 'cmbPurchaseOrderNumber', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (166, 13, 9, 'ContractPurchaseOrderLine_ID', 'cmbPurchaseOrderLine', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (167, 13, 10, 'GainReason_ID', 'cmbGainReason', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (168, 13, 11, 'GainCompetitor_ID', 'cmbGainCompetitor', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (169, 13, 12, 'LostReason_ID', 'cmbLostReason', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (170, 13, 13, 'LostCompetitor_ID', 'cmbLostCompetitor', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

INSERT INTO CONTRACTATTRIBUTE
  (CONTRACTATTRIBUTE_ID, GROUPNUMBER, SEQUENCENUMBER, FACTORYNAME, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP, NOVALUERULE)
VALUES
  (171, 13, 14, 'Remark', 'txtRemark', GETMINSYSTEMUSER(), sysdate, 0);
COMMIT;

---------   CONTRACTATTRIBUTEDEPEND  -----------
CREATE TABLE CONTRACTATTRIBUTEDEPEND
(
CONTRACTATTRIBUTE_ID NUMBER NOT NULL,
INTERNALNAME VARCHAR2(30) NOT NULL,
SYSTEMUSER_ID NUMBER DEFAULT 0 NOT NULL,
TIMESTAMP DATE DEFAULT SYSDATE NOT NULL
);

ALTER TABLE CONTRACTATTRIBUTEDEPEND ADD CONSTRAINT XPKCONTRACTATTRIBUTEDEPEND PRIMARY KEY (CONTRACTATTRIBUTE_ID, INTERNALNAME);

CREATE INDEX XIF1CONTRACTATTRIBUTEDEPEND ON CONTRACTATTRIBUTEDEPEND (CONTRACTATTRIBUTE_ID ASC);

ALTER TABLE CONTRACTATTRIBUTEDEPEND ADD CONSTRAINT CONTRACTATTRIBUTEDEPEND_CID FOREIGN KEY (CONTRACTATTRIBUTE_ID)
REFERENCES CONTRACTATTRIBUTE (CONTRACTATTRIBUTE_ID) ON DELETE CASCADE;

INSERT INTO CONTRACTATTRIBUTEDEPEND
  (CONTRACTATTRIBUTE_ID, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP)
VALUES
  (108, 'cbChargeOveruse3', GETMINSYSTEMUSER(), sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTEDEPEND
  (CONTRACTATTRIBUTE_ID, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP)
VALUES
  (108, 'cbChargeOveruse1', GETMINSYSTEMUSER(), sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTEDEPEND
  (CONTRACTATTRIBUTE_ID, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP)
VALUES
  (112, 'spMinTurnArround', GETMINSYSTEMUSER(), sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTEDEPEND
  (CONTRACTATTRIBUTE_ID, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP)
VALUES
  (112, 'TxtMinTurnAround', GETMINSYSTEMUSER(), sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTEDEPEND
  (CONTRACTATTRIBUTE_ID, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP)
VALUES
  (115, 'spAfterDaysCOG4', GETMINSYSTEMUSER(), sysdate);
COMMIT;

INSERT INTO CONTRACTATTRIBUTEDEPEND
  (CONTRACTATTRIBUTE_ID, INTERNALNAME, SYSTEMUSER_ID, TIMESTAMP)
VALUES
  (115, 'spAfterDaysBM2', GETMINSYSTEMUSER(), sysdate);
COMMIT;