Browse Source

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

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
9be26f9a70
3 changed files with 13 additions and 8 deletions
  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 View File

UserPointSale::deleteAll(['id_point_sale' => $id]); UserPointSale::deleteAll(['id_point_sale' => $id]);


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

+ 10
- 5
common/logic/Distribution/Distribution/Repository/DistributionRepository.php View File

/** /**
* Récupère les distributions futures. * 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() $distributionsArray = Distribution::find()
->where('date > \'' . date('Y-m-d') . '\'') ->where('date > \'' . date('Y-m-d') . '\'')
->andWhere([
'id_producer' => $this->getProducerContext()->id,
'active' => 1
])
->andWhere($paramsWhere)
->orderBy('date ASC') ->orderBy('date ASC')
->all(); ->all();



+ 2
- 2
common/logic/Distribution/Distribution/Service/DistributionBuilder.php View File

*/ */
public function addProductIncomingDistributions(Product $product): void public function addProductIncomingDistributions(Product $product): void
{ {
$distributionArray = $this->distributionRepository->findDistributionsIncoming();
$distributionArray = $this->distributionRepository->findDistributionsIncoming(true);
foreach ($distributionArray as $distribution) { foreach ($distributionArray as $distribution) {
$this->addProduct($distribution, $product); $this->addProduct($distribution, $product);
} }
*/ */
public function addPointSaleIncomingDistributions(PointSale $pointSale): void public function addPointSaleIncomingDistributions(PointSale $pointSale): void
{ {
$distributionArray = $this->distributionRepository->findDistributionsIncoming();
$distributionArray = $this->distributionRepository->findDistributionsIncoming(true);
foreach ($distributionArray as $distribution) { foreach ($distributionArray as $distribution) {
$this->addPointSale($distribution, $pointSale); $this->addPointSale($distribution, $pointSale);
} }

Loading…
Cancel
Save