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

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

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

public function addProduct(Distribution $distribution, Product $product): ProductDistribution public function addProduct(Distribution $distribution, Product $product): ProductDistribution
{ {
$productDistribution = $this->productDistributionBuilder->createProductDistributionIfNotExist($distribution, $product); $productDistribution = $this->productDistributionBuilder->createProductDistributionIfNotExist($distribution, $product);
$this->productDistributionBuilder->updateProductDistribution($productDistribution);
$this->updateOrderProductPrices($distribution, $product); $this->updateOrderProductPrices($distribution, $product);


return $productDistribution; return $productDistribution;

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

public function createProductDistribution(Distribution $distribution, Product $product): ProductDistribution public function createProductDistribution(Distribution $distribution, Product $product): ProductDistribution
{ {
$productDistribution = $this->instanciateProductDistribution($distribution, $product); $productDistribution = $this->instanciateProductDistribution($distribution, $product);

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

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


return $productDistribution; return $productDistribution;
return $this->productDistributionRepository->findOneProductDistribution($distribution, $product) return $this->productDistributionRepository->findOneProductDistribution($distribution, $product)
?? $this->createProductDistribution($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 public function initActive(ProductDistribution $productDistribution): ProductDistribution
{ {

Loading…
Cancel
Save