-- ABS-29431/ ABS-38898

---CLIENTCONTACTPERSON table---
ALTER TABLE CLIENTCONTACTPERSON ADD (SENDINVOICEBY NUMBER DEFAULT 0 NOT NULL
                                                   CONSTRAINT SENDINVOICEBY_VALID1_1 CHECK (SENDINVOICEBY IN (0, 1)));

COMMENT ON COLUMN CLIENTCONTACTPERSON.SENDINVOICEBY
  IS '0 = (Regular) mail
1 = Email';


---CLIENTBILLINGINFO table---
ALTER TABLE CLIENTBILLINGINFO ADD (SENDINVOICEBY NUMBER DEFAULT 0 NOT NULL
                                   CONSTRAINT SENDINVOICEBY_VALID1_2 CHECK (SENDINVOICEBY IN (0, 1)));

COMMENT ON COLUMN CLIENTBILLINGINFO.SENDINVOICEBY
  IS '0 = (Regular) mail
1 = Email';

---EMAILSETTING table---
ALTER TABLE EMAILSETTING
  DROP CONSTRAINT DOCUMENTTYPEEMAILSETT_VALID;
ALTER TABLE EMAILSETTING
  ADD CONSTRAINT DOCUMENTTYPEEMAILSETT_VALID
  CHECK (DOCUMENTTYPE BETWEEN 1 AND 24);

COMMENT ON COLUMN EMAILSETTING.DOCUMENTTYPE
  IS '1 = Invoice 2 = Statement 3 = Purchase order 4 = E-service password reminder 5 = Work order via web 6 = Invoice job checklist 7 = Customer 8 = Log Message 9 = Delivery Note / Consignment Note 10 = Stock Count / Order 11 = Wash List 12 = POD (Proof of delivery) 13 = On site soil scan list 14 = Shipment List 15 = Commission Report 16 = Wearer Web Login Credentials 17 = Recalculation Norm Stock Levels 18 = Recalculation Standard Deliveries 19 = Incidental Inventory 20 = Container Usage Report 21 = (Succesfully) Processed OR Packs 22 = Unattended UHF Reader Status Changed 23 = Future planned deliveries 24 = Client Invoice';

---CUSTOMERRESIDENTIALSETTINGS table---
ALTER TABLE CUSTOMERRESIDENTIALSETTINGS ADD (ALLOWCLIENTINVOICEEMAILING VARCHAR2(1) DEFAULT 'N' NOT NULL
                                             CONSTRAINT YN_VALIDATIONFIELD319 CHECK (ALLOWCLIENTINVOICEEMAILING IN ('Y', 'N')));

---PROCESS table---
insert into process(process_id,description,active) values ('138','Send Client Invoices by Email','Y');
commit;