Selaa lähdekoodia

Merge branch 'develop'

master
Guillaume Bourgeois 2 vuotta sitten
vanhempi
commit
b816aa13ae
4 muutettua tiedostoa jossa 69 lisäystä ja 40 poistoa
  1. +3
    -1
      Builder/Order/OrderProductBuilder.php
  2. +5
    -0
      Form/Order/OrderProductsType.php
  3. +21
    -11
      Resolver/SectionResolver.php
  4. +40
    -28
      Solver/Price/ProductPriceSolver.php

+ 3
- 1
Builder/Order/OrderProductBuilder.php Näytä tiedosto

@@ -49,6 +49,8 @@ class OrderProductBuilder
{
$orderProduct->setTitle($this->orderProductSolver->getTitleOrderShop($orderProduct));
$orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct()));
// #402
//$orderProduct->setPrice($this->priceSolver->getPriceWithReduction($orderProduct->getProduct()));
$orderProduct->setBuyingPrice($this->priceSolver->getBuyingPrice($orderProduct->getProduct()));
$orderProduct->setUnit($this->productSolver->getUnitInherited($orderProduct->getProduct()));
$orderProduct->setTaxRate($this->productFamilySolver->getTaxRateInherited($orderProduct->getProduct()));
@@ -65,7 +67,7 @@ class OrderProductBuilder
if ($reductionCatalog && $reductionCatalog->getStatus()) {
$orderProductReductionCatalog = $this->orderProductReductionCatalogFactory->create(
$reductionCatalog->getTitle(),
$reductionCatalog->getValue(),
is_null($reductionCatalog->getValue()) ? 0 : $reductionCatalog->getValue(),
$reductionCatalog->getUnit(),
$reductionCatalog->getBehaviorTaxRate()
);

+ 5
- 0
Form/Order/OrderProductsType.php Näytä tiedosto

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Form\Order;

use App\Repository\Product\ProductFamilyStore;
use Doctrine\ORM\EntityManagerInterface;
use Http\Discovery\Exception\NotFoundException;
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySolver;
use Symfony\Component\Form\AbstractType;
@@ -70,6 +71,10 @@ class OrderProductsType extends AbstractType
}
}

if(is_null($product)) {
throw new NotFoundException('Aucun Product trouvé pour le ProductFamily #'.$productFamily->getId());
}

$orderProduct = $this->orderProductFactory->create($product, 1);

$builder->add('order_product_0', OrderProductType::class, [

+ 21
- 11
Resolver/SectionResolver.php Näytä tiedosto

@@ -53,21 +53,31 @@ class SectionResolver

// admin
if (isset($requestAttributesArray['_firewall_context']) && $requestAttributesArray['_firewall_context'] == 'security.firewall.map.context.admin') {
if (!$this->isCachedSection) {
$currentAdminSection = null;
$userMerchant = $this->merchantResolver->getUserMerchant();

if ($userMerchant !== null) {
$currentAdminSection = $userMerchant->getCurrentAdminSection();
}
if ($this->cacheSectionCurrent) {
return $this->cacheSectionCurrent;
} elseif ($returnDefaultIfOutOfSections && $this->cacheSectionDefault) {
return $this->cacheSectionDefault;
}

$sectionCurrent = null;
$userMerchant = $this->merchantResolver->getUserMerchant();
if($userMerchant !== null) {
$sectionCurrent = $userMerchant->getCurrentAdminSection();
}

$this->isCachedSection = true;
$this->section = $currentAdminSection;
$sectionDefault = $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault();

return $currentAdminSection;
} else {
return $this->section;
if($sectionCurrent) {
$this->cacheSectionCurrent = $sectionCurrent;
return $sectionCurrent;
} elseif($returnDefaultIfOutOfSections && $sectionDefault) {
$this->cacheSectionDefault = $sectionDefault;
return $sectionDefault;
}

return null;

} // front
else {


+ 40
- 28
Solver/Price/ProductPriceSolver.php Näytä tiedosto

@@ -42,19 +42,31 @@ class ProductPriceSolver
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) {
return $solver->getPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient());
$product
) / $solver->getUnitInherited($product)->getCoefficient());
} else {
return 0;
}
}
}

public function getPriceWithReduction(ProductPropertyInterface $product)
{
return $this->applyReductionCatalog(
$product,
$this->getPrice($product),
$this->getPriceWithTax($product),
1,
null,
false
);
}

public function getPriceWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}

@@ -63,8 +75,7 @@ class ProductPriceSolver
$solver = $this->getSolver($product);

if ($solver->getBehaviorPriceInherited($product) == 'by-piece') {
return ($this->getPrice($product) * $solver->getUnitInherited($product)->getCoefficient(
)) / $solver->getQuantityInherited($product);
return ($this->getPrice($product) * $solver->getUnitInherited($product)->getCoefficient()) / $solver->getQuantityInherited($product);
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
return $solver->getPriceByRefUnitInherited($product);
}
@@ -73,8 +84,8 @@ class ProductPriceSolver
public function getPriceByRefUnitWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}

@@ -82,23 +93,24 @@ class ProductPriceSolver
{
//TODO voir différence entre prix ici et dans tableau décli
return $this->applyReductionCatalog(
$product,
$this->getPrice($product),
$this->getPriceWithTax($product)
$product,
$this->getPrice($product),
$this->getPriceWithTax($product)
);
}

//Bridge pour applyReductionCatalog qui ne peut pas être appeler à cause du call
public function getPriceWithTaxByReduction(
ProductPropertyInterface $product,
ReductionCatalogInterface $reductionCatalog
) {
ProductPropertyInterface $product,
ReductionCatalogInterface $reductionCatalog
)
{
return $this->applyReductionCatalog(
$product,
$this->getPrice($product),
$this->getPriceWithTax($product),
1,
$reductionCatalog
$product,
$this->getPrice($product),
$this->getPriceWithTax($product),
1,
$reductionCatalog
);
}

@@ -108,9 +120,9 @@ class ProductPriceSolver

if ($priceWithTax) {
return $this->round(
($this->getPriceByRefUnitWithTax($product) * $this->getPriceWithTaxAndReduction($product))
/ $priceWithTax
);
($this->getPriceByRefUnitWithTax($product) * $this->getPriceWithTaxAndReduction($product))
/ $priceWithTax
);
}

return 0;
@@ -125,8 +137,8 @@ class ProductPriceSolver
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') {
if ($solver->getQuantityInherited($product) > 0) {
return $solver->getBuyingPriceByRefUnitInherited($product) * ($solver->getQuantityInherited(
$product
) / $solver->getUnitInherited($product)->getCoefficient());
$product
) / $solver->getUnitInherited($product)->getCoefficient());
} else {
return 0;
}
@@ -136,8 +148,8 @@ class ProductPriceSolver
public function getBuyingPriceWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getBuyingPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getBuyingPrice($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}

@@ -149,8 +161,8 @@ class ProductPriceSolver
public function getBuyingPriceByRefUnitWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getBuyingPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
$this->getBuyingPriceByRefUnit($product),
$this->productFamilySolver->getTaxRateInherited($product)->getValue()
);
}


Loading…
Peruuta
Tallenna