Skip to content

Add Tier Downgrade Support for Case Retention Policy with Auto-Adjustment and Admin Warning#8773

Open
sanjacornelius wants to merge 4 commits intoepic/FOUR-29101from
observation/FOUR-30459
Open

Add Tier Downgrade Support for Case Retention Policy with Auto-Adjustment and Admin Warning#8773
sanjacornelius wants to merge 4 commits intoepic/FOUR-29101from
observation/FOUR-30459

Conversation

@sanjacornelius
Copy link
Copy Markdown
Contributor

@sanjacornelius sanjacornelius commented Apr 9, 2026

Issue & Reproduction Steps

This PR implements support for handling tier downgrades in the Case Retention Policy. When a client downgrades their tier, any configured process retention periods that exceed the new tier’s maximum limit are automatically adjusted to comply with the new constraints.

Additionally, a warning message is surfaced to admin users for a 24-hour period to notify them of the automatic adjustment.

Solution

  • Introduced CaseRetentionTierService to:
    • Retrieve the maximum allowed retention period for the current tier
    • Automatically clamp process retention values to the allowed maximum
  • Implemented auto-adjustment logic:
    • Example: If a process is configured for 5 years (Tier 3 max) and the client is downgraded to Tier 2 (3 year max), the retention period is automatically updated to 3 years
  • Added UI warning for affected processes (visible to admin users for 24 hours)

How to Test

  1. Ensure tenant tier is set to Level 3
  2. Create processes with retention periods: six_months, one_year, three_years, five_years
  3. Downgrade the tier to Level 2
  4. Run:
    • php artisan optimize:clear
    • Restart Horizon
  5. Execute:
    • TENANT=[TENANT_ID] php artisan cases:retention:evaluate
  6. Navigate to Designer → Processes listing page
  7. Locate processes previously set above the Tier 2 limit (greater than 3 years)
  8. Verify:
    • A warning message is displayed for affected processes
  9. Open process configuration and confirm:
    • Retention period is adjusted to 3 years
  10. Repeat downgrade (Tier 2 → Tier 1) and verify:
    • Retention is adjusted to 1 year for any processes exceeding the limit

Related Tickets & Packages

ci:deploy

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

…egration

Introduce CaseRetentionTierService to manage tier-driven case retention rules and notices. Integrate the service into ProcessController to expose an admin-only adjustment notice flag, clear notice properties when an admin changes retention_period, and preserve notice keys when restoring process properties. Update EvaluateProcessRetentionJob to clamp process retention to the current tier (logging and refreshing the model when a clamp occurs). The service provides allowed-period lookup, period normalization, a 24-hour admin notice window, and a clamp operation that updates retention_period, retention_updated_at, clears retention_updated_by, and records when to show the notice.
Insert an English translation entry informing users that case retention was automatically shortened to match their subscription tier and that the new retention period applies immediately.
Resolve allowed retention periods once in the command and pass them to the queued job to avoid re-resolving per process. Add PERIOD_MONTHS and longestAllowedPeriod() to determine the longest period by duration (not array order). Update EvaluateProcessRetentionJob to accept optional tierAllowedPeriods and clampProcessRetentionToCurrentTier() to use the provided list when present; clamp now sets the retention to the longest allowed period. Minor docblock and logging updates.
Add a boolean case_retention_tier_adjustment_notice field to the Process API resource (defaults to false) so clients can detect when case retention was automatically shortened to match the subscription tier. Update the frontend ProcessMixin to append a localized warning message to process.warningMessages when this flag is true, informing users the new retention period applies immediately.
@processmaker-sonarqube
Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@Kookster310
Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://ci-b9748f55a0.engk8s.processmaker.net

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