summaryrefslogtreecommitdiff
path: root/fracture
diff options
context:
space:
mode:
Diffstat (limited to 'fracture')
-rw-r--r--fracture/invoice.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/fracture/invoice.py b/fracture/invoice.py
index 0ccfec2..a27d50a 100644
--- a/fracture/invoice.py
+++ b/fracture/invoice.py
@@ -31,32 +31,33 @@ class Product:
price_unit=0.0, vat = 0.21):
if len(description) == 0:
raise ValueError("Product: No description provided")
+
self.description = description
- self.units = units
- self.price_unit = price_unit
+ self.units = Conf.round(units)
+ self.price_unit = Conf.round(price_unit)
if vat in self.VATS:
self.vat = vat
else:
raise ValueError("Product: No valid VAT. Valid are:"+\
str(Product.VATS))
@property
- def total(self):
- return self.base+self.charged_vat
- @property
def base(self):
- return self.price_unit * self.units
+ return Conf.round(self.price_unit * self.units)
+ @property
+ def total(self):
+ return Conf.round(self.base+self.charged_vat)
@property
def charged_vat(self):
- return self.base * self.vat
+ return Conf.round(self.base * self.vat)
def to_dict(self):
return {
"description": self.description,
"units": self.units,
- "price-unit": Conf.round(self.price_unit),
+ "price-unit": self.price_unit,
"vat": self.vat,
- "vat-charged": Conf.round(self.charged_vat),
- "base": Conf.round(self.base),
- "total": Conf.round(self.total)
+ "vat-charged": self.charged_vat,
+ "base": self.base,
+ "total": self.total
}
class Customer:
@@ -373,8 +374,8 @@ class Invoice:
ps = tuple(ps)
res += ({
"vat": vat,
- "base": Conf.round(sum(p.base for p in ps)),
- "charged": Conf.round(sum(p.charged_vat for p in ps)),
+ "base": sum(p.base for p in ps),
+ "charged": sum(p.charged_vat for p in ps),
},)
return res
@@ -420,8 +421,8 @@ class Invoice:
for vat, ps in vs:
ps = tuple(ps)
- row[to_base_key(vat)] = Conf.round(sum(p.base for p in ps))
- row[to_vat_key(vat)] = Conf.round(sum(p.charged_vat for p in ps))
+ row[to_base_key(vat)] = sum(p.base for p in ps)
+ row[to_vat_key(vat)] = sum(p.charged_vat for p in ps)
to_tax_key = lambda tax: tax.name + "("+ str(tax.ratio*100) +"%)"