Quellcode durchsuchen

Frontend : Adaptations suite aux modifications liées aux prix des produits + début mise en place promotions

master
Guillaume vor 4 Jahren
Ursprung
Commit
876a51524c
2 geänderte Dateien mit 36 neuen und 6 gelöschten Zeilen
  1. +34
    -5
      ShopBundle/Model/PriceTrait.php
  2. +2
    -1
      ShopBundle/Model/ReductionCatalog.php

+ 34
- 5
ShopBundle/Model/PriceTrait.php Datei anzeigen

@@ -2,6 +2,7 @@

namespace Lc\ShopBundle\Model ;

use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\UnitInterface;

trait PriceTrait
@@ -58,17 +59,45 @@ trait PriceTrait
return $this->calculatePriceByUnitRef($this->getPriceWithTax()) ;
}

public function getTheReductionCatalog()
{
$reductionCatalog = false;

if($this instanceof ProductFamily) {
$reductionCatalog = $this->getReductionCatalog() ;
}
if($this instanceof Product) {
$reductionCatalog = $this->getProductFamily()->getReductionCatalog() ;
}

return $reductionCatalog ;
}

public function getPriceByUnitRefWithTaxAndReduction(): ?float
{
$reductionCatalog = $this->getTheReductionCatalog() ;

if (isset($reductionCatalog) && $reductionCatalog) {
return $this->calculatePriceByUnitRef($this->getPriceWithTaxAndReductionCatalog($reductionCatalog)) ;
}
else {
return $this->calculatePriceByUnitRef($this->getPriceWithTax());
}
}

public function getPriceWithTaxAndReduction(): ?float
{
if ($this->reductionCatalog) {
return $this->getPriceWithTaxAndReductionCatalog($this->reductionCatalog);
} else {
return null;
$reductionCatalog = $this->getTheReductionCatalog() ;

if (isset($reductionCatalog) && $reductionCatalog) {
return $this->getPriceWithTaxAndReductionCatalog($reductionCatalog);
}
else {
return $this->getPriceWithTax();
}
}

public function getPriceWithTaxAndReductionCatalog(ReductionInterface $reductionCatalog): ?float
public function getPriceWithTaxAndReductionCatalog(ReductionCatalogInterface $reductionCatalog): ?float
{

if ($reductionCatalog->getUnit() == 'percent') {

+ 2
- 1
ShopBundle/Model/ReductionCatalog.php Datei anzeigen

@@ -6,13 +6,14 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\ReductionInterface;
use phpDocumentor\Reflection\Types\Integer;

/**
* @ORM\MappedSuperclass()
*/
abstract class ReductionCatalog extends AbstractDocumentEntity implements ReductionInterface, FilterMerchantInterface
abstract class ReductionCatalog extends AbstractDocumentEntity implements ReductionCatalogInterface, FilterMerchantInterface
{

use ReductionTrait;

Laden…
Abbrechen
Speichern