[16.0][FIX] pms: count bank statement payments in the folio pending amount - #443
Open
DarioLodeiros wants to merge 1 commit into
Open
[16.0][FIX] pms: count bank statement payments in the folio pending amount#443DarioLodeiros wants to merge 1 commit into
DarioLodeiros wants to merge 1 commit into
Conversation
pms.folio.pending_amount only looks at account.payment records, so money collected through a bank transfer never reaches the folio: the guest pays, the accountant reconciles the bank statement line straight against the customer invoice, and the folio stays "to pay" forever even though the invoice is fully paid. This is not an exotic setup. Reconciling a statement line directly against the invoice is the default flow when no payment is registered beforehand, and it is how most small properties collect transfers. The module already models the relation on both sides (pms.folio.statement_line_ids and account.bank.statement.line.folio_ids) but never used it to compute the amounts. Take those statement lines into account, next to the payments, in both the single-folio and the multi-folio branches. Only receivable lines of posted entries are considered, exactly as for payments, so a statement line reconciled against an account.payment through an outstanding account is not counted twice: its own move has no receivable line, and the payment is already counted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A guest pays their stay by bank transfer. The accountant reconciles the bank statement line straight against the customer invoice — the standard flow when no payment was registered beforehand, and the usual one in small properties. The invoice is fully paid, but the folio stays "to pay" forever:
pending_amountnever goes down and reception sees an outstanding balance for a booking that was collected weeks ago.The reason is that
pms.folio._compute_amountlooks only atpayment_ids(account.payment). It ignoresstatement_line_ids, even though this module defines the relation on both sides:pms.folio.statement_line_ids(pms/models/pms_folio.py)account.bank.statement.line.folio_ids(pms/models/account_bank_statement_line.py)So the data is there, and the user can link the statement line to the folio, but it has no effect on the amounts.
Fix
Take the statement lines into account next to the payments, in both the single-folio and the multi-folio branches, through a small helper (
_get_payment_move_lines) that keeps the existing filter: only receivable lines of posted entries.That filter is what keeps the amount correct in the other flow too. When a statement line is reconciled against an
account.paymentthrough an outstanding account, the statement move has no receivable line — the outstanding account is an asset — so nothing is counted twice; the payment alone is counted, exactly as today.The
@api.dependsis extended accordingly so the stored fields recompute when the statement line or its move changes.How to reproduce
account.paymentinvolved).folio_ids).pending_amount = amount_totalandpayment_state = not_paid. After it: the folio is settled.Testing
Verified on a production database of a rural property whose 19 opening bookings had been invoiced and collected by transfer before the PMS went live: with the statement lines linked, the folios were still showing 3.086 € pending. Existing behaviour for folios collected through the PMS is unchanged, since those go through
account.paymentas before.