fix w kalkulacji last price
This commit is contained in:
@@ -34,3 +34,25 @@ def calculate_net_price_costs(net_price, vat_rate=23, vat_deduction_percent=50):
|
||||
"deductible_vat": deductible_vat,
|
||||
"effective_cost": effective_cost,
|
||||
}
|
||||
|
||||
|
||||
def calculate_net_price_comparison(retail_gross_price, settlement_net_price, liters=1, vat_rate=23):
|
||||
"""Compare retail and settlement prices on a net-to-net basis.
|
||||
|
||||
Retail price is supplied gross (pump price), while settlement/Last Price is net.
|
||||
VAT is excluded from the saving because recoverable tax is not a commercial saving.
|
||||
"""
|
||||
retail_gross = Decimal(str(retail_gross_price))
|
||||
settlement_net = Decimal(str(settlement_net_price))
|
||||
quantity = Decimal(str(liters))
|
||||
rate = Decimal(str(vat_rate)) / Decimal("100")
|
||||
retail_net = retail_gross / (Decimal("1") + rate)
|
||||
saving_per_liter = max(retail_net - settlement_net, Decimal("0"))
|
||||
return {
|
||||
"retail_net_price": retail_net,
|
||||
"settlement_net_price": settlement_net,
|
||||
"saving_net_per_liter": saving_per_liter,
|
||||
"retail_net_total": retail_net * quantity,
|
||||
"settlement_net_total": settlement_net * quantity,
|
||||
"saving_net_total": saving_per_liter * quantity,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user