Przeglądaj źródła

[Backend] Produits > désactivation : prendre aussi en compte la modification dans les distributions à venir désactivées #1078

feature/souke
Guillaume Bourgeois 1 rok temu
rodzic
commit
9be26f9a70
3 zmienionych plików z 13 dodań i 8 usunięć
  1. +1
    -1
      backend/controllers/PointSaleController.php
  2. +10
    -5
      common/logic/Distribution/Distribution/Repository/DistributionRepository.php
  3. +2
    -2
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php

+ 1
- 1
backend/controllers/PointSaleController.php Wyświetl plik

@@ -183,7 +183,7 @@ class PointSaleController extends BackendController
UserPointSale::deleteAll(['id_point_sale' => $id]);

// Suppression du lien PointSaleDistribution pour toutes les distributions à venir
$incomingDistributions = $distributionManager->findDistributionsIncoming();
$incomingDistributions = $distributionManager->findDistributionsIncoming(true);
foreach ($incomingDistributions as $distribution) {
PointSaleDistribution::deleteAll(['id_point_sale' => $id, 'id_distribution' => $distribution->id]);
}

+ 10
- 5
common/logic/Distribution/Distribution/Repository/DistributionRepository.php Wyświetl plik

@@ -87,14 +87,19 @@ class DistributionRepository extends AbstractRepository
/**
* Récupère les distributions futures.
*/
public function findDistributionsIncoming(): array
public function findDistributionsIncoming($ignoreActive = false): array
{
$paramsWhere = [
'id_producer' => $this->getProducerContext()->id,
];

if(!$ignoreActive) {
$paramsWhere['active'] = 1;
}

$distributionsArray = Distribution::find()
->where('date > \'' . date('Y-m-d') . '\'')
->andWhere([
'id_producer' => $this->getProducerContext()->id,
'active' => 1
])
->andWhere($paramsWhere)
->orderBy('date ASC')
->all();


+ 2
- 2
common/logic/Distribution/Distribution/Service/DistributionBuilder.php Wyświetl plik

@@ -113,7 +113,7 @@ class DistributionBuilder extends AbstractBuilder
*/
public function addProductIncomingDistributions(Product $product): void
{
$distributionArray = $this->distributionRepository->findDistributionsIncoming();
$distributionArray = $this->distributionRepository->findDistributionsIncoming(true);
foreach ($distributionArray as $distribution) {
$this->addProduct($distribution, $product);
}
@@ -144,7 +144,7 @@ class DistributionBuilder extends AbstractBuilder
*/
public function addPointSaleIncomingDistributions(PointSale $pointSale): void
{
$distributionArray = $this->distributionRepository->findDistributionsIncoming();
$distributionArray = $this->distributionRepository->findDistributionsIncoming(true);
foreach ($distributionArray as $distribution) {
$this->addPointSale($distribution, $pointSale);
}

Ładowanie…
Anuluj
Zapisz