--- ABS-11214
----------------------------------   INVOICELINESUBTYPE   ------------------------------------
update invoicelinesubtype i
set i.factorydescription = 'Rent Not Returned items'
where i.subtype = 44;
commit;

----------------------------------   PRODUCTLISTPERCUSTOMER   --------------------------------
ALTER TABLE PRODUCTLISTPERCUSTOMER ADD(CHARGERENTNOTRETURNED NUMBER DEFAULT 0 NOT NULL
					CONSTRAINT CHARGERENTNOTRETURNED_VALID1_1 CHECK (CHARGERENTNOTRETURNED BETWEEN 0 AND 2));

COMMENT ON COLUMN PRODUCTLISTPERCUSTOMER.CHARGERENTNOTRETURNED IS 'Used in combination with BM3 and InventoryBillingType = 4
0 = Charge Rent for not returned Pool
1 = Charge Rent for not returned Garments (non-pool)
2 = Charge Rent for not returned Pool and Garments';


COMMENT ON COLUMN PRODUCTLISTPERCUSTOMER.INVENTORYBILLINGTYPE IS 'For billingmethod 3: 
0 - circulating inventory 
1 - real quantity 
2 - max inventory qty 
3 - on-site inventory qty 
4 - Non-returned items after n weeks';

----------------------------------   PRODUCTGROUP   ------------------------------------------
ALTER TABLE PRODUCTGROUP ADD(RENTNOTRETTURNOVERGROUP_ID NUMBER NULL);

CREATE INDEX XIF1PRODUCTGROUP ON PRODUCTGROUP(RENTNOTRETTURNOVERGROUP_ID ASC);

ALTER TABLE PRODUCTGROUP ADD CONSTRAINT PRODUCTGROUP_RENTNOTRET FOREIGN KEY (RENTNOTRETTURNOVERGROUP_ID)
REFERENCES TURNOVERGROUP(TURNOVERGROUP_ID);

update productgroup pg
set pg.rentnotretturnovergroup_id = pg.rentturnovergroup_id;
commit;


----------------------------------   PRODUCT   ------------------------------------------------
ALTER TABLE PRODUCT ADD(RENTNOTRETTURNOVERGROUP_ID NUMBER NULL);

CREATE INDEX XIF1PRODUCT ON PRODUCT(RENTNOTRETTURNOVERGROUP_ID ASC);

ALTER TABLE PRODUCT ADD CONSTRAINT PRODUCT_RENTNOTRET FOREIGN KEY (RENTNOTRETTURNOVERGROUP_ID)
REFERENCES TURNOVERGROUP(TURNOVERGROUP_ID);

update product p
set p.rentnotretturnovergroup_id = p.rentturnovergroup_id;
commit;

