Bladeren bron

[Administration] Correctif activation des distributions à l'avance

master
Guillaume Bourgeois 1 jaar geleden
bovenliggende
commit
cd4b1ed6ea
2 gewijzigde bestanden met toevoegingen van 17 en 7 verwijderingen
  1. +10
    -5
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  2. +7
    -2
      console/commands/ActiveDistributionsInAdvanceController.php

+ 10
- 5
common/logic/Distribution/Distribution/Service/DistributionBuilder.php Bestand weergeven

@@ -208,15 +208,20 @@ class DistributionBuilder extends AbstractBuilder
$this->activeDistribution($distribution, $active);
}

public function activeDistributionByDayWeek(string $date, string $dayWeek, bool $active = true)
public function activeDistributionByDateIfDelivery(\DateTime $date, bool $active = true): void
{
$activeDay = $this->pointSaleRepository->isDayOfWeekWithDelivery($date->format('l'));
if($activeDay || !$active) {
$this->activeDistributionByDate($date, $active);
}
}

public function activeDistributionByDayWeek(string $date, string $dayWeek, bool $active = true): void
{
$week = sprintf('%02d', date('W', strtotime($date)));
$start = strtotime(date('Y', strtotime($date)) . 'W' . $week);
$dateDay = new \DateTime(date('Y-m-d', strtotime($dayWeek, $start)));
$activeDay = $this->pointSaleRepository->isDayOfWeekWithDelivery($dayWeek);
if ($activeDay || !$active) {
$this->activeDistributionByDate($dateDay, $active);
}
$this->activeDistributionByDateIfDelivery($dateDay, $active);
}

public function activeDistributionsOfWeek(string $date, bool $active = true): void

+ 7
- 2
console/commands/ActiveDistributionsInAdvanceController.php Bestand weergeven

@@ -19,8 +19,13 @@ class ActiveDistributionsInAdvanceController extends Controller
$weeksDistributionsActivatedInAdvance = $producerModule->getSolver()->getConfig('option_weeks_distributions_activated_in_advance');
if($weeksDistributionsActivatedInAdvance) {
$date = new \DateTime('+'.$weeksDistributionsActivatedInAdvance.' weeks');
$distributionModule->getBuilder()->activeDistributionByDate($date);
echo $producer->name. ' : distribution du ' . $date->format('d/m/Y') .' activée' ."\n";
$distributionModule->getBuilder()->activeDistributionByDateIfDelivery($date);

$distribution = $distributionModule->getRepository()
->findOneDistribution($date->format('Y-m-d'), true);
if($distribution) {
echo $producer->name. ' : distribution du ' . $date->format('d/m/Y') .' activée' ."\n";
}
}
}
}

Laden…
Annuleren
Opslaan