Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Purchase order calculation comparing storage box vendors
from dataclasses import dataclass
@dataclass
class Vendor:
pass
"""
mini45=None
midi45=None
maxi45=None
mini56=None
midi56=None
maxi56=None
mini75=None
midi75=None
maxi75=None
"""
class WhitefurzeSpecial(Vendor):
vat=0.2
midi45=2.48
mini56=2.65
midi56=2.88
maxi56=4.13
mini75=4.13
maxi75=5.90
class WhitefurzeNormal(Vendor):
vat=0.2
stack18=1.76
midi45=3.14
mini56=3.62
midi56=4.10
maxi56=5.25
mini75=5.17
maxi75=7.63
class Mahahome(Vendor):
vat=0
midi45=4.09
mini56=5.74
maxi56=6.81
mini75=10.51
maxi75=12.69
purchase = (
("stack18", 5),
("midi45", 20),
("mini56", 20),
("midi56", 20),
("maxi75", 10),
)
def report():
for vendor in [WhitefurzeNormal()]:
print(f"{type(vendor).__name__}")
totalNet = 0
totalVat = 0
vatFactor = (1.0 + v.vat)
for item, count in purchase:
price = getattr(vendor, item) * count
vat = price * vendor.vat
price = price * 100 // 1 / 100
totalNet += price
totalVat += vat
print(f"{item}x{count}={ price }")
print(f"Net: £{totalNet}")
print(f"Vat: £{totalVat}")
print(f"Total: £{totalNet + totalVat}")
report()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.