# HG changeset patch # User Adrien Di Mascio <Adrien.DiMascio@logilab.fr> # Date 1235731018 -3600 # Fri Feb 27 11:36:58 2009 +0100 # Node ID b9f1006b4c00e0a531c604894a95ce43186c9501 # Parent 768d024d363f1adc5b4959072b16397ff3a3336f fix rounding bugs in accounting diff --git a/views/accounting.py b/views/accounting.py --- a/views/accounting.py +++ b/views/accounting.py @@ -44,17 +44,17 @@ 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) - taxfree = amount - taxes + taxfree = int(round((amount - taxes) * 100)) 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