public function getPriceByUnitRef() | public function getPriceByUnitRef() | ||||
{ | { | ||||
return $this->getPriceInherited() * $this->getUnitInherited()->getCoefficient() ; | |||||
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ; | |||||
} | } | ||||
public function getPriceByUnitRefWithTax() | public function getPriceByUnitRefWithTax() | ||||
private function calculatePriceWithTax($priceWithoutTax, $taxRateValue) | private function calculatePriceWithTax($priceWithoutTax, $taxRateValue) | ||||
{ | { | ||||
$price = floatval($priceWithoutTax) * ($taxRateValue + 1) ; | |||||
$price = number_format(( ($price * 100)) / 100, 2) ; | |||||
$price = floatval($priceWithoutTax) * ($taxRateValue/100 + 1) ; | |||||
$price = round(( ($price * 100)) / 100, 2) ; | |||||
return $price ; | return $price ; | ||||
} | } | ||||
} | } |
*/ | */ | ||||
protected $typeExpirationDate; | protected $typeExpirationDate; | ||||
/** | |||||
* @ORM\Column(type="string", length=32, nullable=true) | |||||
*/ | |||||
protected $behaviorAddToCart; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getProductCategoryParent() | |||||
{ | |||||
$productCategories = $this->getProductCategories() ; | |||||
if(count($productCategories) > 0) { | |||||
return $productCategories[0]->getParent() ; | |||||
} | |||||
return false ; | |||||
} | |||||
public function getProductCategoryChild() | |||||
{ | |||||
$productCategories = $this->getProductCategories() ; | |||||
foreach($productCategories as $productCategory) { | |||||
if($productCategory->getParent()) { | |||||
return $productCategory ; | |||||
} | |||||
} | |||||
return false ; | |||||
} | |||||
public function getSupplierTaxRate(): ?TaxRate | public function getSupplierTaxRate(): ?TaxRate | ||||
{ | { | ||||
return $this->supplierTaxRate; | return $this->supplierTaxRate; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function countProperties(): bool | |||||
{ | |||||
$count = 0 ; | |||||
$count += (int) strlen($this->getPropertyAllergens()) > 0 ; | |||||
$count += (int) strlen($this->getPropertyComposition()) > 0 ; | |||||
$count += (int) strlen($this->getPropertyFragrances()) > 0 ; | |||||
$count += (int) strlen($this->getPropertyOrganicLabel()) > 0 ; | |||||
$count += (int) ($this->getPropertyExpirationDate() != null) ; | |||||
return $count ; | |||||
} | |||||
public function getBehaviorExpirationDate(): ?string | public function getBehaviorExpirationDate(): ?string | ||||
{ | { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getBehaviorAddToCart(): ?string | |||||
{ | |||||
return $this->behaviorAddToCart; | |||||
} | |||||
public function setBehaviorAddToCart(?string $behaviorAddToCart): self | |||||
{ | |||||
$this->behaviorAddToCart = $behaviorAddToCart; | |||||
return $this; | |||||
} | |||||
} | } |
return $this; | return $this; | ||||
} | } | ||||
public function getQuantityInherited(): ?float | |||||
{ | |||||
return $this->getQuantity() ; | |||||
} | |||||
public function getAvailableQuantity(): ?float | public function getAvailableQuantity(): ?float | ||||
{ | { | ||||
return $this->availableQuantity; | return $this->availableQuantity; |
{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | {% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | ||||
{% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} | {% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% endif %} | ||||
{% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} | {% if formValues.behaviorExpirationDate %}behaviorExpirationDate: "{{ formValues.behaviorExpirationDate }}",{% endif %} | ||||
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate }}",{% endif %} | |||||
{% if formValues.propertyExpirationDate %}propertyExpirationDate: "{{ formValues.propertyExpirationDate|date('d/m/Y') }}",{% endif %} | |||||
}; | }; | ||||
window.productUnitPriceValues = { | window.productUnitPriceValues = { | ||||
{% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %} | {% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %} |
public function formatPrice($price) | public function formatPrice($price) | ||||
{ | { | ||||
$price = number_format($price, 2) ; | |||||
$price = str_replace('.',',',$price) ; | |||||
$price = number_format($price, 2, ',', ' ') ; | |||||
$price = $price .' €' ; | $price = $price .' €' ; | ||||
return $price ; | return $price ; | ||||
} | } |