Browse Source

Correctif reductionCatalog

packProduct
Fabien Normand 3 years ago
parent
commit
cfc6befc38
6 changed files with 13 additions and 8 deletions
  1. +1
    -1
      Builder/Order/OrderShopBuilder.php
  2. +2
    -1
      Model/Order/OrderProductReductionCatalogModel.php
  3. +2
    -1
      Model/Order/OrderProductRefundModel.php
  4. +2
    -1
      Model/Order/OrderReductionCreditModel.php
  5. +1
    -0
      Repository/Product/ProductFamilyStore.php
  6. +5
    -4
      Solver/Price/PriceSolverTrait.php

+ 1
- 1
Builder/Order/OrderShopBuilder.php View File

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()
); );



+ 2
- 1
Model/Order/OrderProductReductionCatalogModel.php View File



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;



+ 2
- 1
Model/Order/OrderProductRefundModel.php View File

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")

+ 2
- 1
Model/Order/OrderReductionCreditModel.php View File

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;



+ 1
- 0
Repository/Product/ProductFamilyStore.php View File

return []; return [];
} }



// findByTerms // findByTerms
public function getByTerms( public function getByTerms(
$terms, $terms,

+ 5
- 4
Solver/Price/PriceSolverTrait.php View File

$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);

Loading…
Cancel
Save