Filter out reconciled lines from debit/credit/secondary amount of account grouped line
It is needed to calculate the payable/receivable balance of grouped lines when it is partially reconciled. Closes #13918
This commit is contained in:
@@ -164,10 +164,16 @@ class MoveLineGroup(MoveLineMixin, ModelSQL, ModelView):
|
||||
|
||||
@classmethod
|
||||
def _aggregated_columns(cls, line):
|
||||
context = Transaction().context
|
||||
if not context.get('reconciled', True):
|
||||
filter_ = line.reconciliation == Null
|
||||
else:
|
||||
filter_ = None
|
||||
return [
|
||||
Sum(line.debit).as_('debit'),
|
||||
Sum(line.credit).as_('credit'),
|
||||
Sum(line.amount_second_currency).as_('amount_second_currency'),
|
||||
Sum(line.debit, filter_=filter_).as_('debit'),
|
||||
Sum(line.credit, filter_=filter_).as_('credit'),
|
||||
Sum(line.amount_second_currency, filter_=filter_).as_(
|
||||
'amount_second_currency'),
|
||||
BoolOr(line.reconciliation != Null).as_('partially_reconciled'),
|
||||
BoolAnd(line.reconciliation != Null).as_('reconciled'),
|
||||
Sum(
|
||||
|
||||
@@ -114,6 +114,14 @@ Check lines grouped::
|
||||
... else:
|
||||
... 2
|
||||
2
|
||||
>>> line.payable_receivable_balance
|
||||
Decimal('42.00')
|
||||
|
||||
>>> with config.set_context(reconciled=False):
|
||||
... line = LineGroup(line.id)
|
||||
>>> line.payable_receivable_balance
|
||||
Decimal('20.00')
|
||||
|
||||
>>> line, = LineGroup.find([
|
||||
... ('account', '=', accounts['receivable'].id),
|
||||
... ('credit', '=', Decimal('22')),
|
||||
|
||||
Reference in New Issue
Block a user