changeset 052fe6ec6d32 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=052fe6ec6d32
description:
        Reconcile only balanced deposit

        issue9151
        review301111002
diffstat:

 move.py |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (43 lines):

diff -r c08395de57a4 -r 052fe6ec6d32 move.py
--- a/move.py   Sat Mar 28 14:17:49 2020 +0100
+++ b/move.py   Sat Mar 28 16:54:08 2020 +0100
@@ -1606,7 +1606,7 @@
                     )))
         return [a for a, in cursor.fetchall()]
 
-    def get_parties(self, account):
+    def get_parties(self, account, _balanced=False):
         'Return a list party to reconcile for the account'
         pool = Pool()
         Line = pool.get('account.move.line')
@@ -1620,18 +1620,22 @@
             return list({l.party for l in lines if l.account == account})
 
         balance = line.debit - line.credit
+        if _balanced:
+            having = Sum(balance) == 0
+        else:
+            having = ((
+                    Sum(Case((balance > 0, 1), else_=0)) > 0)
+                & (Sum(Case((balance < 0, 1), else_=0)) > 0)
+                | Case((account.type.receivable, Sum(balance) < 0),
+                    else_=False)
+                | Case((account.type.payable, Sum(balance) > 0),
+                    else_=False)
+                )
         cursor.execute(*line.select(line.party,
                 where=(line.reconciliation == Null)
                 & (line.account == account.id),
                 group_by=line.party,
-                having=((
-                        Sum(Case((balance > 0, 1), else_=0)) > 0)
-                    & (Sum(Case((balance < 0, 1), else_=0)) > 0)
-                    | Case((account.type.receivable, Sum(balance) < 0),
-                        else_=False)
-                    | Case((account.type.payable, Sum(balance) > 0),
-                        else_=False)
-                    )))
+                having=having))
         return [p for p, in cursor.fetchall()]
 
     def transition_next_(self):

Reply via email to