Commit f5ce8281 by Julien Jorry

Fix Solidoume redistribution program : bug in some particular situation

parent d71ca3ea
......@@ -293,22 +293,34 @@ class SolidoumeCommand extends Command
$total = 0;
$countPerson = 0;
$countParticipants = 0;
$participants = [];
foreach ($items as $item) {
if ($this->isItemPayedThisMonth($item)) {
$datas = $this->em->getRepository(Flux::class)->getQueryByAdherentAndDestinataire($item->getAdherent(), $this->em->getRepository(Prestataire::class)->getPrestataireSolidoume(), 'adherent_prestataire');
$lastPrelevement = null;
foreach ($datas as $data) {
if ($data->getCreatedAt()->format('d') <= $this->param->getExecutionDate()) {
if ($data->getCreatedAt()->format('d') <= $this->param->getExecutionDate() && $data->getCreatedAt()->format('m') == ((new \DateTime('now', new \DateTimeZone('UTC')))->format('m'))) {
$lastPrelevement = $data;
} elseif ($data->getCreatedAt()->format('d') > $this->param->getExecutionDate() && $data->getCreatedAt()->format('m') == ((new \DateTime('now', new \DateTimeZone('UTC')))->format('m')-1)) {
$lastPrelevement = $data;
}
}
if ($lastPrelevement == null && count($datas) > 0) {
$lastPrelevement = $datas[0];
$total += $lastPrelevement->getMontant();
if (!$item->getIsDonation()) {
++$countParticipants;
if ($lastPrelevement != null) {
$datas = $this->em->getRepository(Flux::class)->getQueryByAdherentAndDestinataire($item->getAdherent(), $this->em->getRepository(Prestataire::class)->getPrestataireSolidoume(), 'prestataire_adherent');
$lastPaiement = null;
foreach ($datas as $data) {
if ($data->getCreatedAt()->format('m') == ((new \DateTime('now', new \DateTimeZone('UTC')))->format('m'))) {
$lastPaiement = $data;
}
}
if ($lastPaiement == null) {
$total += $lastPrelevement->getMontant();
if (!$item->getIsDonation()) {
++$countParticipants;
}
$participants[] = $item;
++$countPerson;
}
++$countPerson;
}
}
}
......@@ -323,8 +335,8 @@ class SolidoumeCommand extends Command
$isTest = $this->isTest;
$io = $this->io;
$operationUtils = $this->operationUtils;
$callback = function () use ($em, $items, $isTest, $io, $totalByParticipant, $operationUtils) {
foreach ($items as $item) {
$callback = function () use ($em, $participants, $isTest, $io, $totalByParticipant, $operationUtils) {
foreach ($participants as $item) {
if ($this->isItemPayedThisMonth($item) && !$item->getIsDonation()) {
// Envoi de l'emlc sur le compte de l'adherent
$flux = new TransactionPrestataireAdherent();
......@@ -333,7 +345,7 @@ class SolidoumeCommand extends Command
$flux->setMontant($totalByParticipant);
$flux->setMoyen(MoyenEnum::MOYEN_EMLC);
$now = (new \Datetime('now'))->format('d/m/Y H:i:s');
$flux->setReference($em->getRepository(SolidoumeParameter::class)->getValueOf('name') . ' ' . $now);
$flux->setReference('Correction ' . $em->getRepository(SolidoumeParameter::class)->getValueOf('name') . ' ' . $now);
if (!$isTest) {
$em->persist($flux);
// Write operations for this flux !
......@@ -372,11 +384,11 @@ class SolidoumeCommand extends Command
$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) {
if ($item->getLastMonthPayed() >= $nowMonth) {
return true;
}
} else {
if ($item->getLastMonthPayed() == $lastMonth) {
if ($item->getLastMonthPayed() >= $lastMonth) {
return true;
}
}
......
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