Files
erpnext/erpnext
harisansari008 5e33a3c0bf fix: distribute PO-invoice billed amount across receipts without duplication
When a Purchase Invoice is raised directly from a Purchase Order (po_detail
set, pr_detail null), update_billed_amount_based_on_po distributes the billed
amount across the PO's Purchase Receipts in FIFO order.

The proportional branch, taken when the invoiced qty exceeds a single
receipt's qty, computed each receipt's share but never deducted the consumed
amount/qty from the running po_billed_amt_details total. As a result every
subsequent receipt was billed against the same amount again, so the receipts
together showed more billed amount than was actually invoiced. A receipt with
no invoice truly against it could reach 100% billed and become Completed,
dropping out of pending-invoice reports.

Deduct the consumed billed_amt and billed_qty in the proportional branch,
mirroring the existing else branch, so each receipt only consumes what is
left. Add a regression test covering a PO invoice spanning two receipts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-11 16:16:33 +05:30
..
2026-08-09 10:02:29 +00:00
2026-07-01 17:04:11 +05:30