Add daily lease status automation for Upcoming, Active, and Expired leases#53
Merged
Conversation
Added methods to manage and update lease statuses automatically based on defined rules.
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 2 minor |
| ErrorProne | 1 high |
🟢 Metrics 23 complexity · 0 duplication
Metric Results Complexity 23 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Summary
This PR adds automated Lease Status updates for system-controlled lease statuses.
The automation updates leases between the following statuses based on lease dates:
The daily scheduler runs through
daily_longand updates only leases that are already in one of the system-controlled statuses. Manual statuses such as Draft, Terminated, Closed, Vacating, Not Materialized, Renewal to Previous Lease, and Adendum to Previous Lease are intentionally not overwritten.Changes
set_lease_status()on the Lease document controller.get_system_controlled_statuses()helper.get_status_for_lease()helper to calculate the correct status based on:start_dateend_dateskip_end_dateupdate_lease_statuses()scheduler method.frappe.db.set_value()for scheduler updates to avoid full document save hooks.add_comment()on the Lease timeline.Status Rules
start_dateis in the futurestart_date <= todayandend_date >= todayend_date < todayskip_end_dateis checkedend_date == todayManual Status Handling
Only these statuses are system-controlled:
Any other Lease Status is treated as manually controlled and is not updated automatically.
Scheduler
The scheduler method is intended to run under
daily_long: