Skip to content

Commit

Permalink
Merge pull request #109 from akretion/10-fix-rounding-debit-credit
Browse files Browse the repository at this point in the history
[10.0] FIX bug rounding debit/credit
  • Loading branch information
alexis-via committed Apr 30, 2019
2 parents 4b29c8f + 5c04dba commit 41751d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions account_cutoff_accrual_dates/models/account_cutoff.py
Expand Up @@ -43,6 +43,7 @@ def _prepare_accrual_date_lines(self, aml, mapping):
'Should never happen. Total days should always be > 0'
cutoff_amount = (aml.credit - aml.debit) *\
prepaid_days / float(total_days)
cutoff_amount = self.company_currency_id.round(cutoff_amount)
# we use account mapping here
if aml.account_id.id in mapping:
cutoff_account_id = mapping[aml.account_id.id]
Expand Down Expand Up @@ -90,13 +91,14 @@ def _prepare_accrual_date_lines(self, aml, mapping):
raise UserError(_(
"Missing 'Accrued Revenue Tax Account' "
"on tax '%s'") % tax.display_name)
tamount = self.company_currency_id.round(tax_line['amount'])
res['tax_line_ids'].append((0, 0, {
'tax_id': tax_line['id'],
'base': cutoff_amount,
'amount': tax_line['amount'],
'amount': tamount,
'sequence': tax_line['sequence'],
'cutoff_account_id': tax_account.id,
'cutoff_amount': tax_line['amount'],
'cutoff_amount': tamount,
}))
return res

Expand Down
4 changes: 3 additions & 1 deletion account_cutoff_base/models/account_cutoff.py
Expand Up @@ -140,6 +140,7 @@ def _prepare_move(self, to_provision):
move_label = self.move_label
merge_keys = self._get_merge_keys()
for merge_values, amount in to_provision.items():
amount = self.company_currency_id.round(amount)
vals = {
'name': move_label,
'debit': amount < 0 and amount * -1 or 0,
Expand All @@ -151,7 +152,8 @@ def _prepare_move(self, to_provision):
amount_total += amount

# add counter-part
counterpart_amount = amount_total * -1
counterpart_amount = self.company_currency_id.round(
amount_total * -1)
movelines_to_create.append((0, 0, {
'account_id': self.cutoff_account_id.id,
'name': move_label,
Expand Down
1 change: 1 addition & 0 deletions account_cutoff_prepaid/models/account_cutoff.py
Expand Up @@ -88,6 +88,7 @@ def _prepare_prepaid_lines(self, aml, mapping):
'Should never happen. Total days should always be > 0'
cutoff_amount = (aml.debit - aml.credit) *\
prepaid_days / float(total_days)
cutoff_amount = self.company_currency_id.round(cutoff_amount)
# we use account mapping here
if aml.account_id.id in mapping:
cutoff_account_id = mapping[aml.account_id.id]
Expand Down

0 comments on commit 41751d0

Please sign in to comment.