Skip to content

fix(lease): recalculate un-invoiced schedules from first next start date - #91

Open
iamtalib13 wants to merge 1 commit into
Aakvatech-Limited:version-15-hotfixfrom
iamtalib13:fix/recalculate-uninvoiced-lease-schedules
Open

fix(lease): recalculate un-invoiced schedules from first next start date#91
iamtalib13 wants to merge 1 commit into
Aakvatech-Limited:version-15-hotfixfrom
iamtalib13:fix/recalculate-uninvoiced-lease-schedules

Conversation

@iamtalib13

Copy link
Copy Markdown
Contributor

Summary

Fixes schedule recalculation logic when updating Days to Invoice in Advance on Lease documents.

Previously, updating advance days locked all existing rows and failed to update future periods unless lease_end_date was modified. This change preserves invoiced rows and dynamically regenerates only the unbilled periods up to the lease end date.

Changes

  • Preserve billed rows: Keeps rows linked to an existing Sales Invoice or Sales Order.
  • Dynamic start date: Computes next start date from last_invoiced_schedule.end_date + 1 (or lease_start_date if none).
  • Regenerate unbilled: Drops and rebuilds remaining unbilled periods using the updated offset.
  • Refactor: Removed redundant loops and normalized date boundary checks.

How to Test

  1. Create a 1-year Lease (01-Sep-2026 to 31-Aug-2027) with Days to Invoice in Advance = 5.
  2. Generate schedule; create and submit Sales Invoice for Row 1.
  3. Update advance days to 10 and trigger schedule regeneration.
  4. Verify: Row 1 remains unchanged (27-Aug-2026); Rows 2–12 regenerate with the 10-day offset without touching the lease end date.

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.

1 participant