Contract and Asset Renewal Jobs #
Two daily background jobs handle contract auto-renewal and asset expiration reminders.
What DMSI Service Management Adds
Both jobs are new. Core manages subscription renewals through WooCommerce Subscriptions. Service Management adds separate contract-level auto-renewal logic and a dedicated asset expiration tracking system.
Contract Renewal Job #
Interval: Daily
The Contract Renewal job processes service contracts with the auto_renew flag set to true (1).
What It Does #
- Queries all contracts where
auto_renew = 1andend_date <= today. - For each qualifying contract:
- Extends the end date by the contract’s renewal period (typically 12 months).
- Applies hour rollover logic: if the contract has a
rollover_hourssetting, any unused hours from the previous period are added to the new allocated_hours total (up to any configured cap). - Resets hour usage tracking for the new period.
- Queues a
contract-createdemail to notify the customer of the renewal. - Logs all renewals to the plugin activity log.
Manual Renewals #
Admin users can manually renew a contract from the Services > Contracts detail page without waiting for the daily job. Manual renewal uses the same logic as the automated job.
Asset Renewals Job #
Interval: Daily
The Asset Renewals job checks all active assets for upcoming expiration dates.
What It Does #
- Queries all assets with status = active.
- For each asset, calculates days until expiration.
- If days until expiry equals the first reminder threshold (default: 30 days), queues an
asset-expiring-soonemail. - If days until expiry equals the second reminder threshold (default: 7 days), queues a second
asset-expiring-soonemail. - Updates asset status to
expiring_soonwhen crossing the 30-day threshold.
Reminder Thresholds #
| Reminder | Default | Setting Location |
|---|---|---|
| First reminder | 30 days | Services > Settings > Alerts > Asset Reminder Days 1 |
| Second reminder | 7 days | Services > Settings > Alerts > Asset Reminder Days 2 |
Expired Assets #
When an asset’s expiration date passes, the daily job updates its status to expired. An expired asset generates no further reminder emails.
