Skip to content

fix: scope wallet reservations to draft invoices#220

Open
my-dev-jour wants to merge 1 commit intoBrainWise-DEV:developfrom
my-dev-jour:fix/196-wallet-pending-scope
Open

fix: scope wallet reservations to draft invoices#220
my-dev-jour wants to merge 1 commit intoBrainWise-DEV:developfrom
my-dev-jour:fix/196-wallet-pending-scope

Conversation

@my-dev-jour
Copy link
Copy Markdown
Contributor

@my-dev-jour my-dev-jour commented Mar 28, 2026

Summary

  • only reserve wallet balance for draft POS invoices, not submitted invoices already reflected in GL
  • scope pending wallet reservations to the same company as the wallet lookup
  • add regression coverage for both wallet helper implementations

Problem

Wallet balance lookup subtracted pending wallet payments using all POS invoices with docstatus in [0, 1] and without company scoping.

That meant a submitted POS invoice could reduce available wallet balance a second time even though its effect was already in GL, and reservations could leak across companies.

Staging Reproduction

Confirmed on a staging environment (ERPNext 16.11.0 / POSNext 1.15.0):

  • mocked wallet GL balance to 300
  • a submitted partial POS invoice with outstanding 100 and a wallet-flagged payment reduced available balance from 300 to 200
  • this proved submitted invoices were being subtracted again as pending reservations

Fix

  • change pending reservation queries to draft invoices only (docstatus = 0)
  • pass company through wallet balance and available balance calculations
  • keep exclude_invoice behavior intact

Verification

  • staging reproduction confirmed the original bug
  • local verification was limited to py_compile in this workspace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant