sql 获得(净金额)PO折扣金额的公式

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 获得(净金额)PO折扣金额的公式相关的知识,希望对你有一定的参考价值。

pur_pkg.calc_net_amount(nvl(:pur_purchase_order_dtl.amount, 0),                                          
                                        case :pur_purchase_order_dtl.discount_calc_type 
                                        when 1 then
                                            nvl(:pur_purchase_order_dtl.item_discount_amount, 0)
                                        else
                                            nvl(:pur_purchase_order_dtl.discount_amount, 0)  -- direct
                                        end, 
                        nvl(:pur_purchase_order_dtl.item_po_discount_amount, 0))




--item_discount_amount
pur_pkg.calc_discount_amount(nvl(:pur_purchase_order_dtl.amount, 0), 
                             nvl(:pur_purchase_order_dtl.discount_percent, 0 ), 
                             nvl(:pur_purchase_order_dtl.discount_percent2, 0), 
                             nvl(:pur_purchase_order_dtl.discount_percent3,0))
                             
                             
--amount
:pur_purchase_order_dtl.qty * :pur_purchase_order_dtl.price
                             



--item_po_discount_amount
pur_pkg.calc_discount_amount_by_type(nvl(:pur_purchase_order_dtl.amount, 0), --t
                                     case :pur_purchase_order_dtl.discount_calc_type -- direct 
                                        when 1 then
                                            nvl(:pur_purchase_order_dtl.item_discount_amount, 0)
                                        else
                                            nvl(:pur_purchase_order_dtl.discount_amount, 0) --direct
                                        end, 
                                     :pur_purchase_orders.discount_calc_type,  --direct
                                     nvl(:pur_purchase_orders.discount_percent, 0), --direct
                                     nvl(:pur_purchase_orders.discount_amount, 0),  --direct
                                     nvl(:pur_purchase_order_dtl.amount_sum, 0))
                                     
                                     
--amount_sum
select sum(amount) from   pur_purchase_order_dtl
function CF_net_amtFormula return Number is
v_amount									number;
v_amount_sum							number;
v_item_discount_amount		number;
v_item_po_discount_amount	number;
v_net_amt									number;
begin

--amount
	v_amount:= :qty * :price;

--item_discount_amount
	v_item_discount_amount := pur_pkg.calc_discount_amount(nvl(v_amount, 0), 
	                             nvl(:discount_percent, 0 ), 
	                             nvl(:discount_percent2, 0), 
	                             nvl(:discount_percent3,0));
                            
 
 --amount_sum
 v_amount_sum := :sum_amount;



--item_po_discount_amount
	v_item_po_discount_amount := pur_pkg.calc_discount_amount_by_type(nvl(v_amount, 0), 
                                     case :discount_calc_type -- direct
                                        when 1 then
                                            nvl(v_item_discount_amount, 0)
                                        else
                                            nvl(:discount_amount, 0) --direct
                                        end, 
                                     :po_discount_calc_type,  --direct
                                     nvl(:po_discount_percent, 0), --direct
                                     nvl(:po_discount_amount, 0),  --direct
                                     nvl(v_amount_sum, 0));
                                     
--net_amt

	v_net_amt	 := pur_pkg.calc_net_amount(nvl(v_amount, 0),                                          
                                        case :discount_calc_type 
                                        when 1 then
                                            nvl(v_item_discount_amount, 0)
                                        else
                                            nvl(:discount_amount, 0)  -- direct
                                        end, 
                        nvl(v_item_po_discount_amount, 0));
    return v_net_amt;                                                                

end;                                     

以上是关于sql 获得(净金额)PO折扣金额的公式的主要内容,如果未能解决你的问题,请参考以下文章

获取具有不同类型和名称的特定ID mysql的总和

基金认购份额

授权净ARB增加认购金额

SQL 怎么按时间汇总累计金额

Magento:整个购物车的固定金额折扣百分比?

Paypal 自适应支付 IPN 费用信息