changeset 24b9e7b0c096 in modules/commission:default
details: 
https://hg.tryton.org/modules/commission?cmd=changeset&node=24b9e7b0c096
description:
        Deduce the commission price from the cost

        Because the commission price is negative when it has the same type as 
the
        invoice.

        issue11723
        review423891003
diffstat:

 stock_reporting_margin.py           |  2 +-
 tests/scenario_commission_stock.rst |  2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r a517ee697a57 -r 24b9e7b0c096 stock_reporting_margin.py
--- a/stock_reporting_margin.py Thu Jun 16 14:35:48 2022 +0200
+++ b/stock_reporting_margin.py Sun Sep 25 20:32:08 2022 +0200
@@ -20,7 +20,7 @@
         cost = super()._column_cost(tables, withs, sign)
         if (Transaction().context.get('include_commission')
                 and 'commission_price' in Move._fields):
-            cost += Sum(
+            cost -= Sum(
                 sign * cls.cost.sql_cast(move.internal_quantity)
                 * Coalesce(move.commission_price, 0))
         return cost
diff -r a517ee697a57 -r 24b9e7b0c096 tests/scenario_commission_stock.rst
--- a/tests/scenario_commission_stock.rst       Thu Jun 16 14:35:48 2022 +0200
+++ b/tests/scenario_commission_stock.rst       Sun Sep 25 20:32:08 2022 +0200
@@ -191,7 +191,7 @@
     >>> context['include_commission'] = True
     >>> with config.set_context(context=context):
     ...     report, = MarginProduct.find([])
-    >>> report.cost == Decimal('225.0000')
+    >>> report.cost == Decimal('275.0000')
     True
     >>> report.revenue == Decimal('500.0000')
     True

Reply via email to