Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with float_is_zero #32

Merged
merged 2 commits into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mis_builder/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ Changelog for mis_builder
.. *


10.0.3.0.x (unreleased)
~~~~~~~~~~~~~~~~~~~~~~~

Bug fix:

* [FIX] issue with initial balance rounding.
`#30 <https://github.com/OCA/mis-builder/issues/30>`_

10.0.3.0.3 (2017-10-03)
~~~~~~~~~~~~~~~~~~~~~~~

Bug fix:

* [FIX] fix error saving KPI on newly created reports
(https://github.com/OCA/mis-builder/issues/18)
* [FIX] fix error saving KPI on newly created reports.
`#18 <https://github.com/OCA/mis-builder/issues/18>`_

10.0.3.0.2 (2017-10-01)
~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions mis_builder/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Contributors
* Martronic SA <info@martronic.ch>
* nicomacr <nmr@adhoc.com.ar>
* Juan Jose Scarafia <jjs@adhoc.com.ar>
* Richard deMeester <richard@willowit.com.au>

Maintainer
----------
Expand Down
6 changes: 3 additions & 3 deletions mis_builder/models/aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def do_queries(self, date_from, date_to,
credit = acc['credit'] or 0.0
if mode in (self.MODE_INITIAL, self.MODE_UNALLOCATED) and \
float_is_zero(debit-credit,
precision_rounding=self.dp):
precision_digits=self.dp):
# in initial mode, ignore accounts with 0 balance
continue
self._data[key][acc['account_id'][0]] = (debit, credit)
Expand Down Expand Up @@ -332,7 +332,7 @@ def f(mo):
# as it does not make sense to distinguish 0 from "no data"
if v is not AccountingNone and \
mode in (self.MODE_INITIAL, self.MODE_UNALLOCATED) and \
float_is_zero(v, precision_rounding=self.dp):
float_is_zero(v, precision_digits=self.dp):
v = AccountingNone
return '(' + repr(v) + ')'

Expand Down Expand Up @@ -373,7 +373,7 @@ def f(mo):
# as it does not make sense to distinguish 0 from "no data"
if v is not AccountingNone and \
mode in (self.MODE_INITIAL, self.MODE_UNALLOCATED) and \
float_is_zero(v, precision_rounding=self.dp):
float_is_zero(v, precision_digits=self.dp):
v = AccountingNone
return '(' + repr(v) + ')'

Expand Down
29 changes: 29 additions & 0 deletions mis_builder/tests/test_aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,35 @@ def test_aep_convenience_methods(self):
'posted')
self.assertEquals(unallocated, (0, 100))

def test_float_is_zero(self):
dp = self.company.currency_id.decimal_places
self.assertEqual(dp, 2)
# make initial balance at Jan 1st equal to 0.01
self._create_move(
date=datetime.date(self.prev_year, 12, 1),
amount=100.01,
debit_acc=self.account_in,
credit_acc=self.account_ar)
initial = AEP.get_balances_initial(
self.company,
time.strftime('%Y') + '-01-01',
'posted')
self.assertEquals(initial, {
self.account_ar.id: (100.00, 100.01),
})
# make initial balance at Jan 1st equal to 0.001
self._create_move(
date=datetime.date(self.prev_year, 12, 1),
amount=0.009,
debit_acc=self.account_ar,
credit_acc=self.account_in)
initial = AEP.get_balances_initial(
self.company,
time.strftime('%Y') + '-01-01',
'posted')
# epsilon initial balances is reported as empty
self.assertEquals(initial, {})

def test_get_account_ids_for_expr(self):
expr = 'balp[700IN]'
account_ids = self.aep.get_account_ids_for_expr(expr)
Expand Down