-
currency_id
-
id
-
amount
-
company_id
-
company_id.currency_id
-
journal_id
-
journal_id.default_account_id
|
''' Compute the field indicating if the payments are already reconciled with something.
This field is used for display purpose (e.g. display the 'reconcile' button redirecting to the reconciliation
widget).
'''
for pay in self:
liquidity_lines, counterpart_lines, writeoff_lines = pay._seek_for_lines()
if not pay.currency_id or not pay.id:
pay.is_reconciled = False
pay.is_matched = False
elif pay.currency_id.is_zero(pay.amount):
pay.is_reconciled = True
pay.is_matched = True
else:
residual_field = 'amount_residual' if pay.currency_id == pay.company_id.currency_id else 'amount_residual_currency'
if pay.journal_id.default_account_id and pay.journal_id.default_account_id in liquidity_lines.account_id:
# Allow user managing payments without any statement lines by using the bank account directly.
# In that case, the user manages transactions only using the register payment wizard.
pay.is_matched = True
else:
pay.is_matched = pay.currency_id.is_zero(sum(liquidity_lines.mapped(residual_field)))
reconcile_lines = (counterpart_lines + writeoff_lines).filtered(lambda line: line.account_id.reconcile)
pay.is_reconciled = pay.currency_id.is_zero(sum(reconcile_lines.mapped(residual_field)))
|
|