瀏覽代碼

Merge branch 'master' into develop

feature/export_comptable
Guillaume 4 年之前
父節點
當前提交
1f3dbd3007
共有 2 個文件被更改,包括 36 次插入6 次删除
  1. +34
    -5
      ShopBundle/Model/PriceTrait.php
  2. +2
    -1
      ShopBundle/Model/ReductionCatalog.php

+ 34
- 5
ShopBundle/Model/PriceTrait.php 查看文件

@@ -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 查看文件

@@ -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;

Loading…
取消
儲存