Skip to content
Snippets Groups Projects
Commit b9f1006b4c00 authored by Adrien Di Mascio's avatar Adrien Di Mascio
Browse files

fix rounding bugs in accounting

parent 768d024d363f
No related branches found
No related tags found
No related merge requests found
......@@ -44,10 +44,10 @@
entity = self.complete_entity(row, col)
self.w(u' <ecriture date="%s">\n' % entity.diem.strftime('%Y-%m-%d'))
self.w(u' <libelle>%s</libelle>\n' % html_escape(entity.dc_long_title()))
amount = int(entity.euro_amount()*100) / 100.0
taxes = int(entity.taxes*100) / 100.0
amount = round(entity.euro_amount(), 2)
taxes = round(entity.taxes, 2)
self.w(u' <credit compte="%s" montant="%.2f" />\n' % (
entity.paid_by[0].account, amount))
if entity.taxes:
# XXX hardcoded account for VAT
self.w(u' <debit compte="44566" montant="%.2f" />\n' % entity.taxes)
......@@ -49,7 +49,7 @@
self.w(u' <credit compte="%s" montant="%.2f" />\n' % (
entity.paid_by[0].account, amount))
if entity.taxes:
# XXX hardcoded account for VAT
self.w(u' <debit compte="44566" montant="%.2f" />\n' % entity.taxes)
taxfree = amount - taxes
taxfree = int(round((amount - taxes) * 100))
accounts = list(entity.paid_for)
......@@ -55,6 +55,6 @@
accounts = list(entity.paid_for)
debit_quotient = int(taxfree*100) / len(accounts)
debit_remainder = int(taxfree*100) % len(accounts)
debit_quotient = taxfree / len(accounts)
debit_remainder = taxfree % len(accounts)
for account in accounts:
if debit_remainder > 0:
debit = (debit_quotient + 1) / 100.0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment