Commit 3ae5203e by Julien Jorry

Solidoume : fix check in redistribution

parent c52d983a
...@@ -405,7 +405,7 @@ class PrestataireAdmin extends AbstractAdmin ...@@ -405,7 +405,7 @@ class PrestataireAdmin extends AbstractAdmin
$em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager(); $em = $this->getConfigurationPool()->getContainer()->get('doctrine')->getManager();
foreach ($users as $user) { foreach ($users as $user) {
$newUser = false; $newUser = false;
if (null == $user->getId()) { if (null == $user || null == $user->getId()) {
$newUser = true; $newUser = true;
$emailExist = $em->getRepository(User::class)->findBy(['email' => $user->getEmail()]); $emailExist = $em->getRepository(User::class)->findBy(['email' => $user->getEmail()]);
if (count($emailExist) > 0) { if (count($emailExist) > 0) {
......
...@@ -236,7 +236,7 @@ class SolidoumeCommand extends Command ...@@ -236,7 +236,7 @@ class SolidoumeCommand extends Command
private function executeProgram() private function executeProgram()
{ {
$nowDay = (new \DateTime('now', new \DateTimeZone('UTC')))->format('d'); $nowDay = (new \DateTime('now', new \DateTimeZone('UTC')))->format('d');
// @TODO : uncomment this !
if (!$this->testExecute && $nowDay != $this->param->getExecutionDate()) { if (!$this->testExecute && $nowDay != $this->param->getExecutionDate()) {
$this->io->warning("Ce n'est pas le jour d'execution du programme (" . $this->param->getExecutionDate() . ')'); $this->io->warning("Ce n'est pas le jour d'execution du programme (" . $this->param->getExecutionDate() . ')');
} else { } else {
...@@ -250,7 +250,7 @@ class SolidoumeCommand extends Command ...@@ -250,7 +250,7 @@ class SolidoumeCommand extends Command
$countPerson = 0; $countPerson = 0;
$countParticipants = 0; $countParticipants = 0;
foreach ($items as $item) { foreach ($items as $item) {
if ($item->isEnabled()) { if ($this->isItemPayedThisMonth($item)) {
$total += $item->getAmount(); $total += $item->getAmount();
if (!$item->getIsDonation()) { if (!$item->getIsDonation()) {
++$countParticipants; ++$countParticipants;
...@@ -313,6 +313,25 @@ class SolidoumeCommand extends Command ...@@ -313,6 +313,25 @@ class SolidoumeCommand extends Command
return null; return null;
} }
private function isItemPayedThisMonth(SolidoumeItem $item): bool
{
$nowMonth = intval((new \DateTime('now', new \DateTimeZone('UTC')))->format('Ym'));
$lastMonth = intval((new \DateTime('now -1month', new \DateTimeZone('UTC')))->format('Ym'));
if ($item->isEnabled() && null != $item->getLastMonthPayed()) {
if ($item->getPaiementDate() <= $this->param->getExecutionDate() && $item->getPaiementDate() >= 1) {
if ($item->getLastMonthPayed() == $nowMonth) {
return true;
}
} else {
if ($item->getLastMonthPayed() == $lastMonth) {
return true;
}
}
}
return false;
}
/** /**
* Has to execute reminder by email ? Check date of paiement choose by adherent and number of days before remind. * Has to execute reminder by email ? Check date of paiement choose by adherent and number of days before remind.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment