Skip to content

Commit

Permalink
[IMP]account_payment_group:order imputed invoices by date maturity on…
Browse files Browse the repository at this point in the history
… receipts

Ticket: 51784
X-original-commit: 2e34da2
  • Loading branch information
Pablo Montenegro authored and pablohmontenegro committed Jan 20, 2023
1 parent 0bd3ddb commit c0fe8af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion account_payment_group/models/account_payment_group.py
Expand Up @@ -320,7 +320,13 @@ def _compute_matched_move_line_ids(self):
"""
for rec in self:
payment_lines = rec.payment_ids.mapped('line_ids').filtered(lambda x: x.account_internal_type in ['receivable', 'payable'])
rec.matched_move_line_ids = (payment_lines.mapped('matched_debit_ids.debit_move_id') | payment_lines.mapped('matched_credit_ids.credit_move_id')) - payment_lines
debit_moves = payment_lines.mapped('matched_debit_ids.debit_move_id')
credit_moves = payment_lines.mapped('matched_credit_ids.credit_move_id')
debit_lines_sorted = debit_moves.filtered(lambda x: x.date_maturity != False).sorted(key=lambda x: (x.date_maturity, x.move_id.name))
credit_lines_sorted = credit_moves.filtered(lambda x: x.date_maturity != False).sorted(key=lambda x: (x.date_maturity, x.move_id.name))
debit_lines_without_date_maturity = debit_moves - debit_lines_sorted
credit_lines_without_date_maturity = credit_moves - credit_lines_sorted
rec.matched_move_line_ids = ((debit_lines_sorted + debit_lines_without_date_maturity) | (credit_lines_sorted + credit_lines_without_date_maturity)) - payment_lines

@api.depends('payment_ids.line_ids')
def _compute_move_lines(self):
Expand Down

0 comments on commit c0fe8af

Please sign in to comment.