if ($orderProductAdd->getQuantityOrder() > 0) { | if ($orderProductAdd->getQuantityOrder() > 0) { | ||||
$updated = false; | $updated = false; | ||||
$this->orderProductBuilder->init($orderProductAdd); | $this->orderProductBuilder->init($orderProductAdd); | ||||
$productFamily = $this->productFamilyStore->getOneBySlug( | |||||
$productFamily = $this->productFamilyStore->setSection($orderShop->getSection())->getOneBySlug( | |||||
$orderProductAdd->getProduct()->getProductFamily()->getSlug() | $orderProductAdd->getProduct()->getProductFamily()->getSlug() | ||||
); | ); | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class OrderProductReductionCatalogModel | |||||
abstract class OrderProductReductionCatalogModel implements EntityInterface | |||||
{ | { | ||||
use ReductionTrait; | use ReductionTrait; | ||||
namespace Lc\CaracoleBundle\Model\Order; | namespace Lc\CaracoleBundle\Model\Order; | ||||
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class OrderProductRefundModel | |||||
abstract class OrderProductRefundModel implements EntityInterface | |||||
{ | { | ||||
/** | /** | ||||
* @ORM\Column(type="integer") | * @ORM\Column(type="integer") |
use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\SovBundle\Doctrine\EntityInterface; | |||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class OrderReductionCreditModel implements ReductionInterface | |||||
abstract class OrderReductionCreditModel implements ReductionInterface, EntityInterface | |||||
{ | { | ||||
use ReductionTrait; | use ReductionTrait; | ||||
return []; | return []; | ||||
} | } | ||||
// findByTerms | // findByTerms | ||||
public function getByTerms( | public function getByTerms( | ||||
$terms, | $terms, |
$withTax = true, | $withTax = true, | ||||
$round = true | $round = true | ||||
): ?float { | ): ?float { | ||||
if ($reductionCatalog) { | if ($reductionCatalog) { | ||||
$reductionCatalogValue = $reductionCatalog->getValue(); | $reductionCatalogValue = $reductionCatalog->getValue(); | ||||
$reductionCatalogUnit = $reductionCatalog->getUnit(); | $reductionCatalogUnit = $reductionCatalog->getUnit(); | ||||
} | } | ||||
} | } | ||||
if (isset($reductionCatalogValue) && isset($reductionCatalogUnit) && isset($reductionCatalogBehaviorTaxRate)) { | |||||
if (isset($reductionCatalogValue) && isset($reductionCatalogUnit)) { | |||||
if ($reductionCatalogUnit == 'percent') { | if ($reductionCatalogUnit == 'percent') { | ||||
$priceWithTax = $this->applyReductionPercent( | $priceWithTax = $this->applyReductionPercent( | ||||
$priceWithTax, | $priceWithTax, | ||||
$reductionCatalogValue | $reductionCatalogValue | ||||
); | ); | ||||
} elseif ($reductionCatalogUnit == 'amount') { | |||||
} elseif ($reductionCatalogUnit == 'amount' && isset($reductionCatalogBehaviorTaxRate)) { | |||||
if ($reductionCatalogBehaviorTaxRate == 'tax-excluded') { | if ($reductionCatalogBehaviorTaxRate == 'tax-excluded') { | ||||
$priceWithTax = $this->applyTax( | $priceWithTax = $this->applyTax( | ||||
$this->applyReductionAmount( | $this->applyReductionAmount( | ||||
$price, | $price, | ||||
$reductionCatalogValue * $quantity | $reductionCatalogValue * $quantity | ||||
), | ), | ||||
$entity->getTaxRateInherited()->getValue() | |||||
$this->productFamilySolver->getTaxRateInherited($entity)->getValue() | |||||
); | ); | ||||
} elseif ($reductionCatalogBehaviorTaxRate == 'tax-included') { | } elseif ($reductionCatalogBehaviorTaxRate == 'tax-included') { | ||||
$priceWithTax = $this->applyReductionAmount( | $priceWithTax = $this->applyReductionAmount( | ||||
if ($withTax) { | if ($withTax) { | ||||
$priceReturn = $priceWithTax; | $priceReturn = $priceWithTax; | ||||
} else { | } else { | ||||
$priceReturn = $this->applyPercentNegative($priceWithTax, $entity->getTaxRateInherited()->getValue()); | |||||
$priceReturn = $this->applyPercentNegative($priceWithTax, $this->productFamilySolver->getTaxRateInherited($entity)->getValue()); | |||||
} | } | ||||
if ($round) { | if ($round) { | ||||
return $this->round($priceReturn); | return $this->round($priceReturn); |