-- todo 9730

-- correct current data from database
-- downgrade todo 9730 to 8.02.02 and at Koert request add only the updates (not the inserts)


update customerrentprice cr
set cr.invoicefrequencynumber = 10
where cr.invoicefrequencynumber = 0
and cr.typeofrent != 8
and not exists (select 1
               from customerrentprice cr2
               where cr2.productlistpercustomer_id = cr.productlistpercustomer_id
               and cr2.startdate = cr.startdate
               and cr2.typeofrent = cr.typeofrent
               and cr2.invoicefrequencynumber = 10);

commit;


update generalrentprice gr
set gr.invoicefrequencynumber = 10
where gr.invoicefrequencynumber = 0
and gr.typeofrent != 8
and not exists (select 1
               from generalrentprice gr2
               where gr2.generalpricelist_id = gr.generalpricelist_id
               and gr2.product_id = gr.product_id
               and gr2.sizedefinition_id = gr.sizedefinition_id
               and gr2.finishingmethod_id = gr.finishingmethod_id
               and gr2.startdate = gr.startdate
               and gr2.typeofrent = gr.typeofrent
               and gr2.invoicefrequencynumber = 10);

commit;
