[Backport version-15] fix(lease): preserve existing invoice schedules on advance days recalculation - #86
Merged
Conversation
…culation (cherry picked from commit ceee36f)
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.
Backport of #83 to
version-15.Summary
Fixes invoice schedule recalculation in the Lease DocType so that changing Days to Invoice in Advance does not modify, delete, or regenerate existing invoice schedule dates.
Newly added lease periods are calculated independently using the updated advance setting.
Changes
date_to_invoicevalues from being recalculated when advance days are changed.schedule_start_date ASCcreation ASCschedule_start_date > lease.end_dateinstead ofdate_to_invoice > lease.end_date.days_to_invoice_in_advanceeven after invoices have been created.frappe.msgprintmodal with a non-blockingfrappe.show_alertnotification.Problem
Previously, changing Days to Invoice in Advance could cause existing un-invoiced schedules to be deleted and regenerated with different
date_to_invoicevalues.Additionally, schedules were ordered by
date_to_invoice, which could produce an incorrect sequence when schedules had different advance-day settings.Verification
Initial Schedule
Created a monthly Lease from September 2026 to December 2026 with:
5Generated schedules:
Recalculation
Updated:
5 → 1028-02-2027Then generated the Invoice Schedule again.
Result
Existing schedules remained unchanged:
Only the newly added periods were generated using the updated
10days advance:Also verified that the completion notification is displayed as a floating green alert.
Expected Behavior
Changing Days to Invoice in Advance should affect only newly generated invoice schedule periods. Existing schedule records and their invoice dates must remain untouched.