changeset 8e183287aa93 in modules/analytic_account:default
details: 
https://hg.tryton.org/modules/analytic_account?cmd=changeset;node=8e183287aa93
description:
        Ignore balance of non-deferral move

        issue9460
        review294111002
diffstat:

 CHANGELOG                           |   1 +
 line.py                             |   8 +++++-
 tests/scenario_analytic_account.rst |  44 +++++++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 1 deletions(-)

diffs (78 lines):

diff -r 24414e3f2ef6 -r 8e183287aa93 CHANGELOG
--- a/CHANGELOG Thu Jul 09 10:21:06 2020 +0100
+++ b/CHANGELOG Sat Jul 25 12:31:10 2020 +0200
@@ -1,3 +1,4 @@
+* Ignore balance of non-deferral move
 * Add a button to manually reapply rule engine
 
 Version 5.6.0 - 2020-05-04
diff -r 24414e3f2ef6 -r 8e183287aa93 line.py
--- a/line.py   Thu Jul 09 10:21:06 2020 +0100
+++ b/line.py   Sat Jul 25 12:31:10 2020 +0200
@@ -218,8 +218,14 @@
     @property
     def must_have_analytic(self):
         "If the line must have analytic lines set"
+        pool = Pool()
+        FiscalYear = pool.get('account.fiscalyear')
         if self.account.type:
-            return self.account.type.statement == 'income'
+            return self.account.type.statement == 'income' and not (
+                # ignore balance move of non-deferral account
+                self.journal.type == 'situation'
+                and self.period.type == 'adjustment'
+                and isinstance(self.move.origin, FiscalYear))
 
     @classmethod
     def apply_rule(cls, lines):
diff -r 24414e3f2ef6 -r 8e183287aa93 tests/scenario_analytic_account.rst
--- a/tests/scenario_analytic_account.rst       Thu Jul 09 10:21:06 2020 +0100
+++ b/tests/scenario_analytic_account.rst       Sat Jul 25 12:31:10 2020 +0200
@@ -140,3 +140,47 @@
     Decimal('73')
     >>> analytic_line.date == analytic_line.move_line.date
     True
+
+Prepare to balance non-deferral accounts::
+
+    >>> Sequence = Model.get('ir.sequence')
+    >>> Period = Model.get('account.period')
+    >>> AccountType = Model.get('account.account.type')
+    >>> Account = Model.get('account.account')
+    >>> journal_sequence, = Sequence.find([('code', '=', 'account.journal')])
+    >>> journal_closing = Journal()
+    >>> journal_closing.code = 'CLO'
+    >>> journal_closing.type = 'situation'
+    >>> journal_closing.name = "Closing"
+    >>> journal_closing.sequence = journal_sequence
+    >>> journal_closing.save()
+    >>> period_closing = Period()
+    >>> period_closing.name = "Closing"
+    >>> period_closing.type = 'adjustment'
+    >>> period_closing.fiscalyear = fiscalyear
+    >>> period_closing.start_date = fiscalyear.end_date
+    >>> period_closing.end_date = fiscalyear.end_date
+    >>> period_closing.save()
+    >>> equity, = AccountType.find([('name', '=', 'Equity')])
+    >>> account_pl = Account()
+    >>> account_pl.name = 'P&L'
+    >>> account_pl.type = equity
+    >>> account_pl.parent = revenue.parent
+    >>> account_pl.save()
+
+Balance non-deferral accounts::
+
+    >>> balance_non_deferral = 
Wizard('account.fiscalyear.balance_non_deferral')
+    >>> balance_non_deferral.form.fiscalyear = fiscalyear
+    >>> balance_non_deferral.form.journal = journal_closing
+    >>> balance_non_deferral.form.period = period_closing
+    >>> balance_non_deferral.form.credit_account = account_pl
+    >>> balance_non_deferral.form.debit_account = account_pl
+    >>> balance_non_deferral.execute('balance')
+    >>> move, = Move.find([
+    ...     ('state', '=', 'draft'),
+    ...     ('journal', '=', journal_closing.id),
+    ...     ])
+    >>> move.click('post')
+    >>> [l for l in move.lines if l.analytic_lines]
+    []

Reply via email to