@@ -50,7 +50,7 @@ trait PriceTrait | |||
public function getPriceByUnitRef() | |||
{ | |||
return $this->getPriceInherited() * $this->getUnitInherited()->getCoefficient() ; | |||
return ($this->getPriceInherited() * $this->getUnitInherited()->getCoefficient()) / $this->getQuantityInherited() ; | |||
} | |||
public function getPriceByUnitRefWithTax() | |||
@@ -91,8 +91,8 @@ trait PriceTrait | |||
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 ; | |||
} | |||
} |
@@ -118,6 +118,10 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
*/ | |||
protected $typeExpirationDate; | |||
/** | |||
* @ORM\Column(type="string", length=32, nullable=true) | |||
*/ | |||
protected $behaviorAddToCart; | |||
public function __construct() | |||
{ | |||
@@ -233,6 +237,30 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
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 | |||
{ | |||
return $this->supplierTaxRate; | |||
@@ -430,6 +458,18 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
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 | |||
{ | |||
@@ -455,4 +495,16 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
return $this; | |||
} | |||
public function getBehaviorAddToCart(): ?string | |||
{ | |||
return $this->behaviorAddToCart; | |||
} | |||
public function setBehaviorAddToCart(?string $behaviorAddToCart): self | |||
{ | |||
$this->behaviorAddToCart = $behaviorAddToCart; | |||
return $this; | |||
} | |||
} |
@@ -60,6 +60,11 @@ trait ProductPropertyTrait | |||
return $this; | |||
} | |||
public function getQuantityInherited(): ?float | |||
{ | |||
return $this->getQuantity() ; | |||
} | |||
public function getAvailableQuantity(): ?float | |||
{ | |||
return $this->availableQuantity; |
@@ -42,7 +42,7 @@ | |||
{% if formValues.propertyNoveltyExpirationDate %}propertyNoveltyExpirationDateActive: true,{% endif %} | |||
{% if formValues.typeExpirationDate %}typeExpirationDate: "{{ formValues.typeExpirationDate }}",{% 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 = { | |||
{% if formValues.unit %}unit: parseInt({{ formValues.unit.id }}),{% endif %} |
@@ -66,8 +66,7 @@ class FrontendTwigExtension extends AbstractExtension | |||
public function formatPrice($price) | |||
{ | |||
$price = number_format($price, 2) ; | |||
$price = str_replace('.',',',$price) ; | |||
$price = number_format($price, 2, ',', ' ') ; | |||
$price = $price .' €' ; | |||
return $price ; | |||
} |