Browse Source

[Frontend] Page produit : correctif calcul prix par unité de référence

master
Guillaume 4 years ago
parent
commit
bbbb8c6659
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      ShopBundle/Model/PriceTrait.php

+ 7
- 2
ShopBundle/Model/PriceTrait.php View File



public function getPriceByUnitRef(): ?float public function getPriceByUnitRef(): ?float
{ {
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ;
return $this->calculatePriceByUnitRef($this->getPriceInherited()) ;
} }


public function getPriceByUnitRefWithTax(): ?float public function getPriceByUnitRefWithTax(): ?float
{ {
return $this->calculatePriceWithTax($this->getPriceByUnitRef(), $this->getTaxRateInherited()->getValue()) ;
return $this->calculatePriceByUnitRef($this->getPriceWithTax()) ;
} }


public function setPrice(float $price): self public function setPrice(float $price): self
$price = round(( ($price * 100)) / 100, 2) ; $price = round(( ($price * 100)) / 100, 2) ;
return $price ; return $price ;
} }

private function calculatePriceByUnitRef($price)
{
return ($price * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ;
}
} }

Loading…
Cancel
Save