浏览代码

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

feature/souke
Guillaume Bourgeois 1年前
父节点
当前提交
9be26f9a70
共有 3 个文件被更改,包括 13 次插入8 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

@@ -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);
}

正在加载...
取消
保存