Browse Source

[Backend] Produits : correctif update active et quantity max

feature/souke
Guillaume 1 year ago
parent
commit
9e2346f88a
3 changed files with 18 additions and 5 deletions
  1. +1
    -1
      common/logic/Distribution/Distribution/Repository/DistributionRepository.php
  2. +1
    -0
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  3. +16
    -4
      common/logic/Distribution/ProductDistribution/Service/ProductDistributionBuilder.php

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

@@ -92,7 +92,7 @@ class DistributionRepository extends AbstractRepository
$distributionsArray = Distribution::find()
->where('date > \'' . date('Y-m-d') . '\'')
->andWhere([
'id_producer' => GlobalParam::getCurrentProducerId(),
'id_producer' => $this->getProducerContext()->id,
'active' => 1
])
->orderBy('date ASC')

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

@@ -102,6 +102,7 @@ class DistributionBuilder extends AbstractBuilder
public function addProduct(Distribution $distribution, Product $product): ProductDistribution
{
$productDistribution = $this->productDistributionBuilder->createProductDistributionIfNotExist($distribution, $product);
$this->productDistributionBuilder->updateProductDistribution($productDistribution);
$this->updateOrderProductPrices($distribution, $product);

return $productDistribution;

+ 16
- 4
common/logic/Distribution/ProductDistribution/Service/ProductDistributionBuilder.php View File

@@ -35,10 +35,7 @@ class ProductDistributionBuilder extends AbstractBuilder
public function createProductDistribution(Distribution $distribution, Product $product): ProductDistribution
{
$productDistribution = $this->instanciateProductDistribution($distribution, $product);

$this->initActive($productDistribution);
$this->initQuantityMax($productDistribution);

$this->initProductDistribution($productDistribution);
$this->saveCreate($productDistribution);

return $productDistribution;
@@ -49,6 +46,21 @@ class ProductDistributionBuilder extends AbstractBuilder
return $this->productDistributionRepository->findOneProductDistribution($distribution, $product)
?? $this->createProductDistribution($distribution, $product);
}
public function updateProductDistribution(ProductDistribution $productDistribution): ProductDistribution
{
$this->initProductDistribution($productDistribution);
$this->saveUpdate($productDistribution);

return $productDistribution;
}

public function initProductDistribution(ProductDistribution $productDistribution): ProductDistribution
{
$this->initActive($productDistribution);
$this->initQuantityMax($productDistribution);

return $productDistribution;
}

public function initActive(ProductDistribution $productDistribution): ProductDistribution
{

Loading…
Cancel
Save