Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5066 from Zales0123/remove-adjustments-before-tax…
…es-and-promotion-application [Core] Remove promotion and tax adjustments before recalculation
- Loading branch information
Showing
9 changed files
with
195 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sylius\Component\Core\Remover; | ||
|
||
use Sylius\Component\Core\Model\AdjustmentInterface; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Model\OrderItemUnitInterface; | ||
|
||
/** | ||
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com> | ||
*/ | ||
class AdjustmentsRemover implements AdjustmentsRemoverInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function removeFrom(OrderInterface $order) | ||
{ | ||
$adjustmentsToRemove = [ | ||
AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT, | ||
AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT, | ||
AdjustmentInterface::TAX_ADJUSTMENT | ||
]; | ||
|
||
foreach ($adjustmentsToRemove as $type) { | ||
$order->removeAdjustmentsRecursively($type); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Sylius/Component/Core/Remover/AdjustmentsRemoverInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sylius\Component\Core\Remover; | ||
|
||
use Sylius\Component\Core\Model\OrderInterface; | ||
|
||
/** | ||
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com> | ||
*/ | ||
interface AdjustmentsRemoverInterface | ||
{ | ||
/** | ||
* @param OrderInterface $order | ||
*/ | ||
public function removeFrom(OrderInterface $order); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/Sylius/Component/Core/spec/Remover/AdjustmentsRemoverSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace spec\Sylius\Component\Core\Remover; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Model\AdjustmentInterface; | ||
use Sylius\Component\Core\Model\OrderInterface; | ||
use Sylius\Component\Core\Model\OrderItemUnitInterface; | ||
use Sylius\Component\Core\Remover\AdjustmentsRemover; | ||
use Sylius\Component\Core\Remover\AdjustmentsRemoverInterface; | ||
|
||
/** | ||
* @mixin AdjustmentsRemover | ||
* | ||
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com> | ||
*/ | ||
class AdjustmentsRemoverSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Sylius\Component\Core\Remover\AdjustmentsRemover'); | ||
} | ||
|
||
function it_implements_adjustments_remover_interface() | ||
{ | ||
$this->shouldImplement(AdjustmentsRemoverInterface::class); | ||
} | ||
|
||
function it_removes_adjustments_from_order_recursively(OrderInterface $order) | ||
{ | ||
$order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT)->shouldBeCalled(); | ||
$order->removeAdjustmentsRecursively(AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT)->shouldBeCalled(); | ||
$order->removeAdjustmentsRecursively(AdjustmentInterface::TAX_ADJUSTMENT)->shouldBeCalled(); | ||
|
||
$this->removeFrom($order); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters