line: negate amount if splitline=spout - tests
This commit is contained in:
parent
d820fc7109
commit
71cdadb8ad
2 changed files with 62 additions and 26 deletions
12
line.py
12
line.py
|
@ -4,7 +4,7 @@
|
|||
# full copyright notices and license terms.
|
||||
|
||||
from decimal import Decimal
|
||||
from sql.conditionals import Coalesce
|
||||
from sql.conditionals import Coalesce, Case
|
||||
from sql.aggregate import Sum
|
||||
from trytond.model import fields
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
|
@ -212,13 +212,19 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
|
|||
Sum(Coalesce(
|
||||
tab_inout_fee.credit - tab_inout_fee.debit,
|
||||
tab_mv_spline_fee.amount,
|
||||
tab_spline_fee.amount,
|
||||
Case(
|
||||
(tab_line.bookingtype == 'spin', tab_spline_fee.amount),
|
||||
(tab_line.bookingtype == 'spout', tab_spline_fee.amount * Decimal('-1.0')),
|
||||
),
|
||||
Decimal('0.0'),
|
||||
)).as_('fee'),
|
||||
Sum(Coalesce(
|
||||
tab_inout_divi.credit - tab_inout_divi.debit,
|
||||
tab_mv_spline_divi.amount,
|
||||
tab_spline_divi.amount,
|
||||
Case(
|
||||
(tab_line.bookingtype == 'spin', tab_spline_divi.amount),
|
||||
(tab_line.bookingtype == 'spout', tab_spline_divi.amount * Decimal('-1.0')),
|
||||
),
|
||||
Decimal('0.0'),
|
||||
)).as_('dividend'),
|
||||
group_by=[tab_line.id],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue