Skip to content

Fix expiration date logic to use latest entitlement end date#153

Open
vijaidjearam wants to merge 1 commit intoInfotelGLPI:masterfrom
vijaidjearam:patch-1
Open

Fix expiration date logic to use latest entitlement end date#153
vijaidjearam wants to merge 1 commit intoInfotelGLPI:masterfrom
vijaidjearam:patch-1

Conversation

@vijaidjearam
Copy link
Copy Markdown

A device can have multiple entitlements, each with its own endDate.
When determining the expiration date, we need to return the latest (maximum) end date, since that represents the actual final expiration of coverage.

However, using:

$date < $max_date

selects the earliest (minimum) date, which results in:

  • Returning the first entitlement that expires
  • Incorrectly reporting an earlier expiration date
  • Potentially shortening the displayed warranty/coverage period

✅ Correct Logic

To properly determine the expiration date, we must keep the comparison as:

if ($max_date == false || $date > $max_date) {
    $max_date = $date;
}

This ensures that:

  • On the first iteration, $max_date is initialized.
  • On subsequent iterations, we keep the latest (maximum) endDate.
  • The final result reflects the true expiration of all entitlements.

Fix expiration date logic to use latest entitlement 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