Files
fuel_track/app/domain/costs.py
T
Mateusz Gruszczyński bd562b3da6 first commit
2026-07-13 13:19:26 +02:00

15 lines
629 B
Python

from decimal import Decimal, ROUND_HALF_UP
def money(value):
return Decimal(str(value)).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
def calculate_costs(gross, vat_rate=23, vat_deduction_percent=50):
gross = Decimal(str(gross)); rate = Decimal(str(vat_rate))
deduction = Decimal(str(vat_deduction_percent)) / Decimal("100")
net = gross / (Decimal("1") + rate / Decimal("100")); vat = gross - net
deductible_vat = vat * deduction
return {"gross": money(gross), "net": money(net), "vat": money(vat),
"deductible_vat": money(deductible_vat), "final_cost": money(gross - deductible_vat)}