Browse Source

Merge branch 'master' into develop

feature/export_comptable
Guillaume 4 years ago
parent
commit
1f3dbd3007
2 changed files with 36 additions and 6 deletions
  1. +34
    -5
      ShopBundle/Model/PriceTrait.php
  2. +2
    -1
      ShopBundle/Model/ReductionCatalog.php

+ 34
- 5
ShopBundle/Model/PriceTrait.php View File



namespace Lc\ShopBundle\Model ; namespace Lc\ShopBundle\Model ;


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


trait PriceTrait trait PriceTrait
return $this->calculatePriceByUnitRef($this->getPriceWithTax()) ; 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 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') { if ($reductionCatalog->getUnit() == 'percent') {

+ 2
- 1
ShopBundle/Model/ReductionCatalog.php View File

use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\FilterMerchantInterface; use Lc\ShopBundle\Context\FilterMerchantInterface;
use Lc\ShopBundle\Context\ReductionCatalogInterface;
use Lc\ShopBundle\Context\ReductionInterface; use Lc\ShopBundle\Context\ReductionInterface;
use phpDocumentor\Reflection\Types\Integer; use phpDocumentor\Reflection\Types\Integer;


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


use ReductionTrait; use ReductionTrait;

Loading…
Cancel
Save