Skip to content

[Backport version-15] fix(lease): preserve existing invoice schedules on advance days recalculation - #86

Merged
aakvatech merged 1 commit into
version-15from
backport-83-to-version-15
Sep 4, 2026
Merged

[Backport version-15] fix(lease): preserve existing invoice schedules on advance days recalculation#86
aakvatech merged 1 commit into
version-15from
backport-83-to-version-15

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

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

  • Preserve existing un-invoiced invoice schedule records during recalculation.
  • Prevent existing date_to_invoice values from being recalculated when advance days are changed.
  • Process existing schedules chronologically using:
    • schedule_start_date ASC
    • creation ASC
  • Fix cleanup logic to check schedule_start_date > lease.end_date instead of date_to_invoice > lease.end_date.
  • Allow users to modify days_to_invoice_in_advance even after invoices have been created.
  • Replace the blocking frappe.msgprint modal with a non-blocking frappe.show_alert notification.

Problem

Previously, changing Days to Invoice in Advance could cause existing un-invoiced schedules to be deleted and regenerated with different date_to_invoice values.

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:

  • Days to Invoice in Advance: 5

Generated schedules:

Row Schedule Period Date to Invoice
1 Sep 2026 27-08-2026
2 Oct 2026 26-09-2026
3 Nov 2026 27-10-2026
4 Dec 2026 26-11-2026

Recalculation

Updated:

  • Days to Invoice in Advance: 5 → 10
  • Lease End Date: 28-02-2027

Then generated the Invoice Schedule again.

Result

Existing schedules remained unchanged:

  • 27-08-2026
  • 26-09-2026
  • 27-10-2026
  • 26-11-2026

Only the newly added periods were generated using the updated 10 days advance:

Row Schedule Period Date to Invoice
5 Jan 2027 22-12-2026
6 Feb 2027 22-01-2027

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.

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.

2 participants