Internal: Fix reminder logic to send first notification when reaching exacte number of days and fix reminder number calculation not taking into account hours - refs BT#22063

pull/5865/head
NicoDucou 10 months ago
parent 5a6b2131c4
commit b5b32617e1
  1. 6
      src/CoreBundle/Command/LpProgressReminderCommand.php

@ -221,6 +221,8 @@ class LpProgressReminderCommand extends Command
{
$reminderStartDate = (clone $registrationDate)->modify("+$nbDaysForLpCompletion days");
$currentDate = new DateTime('now', new DateTimeZone('UTC'));
$reminderStartDate->setTime(0, 0, 0);
$currentDate->setTime(0, 0, 0);
$interval = $reminderStartDate->diff($currentDate);
$diffDays = (int) $interval->format('%a');
@ -242,8 +244,8 @@ class LpProgressReminderCommand extends Command
$interval = $reminderStartDate->diff($currentDate);
$diffDays = (int) $interval->format('%a');
return $diffDays >= self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION &&
$diffDays % self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION === 0;
return ($diffDays >= self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION &&
$diffDays % self::NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION === 0) || $diffDays === 0;
}

Loading…
Cancel
Save