fix: flip clubbed DN status To Bill → Completed on consolidated SI submit#25
Merged
Conversation
When multiple DNs are clubbed into one net-off Sales Invoice (consolidate_dns_to_si), the source DNs stayed on "To Bill" forever. Cause: the net-off SI omits SI Item.delivery_note (to avoid validate_multiple_billing), so ERPNext's update_billing_status sums zero linked rows and never advances per_billed. And nothing refreshed the custom_consolidated_si-linked DNs on submit (only the inter-company path refreshed its own custom_inter_company_si DNs). Fix: on Sales Invoice on_submit, mark every custom_consolidated_si-linked DN per_billed=100 / status=Completed (flat — a clubbed DN is fully invoiced). On cancel and on_trash, revert via ERPNext's update_billing_status (back to To Bill for a pure net-off DN; reflects any other real invoices otherwise) — done before clearing the stamp. No schema change. Regression test added. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Clubbing multiple DNs into one net-off Sales Invoice left the source DNs stuck on To Bill.
Cause
The net-off SI omits
SI Item.delivery_note(to dodgevalidate_multiple_billing), so ERPNext'supdate_billing_statussums zero linked rows →per_billednever moves. And no handler refreshed thecustom_consolidated_si-linked DNs on submit (only the inter-company path handled its owncustom_inter_company_siDNs).Fix
on_submit→mark_consolidated_dns_billed: set each clubbed DNper_billed=100/status=Completed(flat).on_cancel+on_trash→unmark_consolidated_dns_billed(ERPNext recompute → To Bill), before clearing the stamp.