-- ABS-85330 / ABS-88890
--- CUSTOMERCREDITCARD ---
ALTER TABLE CUSTOMERCREDITCARD RENAME COLUMN CARDNUMBER TO MASKEDCARDNUMBER;

ALTER TABLE CUSTOMERCREDITCARD DROP COLUMN CARDEXPIRYDATE;

ALTER TABLE CUSTOMERCREDITCARD ADD (CARDEXPIRYMONTH NUMBER NULL,
				    CARDEXPIRYYEAR NUMBER NULL);

--- ARTRANSACTION ---
ALTER TABLE ARTRANSACTION DROP CONSTRAINT CHK_ARTRANSACTION_ORIGIN;

COMMENT ON COLUMN ARTRANSACTION.ORIGIN IS 'This field is only used internally for trouble shooting. It identifies where the ARTransaction is created.
0 = Undefined
1 = Finalize invoices
2 = Consolidated invoices
3 = Settlement
4 = Generate statement
5 = Cash application - Manual added
6 = Cash application - Generated (apply)
7 = DB Procedure ProcessPaymentTransaction
8 = DB Procedure ProcessUnappliedCredit
9 = Credit card transactions - cancel / refund
10 = Process credit card transactions
11 = Credit Card Portal
12 = Customer Financials - Credit card on demand
13 = Web Portal Credit Card payment
14 = Scheduled Credit Card Payment
15 = Card Test transaction';

ALTER TABLE ARTRANSACTION ADD CONSTRAINT CHK_ARTRANSACTION_ORIGIN CHECK (ORIGIN BETWEEN 0 AND 15);

--- CREDITCARDTRANSACTION ---
ALTER TABLE CREDITCARDTRANSACTION DROP CONSTRAINT CHK_CREDITCARDTRANS_ORIGIN;

COMMENT ON COLUMN CREDITCARDTRANSACTION.ORIGIN IS '1 = Remittance (manual via Cash application)
2 = Refund
3 = Miscellaneous
4 = Generated via Statement
5 = Generated via Settlement
6 = Credit Card on Demand
7 = Web Portal Credit Card Payment
8 = Scheduled credit card payment
9 = Card Test Transaction';

ALTER TABLE CREDITCARDTRANSACTION ADD CONSTRAINT CHK_CREDITCARDTRANS_ORIGIN CHECK (ORIGIN BETWEEN 1 AND 9);

ALTER TABLE CREDITCARDTRANSACTION MODIFY (TXREFNUM VARCHAR2(100));
ALTER TABLE CREDITCARDTRANSACTION ADD (BILLTOCUSTOMER_LINK_ID NUMBER NULL);

CREATE INDEX XIF5CREDITCARDTRANSACTION ON CREDITCARDTRANSACTION (BILLTOCUSTOMER_LINK_ID ASC);

ALTER TABLE CREDITCARDTRANSACTION ADD CONSTRAINT FK_CREDITCARDTRANS_BILLTO FOREIGN KEY (BILLTOCUSTOMER_LINK_ID)
REFERENCES CUSTOMER_LINK (CUSTOMER_LINK_ID);

--- REMITBATCH ---
ALTER TABLE REMITBATCH DROP CONSTRAINT PAYMENTTYPE_VALID;

COMMENT ON COLUMN REMITBATCH.PAYMENTTYPE IS '0 = Cash
1 = Check
2 = Credit card
3 = EFT
4 = EDI
5 = Acceptgiro
6 = Automatic collection
7 = Pay-by customer
8 = Credit Card Portal
9 = Not applicable
10 = Credit Card Web Portal
11 = Scheduled Credit Card Payment';

ALTER TABLE REMITBATCH ADD CONSTRAINT CHK_REMITBATCH_PAYMENT CHECK ((PAYMENTTYPE BETWEEN 0 AND 11) OR (PAYMENTTYPE IS NULL));