changeset 943412699dfe in modules/account_move_line_grouping:default
details: 
https://hg.tryton.org/modules/account_move_line_grouping?cmd=changeset&node=943412699dfe
description:
        Add delegated amount on lines to pay

        issue10345
        review346191002
diffstat:

 CHANGELOG                                     |   1 +
 account.py                                    |  16 +++++++++++++++-
 tests/scenario_account_move_line_grouping.rst |   5 ++++-
 view/move_line_group_form.xml                 |   2 ++
 4 files changed, 22 insertions(+), 2 deletions(-)

diffs (87 lines):

diff -r 48a4abb19462 -r 943412699dfe CHANGELOG
--- a/CHANGELOG Sun Apr 10 19:11:37 2022 +0200
+++ b/CHANGELOG Mon Apr 11 19:19:54 2022 +0200
@@ -1,3 +1,4 @@
+* Add delegated amount on move lines
 * Add support for Python 3.10
 * Remove support for Python 3.6
 
diff -r 48a4abb19462 -r 943412699dfe account.py
--- a/account.py        Sun Apr 10 19:11:37 2022 +0200
+++ b/account.py        Mon Apr 11 19:19:54 2022 +0200
@@ -1,7 +1,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 from sql import Literal, Null, Select, Window
-from sql.aggregate import BoolAnd, Min, Sum
+from sql.aggregate import BoolAnd, BoolOr, Min, Sum
 from sql.functions import CurrentTimestamp, FirstValue
 
 from trytond.model import ModelSQL, ModelView, fields
@@ -47,7 +47,16 @@
         'get_amount')
     amount_currency = fields.Function(fields.Many2One(
             'currency.currency', "Amount Currency"), 'get_amount_currency')
+    delegated_amount = fields.Function(Monetary(
+            "Delegated Amount",
+            currency='amount_currency', digits='amount_currency',
+            states={
+                'invisible': ~Eval('partially_reconciled', False),
+                }),
+        'get_delegated_amount')
 
+    partially_reconciled = fields.Boolean(
+        "Partially Reconciled", readonly=True)
     reconciled = fields.Boolean("Reconciled", readonly=True)
     amount_reconciled = Monetary(
         "Amount Reconciled",
@@ -136,6 +145,7 @@
             Sum(line.debit).as_('debit'),
             Sum(line.credit).as_('credit'),
             Sum(line.amount_second_currency).as_('amount_second_currency'),
+            BoolOr(line.reconciliation != Null).as_('partially_reconciled'),
             BoolAnd(line.reconciliation != Null).as_('reconciled'),
             Sum(
                 line.debit + line.credit,
@@ -153,6 +163,10 @@
         if self.account:
             return self.account.currency.id
 
+    def get_delegated_amount(self, name):
+        return self.amount_currency.round(
+            sum(l.delegated_amount for l in self.lines if l.delegated_amount))
+
 
 class MoveLineGroup_MoveLine(ModelSQL):
     "Account Move Line Group - Move Line"
diff -r 48a4abb19462 -r 943412699dfe 
tests/scenario_account_move_line_grouping.rst
--- a/tests/scenario_account_move_line_grouping.rst     Sun Apr 10 19:11:37 
2022 +0200
+++ b/tests/scenario_account_move_line_grouping.rst     Mon Apr 11 19:19:54 
2022 +0200
@@ -109,6 +109,10 @@
     ...         ])
     >>> line.amount_reconciled == Decimal(22)
     True
+    >>> line.partially_reconciled
+    True
+    >>> line.delegated_amount
+    Decimal('0.00')
     >>> if backend.name != 'sqlite':
     ...     len(line.lines)
     ... else:
@@ -125,4 +129,3 @@
     ... else:
     ...     1
     1
-
diff -r 48a4abb19462 -r 943412699dfe view/move_line_group_form.xml
--- a/view/move_line_group_form.xml     Sun Apr 10 19:11:37 2022 +0200
+++ b/view/move_line_group_form.xml     Mon Apr 11 19:19:54 2022 +0200
@@ -40,6 +40,8 @@
             <label name="amount_reconciled"/>
             <field name="amount_reconciled"/>
 
+            <label name="delegated_amount"/>
+            <field name="delegated_amount"/>
             <label name="amount_second_currency"/>
             <field name="amount_second_currency"/>
         </page>

Reply via email to