--Update statements for net and tax values for ccm resources and revenue forecast

--function space
update yebs
set yebs_price_net = yebs_specialrate - evaluatevat(yebs_zdco_id, trunc(yebs_starttime), yebs_specialrate),
    yebs_price_vat = evaluatevat(yebs_zdco_id, trunc(yebs_starttime), yebs_specialrate)
where nvl(yebs_zdco_id, 0) <> 0 and nvl(yebs_specialrate, 0) > 0 and nvl(yebs_price_net, 0) = 0;

--catering items
update yebr
set yebr_price_net = yebr_manualprice - evaluatevat(yebr_zdco_id, trunc(yebr_starttime), yebr_manualprice),
    yebr_price_vat = evaluatevat(yebr_zdco_id, trunc(yebr_starttime), yebr_manualprice)
where nvl(yebr_zdco_id, 0) <> 0 and nvl(yebr_manualprice, 0) >0 and nvl(yebr_price_net, 0) = 0; 

--standard menu split
update ymrd
set ymrd_price_net = ymrd_yfca_amount - evaluatevat(ymrd_zdco_id, sysdate, ymrd_yfca_amount), 
    ymrd_price_vat = evaluatevat(ymrd_zdco_id, sysdate, ymrd_yfca_amount)
where nvl(ymrd_zdco_id, 0) <> 0 and nvl(ymrd_yfca_amount, 0) >0 and nvl(ymrd_price_net, 0) = 0; 

--menu items
update yemi
set yemi_price_net = yemi_price - evaluatevat(yemi_zdco_id, sysdate, yemi_price),
    yemi_price_vat = evaluatevat(yemi_zdco_id, sysdate, yemi_price)
where nvl(yemi_zdco_id, 0) >0 and nvl(yemi_price, 0) >0 and nvl(yemi_price_net, 0) = 0;    

--forecast revenue table
update ybef
set ybef_price_net = ybef_rev_amount - evaluatevat(ybef_zdco_id, sysdate, ybef_rev_amount),
    ybef_price_vat = evaluatevat(ybef_zdco_id, sysdate, ybef_rev_amount)
where nvl(ybef_zdco_id, 0) > 0 and nvl(ybef_rev_amount, 0) >0 and nvl(ybef_price_net, 0) = 0;
