Information about bug
A transaction-based Pricing Rule discount remains on an existing Draft Sales Invoice after the Pricing Rule is changed so that it is no longer valid for the invoice's Posting Date.
The issue occurs when a Pricing Rule has already populated a transaction-level discount on a Draft Sales Invoice, and the Pricing Rule is subsequently changed so that it no longer applies to the transaction.
The concern is specifically the persistence of the previously applied transaction-level discount during subsequent editing and recalculation of the Draft Sales Invoice.
Steps to reproduce
-
Create a Pricing Rule with:
- Apply On: Transaction
- Price or Product Discount: Price
- A percentage discount, for example 4%
- A validity period that includes the Sales Invoice Posting Date.
-
Create a new Sales Invoice with a Posting Date within the Pricing Rule validity period.
-
Save the Sales Invoice as Draft.
-
Confirm that the transaction-level discount has been applied to the Draft Sales Invoice.
-
Edit the same Pricing Rule and change Valid Upto to a date earlier than the Sales Invoice Posting Date, making the Pricing Rule no longer applicable to that transaction.
-
Reopen the existing Draft Sales Invoice.
-
Modify the Draft in a way that triggers recalculation, then save it.
-
The Pricing Rule is no longer valid for the invoice Posting Date, but the previously applied transaction-level discount remains on the Draft Sales Invoice.
Current behavior
The previously applied transaction-level discount remains on the Draft Sales Invoice even after the Pricing Rule that originally provided it is no longer applicable to the invoice Posting Date.
The transaction is recalculated, but the previously populated transaction-level discount is retained.
Expected behavior
When an existing Draft Sales Invoice is recalculated, ERPNext should not silently retain a discount that was previously populated by a Pricing Rule that is no longer applicable.
The system should distinguish between:
- A discount explicitly entered or intentionally overridden by the user.
- A discount previously populated by a Pricing Rule.
When the originating Pricing Rule is no longer applicable, the Pricing Rule-derived discount should be revalidated and removed or recalculated as appropriate, while preserving an intentional manual override.
The recalculation should therefore not allow a previously rule-generated discount to remain silently effective solely because it was populated before the Pricing Rule became invalid.
Business impact
This behavior can have a material financial impact in environments with a high volume of Draft Sales Invoices.
For example, a Pricing Rule may initially be configured with an incorrect validity date and apply a discount to Draft invoices. The Pricing Rule may later be corrected, but previously created Draft invoices can retain the old transaction-level discount during subsequent editing and recalculation.
If these Draft invoices proceed through the normal approval and submission workflow without the discount being identified and revalidated, an unintended discount may remain on the submitted Sales Invoice.
No server-side exception is generated. This is a functional behavior reproduced through the standard Sales Invoice UI.
Module
accounts
Version
Frappe v15.121.2
Frappe v16.36.0
ERPNext v15.121.6
ERPNext v16.37.0
Installation method
FrappeCloud
Relevant log output / Stack trace / Full Error Message.
No server-side exception or stack trace is generated.
This is a functional behavior reproduced through the standard ERPNext Sales Invoice UI.
Additional context
A related case was previously reported through Frappe Cloud:
Ticket #79305:
https://support.frappe.io/helpdesk/my-tickets/79305
The current issue is specifically about the persistence of a previously applied transaction-level discount on an existing Draft Sales Invoice after the originating Pricing Rule becomes invalid.
Information about bug
A transaction-based Pricing Rule discount remains on an existing Draft Sales Invoice after the Pricing Rule is changed so that it is no longer valid for the invoice's Posting Date.
The issue occurs when a Pricing Rule has already populated a transaction-level discount on a Draft Sales Invoice, and the Pricing Rule is subsequently changed so that it no longer applies to the transaction.
The concern is specifically the persistence of the previously applied transaction-level discount during subsequent editing and recalculation of the Draft Sales Invoice.
Steps to reproduce
Create a Pricing Rule with:
Create a new Sales Invoice with a Posting Date within the Pricing Rule validity period.
Save the Sales Invoice as Draft.
Confirm that the transaction-level discount has been applied to the Draft Sales Invoice.
Edit the same Pricing Rule and change Valid Upto to a date earlier than the Sales Invoice Posting Date, making the Pricing Rule no longer applicable to that transaction.
Reopen the existing Draft Sales Invoice.
Modify the Draft in a way that triggers recalculation, then save it.
The Pricing Rule is no longer valid for the invoice Posting Date, but the previously applied transaction-level discount remains on the Draft Sales Invoice.
Current behavior
The previously applied transaction-level discount remains on the Draft Sales Invoice even after the Pricing Rule that originally provided it is no longer applicable to the invoice Posting Date.
The transaction is recalculated, but the previously populated transaction-level discount is retained.
Expected behavior
When an existing Draft Sales Invoice is recalculated, ERPNext should not silently retain a discount that was previously populated by a Pricing Rule that is no longer applicable.
The system should distinguish between:
When the originating Pricing Rule is no longer applicable, the Pricing Rule-derived discount should be revalidated and removed or recalculated as appropriate, while preserving an intentional manual override.
The recalculation should therefore not allow a previously rule-generated discount to remain silently effective solely because it was populated before the Pricing Rule became invalid.
Business impact
This behavior can have a material financial impact in environments with a high volume of Draft Sales Invoices.
For example, a Pricing Rule may initially be configured with an incorrect validity date and apply a discount to Draft invoices. The Pricing Rule may later be corrected, but previously created Draft invoices can retain the old transaction-level discount during subsequent editing and recalculation.
If these Draft invoices proceed through the normal approval and submission workflow without the discount being identified and revalidated, an unintended discount may remain on the submitted Sales Invoice.
No server-side exception is generated. This is a functional behavior reproduced through the standard Sales Invoice UI.
Module
accounts
Version
Frappe v15.121.2
Frappe v16.36.0
ERPNext v15.121.6
ERPNext v16.37.0
Installation method
FrappeCloud
Relevant log output / Stack trace / Full Error Message.
Additional context
A related case was previously reported through Frappe Cloud:
Ticket #79305:
https://support.frappe.io/helpdesk/my-tickets/79305
The current issue is specifically about the persistence of a previously applied transaction-level discount on an existing Draft Sales Invoice after the originating Pricing Rule becomes invalid.