Selaa lähdekoodia

Modification Product et OrderUtils

feature/export_comptable
Guillaume 4 vuotta sitten
vanhempi
commit
42858f6cdd
2 muutettua tiedostoa jossa 43 lisäystä ja 8 poistoa
  1. +20
    -0
      ShopBundle/Model/Product.php
  2. +23
    -8
      ShopBundle/Services/OrderUtils.php

+ 20
- 0
ShopBundle/Model/Product.php Näytä tiedosto

@@ -37,6 +37,26 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod
$this->orderProducts = new ArrayCollection() ;
}

public function getBuyingPriceInherited()
{
if($this->getBuyingPrice()) {
return $this->getBuyingPrice();
}
else {
return $this->getProductFamily()->getBuyingPrice();
}
}

public function getBuyingPriceByRefUnitInherited()
{
if($this->getBuyingPriceByRefUnit()) {
return $this->getBuyingPriceByRefUnit();
}
else {
return $this->getProductFamily()->getBuyingPriceByRefUnit();
}
}

public function getPriceInherited()
{
if($this->getPrice()) {

+ 23
- 8
ShopBundle/Services/OrderUtils.php Näytä tiedosto

@@ -204,18 +204,12 @@ class OrderUtils

public function compareOrderProductReductionCatalog($orderProductReductionCatalog1, $orderProductReductionCatalog2)
{

return $orderProductReductionCatalog1 && $orderProductReductionCatalog2
&& $orderProductReductionCatalog1->getUnit() == $orderProductReductionCatalog2->getUnit()
&& $orderProductReductionCatalog1->getValue() == $orderProductReductionCatalog2->getValue()
&& $orderProductReductionCatalog1->getBehaviorTaxRate() == $orderProductReductionCatalog2->getBehaviorTaxRate();

/*return (!$orderProductReductionCatalog1 && !$orderProductReductionCatalog2)
return (!$orderProductReductionCatalog1 && !$orderProductReductionCatalog2)
|| ($orderProductReductionCatalog1
&& $orderProductReductionCatalog2
&& $orderProductReductionCatalog1->getUnit() == $orderProductReductionCatalog2->getUnit()
&& (string) $orderProductReductionCatalog1->getValue() == (string) $orderProductReductionCatalog2->getValue()
&& $orderProductReductionCatalog1->getBehaviorTaxRate() == $orderProductReductionCatalog2->getBehaviorTaxRate()) ;*/
&& $orderProductReductionCatalog1->getBehaviorTaxRate() == $orderProductReductionCatalog2->getBehaviorTaxRate()) ;
}

public function countQuantities($orderShop)
@@ -414,4 +408,25 @@ class OrderUtils

return $document ;
}

public function groupOrderProductsByProductFamily($orderProducts)
{
$orderProductsByProductFamily = [] ;
foreach($orderProducts as $orderProduct) {
if($orderProduct->getProduct() && $orderProduct->getProduct()->getProductFamily()) {
$productFamily = $orderProduct->getProduct()->getProductFamily() ;
if(!isset($orderProductsByProductFamily[$productFamily->getId()])) {
$orderProductsByProductFamily[$productFamily->getId()] = [
'order_products' => [],
'total_quantity_weight' => 0,
] ;
}
$orderProductsByProductFamily[$productFamily->getId()]['order_products'][] = $orderProduct ;
$orderProductsByProductFamily[$productFamily->getId()]['total_quantity_weight'] += ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient()) * $orderProduct->getQuantityOrder() ;
}
}

return $orderProductsByProductFamily ;
}

}

Loading…
Peruuta
Tallenna