Browse Source

Merge branch 'feature/section_export' into develop

develop
Guillaume Bourgeois 2 weeks ago
parent
commit
ba122f7974
5 changed files with 50 additions and 5 deletions
  1. +8
    -0
      Controller/AdminControllerTrait.php
  2. +18
    -0
      Doctrine/Extension/ProductPropertyTrait.php
  3. +1
    -1
      Solver/Order/OrderShopSolver.php
  4. +11
    -0
      Solver/Price/PriceSolverTrait.php
  5. +12
    -4
      Solver/Product/ProductSolver.php

+ 8
- 0
Controller/AdminControllerTrait.php View File



namespace Lc\CaracoleBundle\Controller; namespace Lc\CaracoleBundle\Controller;


use App\Entity\Section\Section;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection; use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
} }
} }


public function configureResponseParametersDisableShowIfNotSection(KeyValueStore $responseParameters, Section $section)
{
if($this->getSectionCurrent() != $section) {
$responseParameters->set('replace_content_with_message', "Vous devez vous rendre sur la section ". $section->getTitle().' pour afficher cette page');
}
}

public function createIndexRepositoryQuery( public function createIndexRepositoryQuery(
SearchDto $searchDto, SearchDto $searchDto,
EntityDto $entityDto, EntityDto $entityDto,

+ 18
- 0
Doctrine/Extension/ProductPropertyTrait.php View File

*/ */
protected $propertyExpirationDate; protected $propertyExpirationDate;


/**
* @ORM\Column(type="float", nullable=true)
*/
protected $weight;


public function getBuyingPriceByRefUnit(): ?float public function getBuyingPriceByRefUnit(): ?float
{ {
return $this->buyingPriceByRefUnit; return $this->buyingPriceByRefUnit;
return $this; return $this;
} }


public function getWeight(): ?float
{
return $this->weight;
}

public function setWeight(?float $weight): self
{
$this->weight = $weight;

return $this;
}

} }

+ 1
- 1
Solver/Order/OrderShopSolver.php View File

} }
return $arrayComplementaryOrderShops; return $arrayComplementaryOrderShops;
} }
public function countValidComplementaryOrderShops(OrderShopInterface $orderShop): int public function countValidComplementaryOrderShops(OrderShopInterface $orderShop): int
{ {
return count($this->getValidComplementaryOrderShops($orderShop)); return count($this->getValidComplementaryOrderShops($orderShop));

+ 11
- 0
Solver/Price/PriceSolverTrait.php View File

return $price; return $price;
} }


public function excludeTax($price, $taxRateValue, $round = true)
{
$price = $this->applyPercentNegative($price, $taxRateValue);

if($round) {
return $this->round($price);
}

return $price;
}

public function applyReductionPercent($price, $percentage) public function applyReductionPercent($price, $percentage)
{ {
return $this->applyPercent($price, -$percentage); return $this->applyPercent($price, -$percentage);

+ 12
- 4
Solver/Product/ProductSolver.php View File

if ($product->getTitle()) { if ($product->getTitle()) {
$endOfTitle = $product->getTitle(); $endOfTitle = $product->getTitle();
} else { } else {
$endOfTitle = $this->getQuantityInherited($product).' '.$this->getUnitInherited($product)->getWordingShort();
$endOfTitle = $this->getQuantityInherited($product) . ' ' . $this->getUnitInherited($product)->getWordingShort();
} }
return $product->getProductFamily()->getTitle(). ' - '. $endOfTitle;
return $product->getProductFamily()->getTitle() . ' - ' . $endOfTitle;
} }


public function getQuantityInherited(ProductInterface $product) public function getQuantityInherited(ProductInterface $product)
{ {
if ($product->getQuantity()) { if ($product->getQuantity()) {
return $product->getQuantity(); return $product->getQuantity();
} else if($product->getProductFamily()->getQuantity()){
} else if ($product->getProductFamily()->getQuantity()) {
return $product->getProductFamily()->getQuantity(); return $product->getProductFamily()->getQuantity();
}else{
} else {
return 1; return 1;
} }
} }


return null; return null;
} }

public function getWeightInherited(ProductInterface $product): ? float
{
if ($product->getWeight()) {
return $product->getWeight();
}
return $product->getProductFamily()->getWeight();
}
} }

Loading…
Cancel
Save