Skip to content

Commit

Permalink
Updated PriceAmendable using RationalMoney
Browse files Browse the repository at this point in the history
  • Loading branch information
toonvandenbos committed Sep 14, 2024
1 parent d689fd4 commit a4cb67a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
11 changes: 2 additions & 9 deletions src/PriceAmendable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Whitecube\Price;

use Brick\Money\AbstractMoney;
use Brick\Money\RationalMoney;

interface PriceAmendable
{
Expand Down Expand Up @@ -35,13 +35,6 @@ public function appliesAfterVat(): bool;

/**
* Apply the modifier on the given Money instance
*
* @param \Brick\Money\AbstractMoney $build
* @param float $units
* @param bool $perUnit
* @param null|\Brick\Money\AbstractMoney $exclusive
* @param null|\Whitecube\Price\Vat $vat
* @return null|\Brick\Money\AbstractMoney
*/
public function apply(AbstractMoney $build, float $units, bool $perUnit, AbstractMoney $exclusive = null, Vat $vat = null) : ?AbstractMoney;
public function apply(RationalMoney $build, float $units, bool $perUnit, RationalMoney $exclusive = null, Vat $vat = null) : ?RationalMoney;
}
4 changes: 2 additions & 2 deletions tests/Fixtures/AfterVatAmendableModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Brick\Math\RoundingMode;
use Whitecube\Price\Vat;
use Whitecube\Price\PriceAmendable;
use Brick\Money\AbstractMoney;
use Brick\Money\RationalMoney;

class AfterVatAmendableModifier implements PriceAmendable
{
Expand Down Expand Up @@ -62,7 +62,7 @@ public function appliesAfterVat(): bool
/**
* Apply the modifier on the given Money instance
*/
public function apply(AbstractMoney $build, $units, $perUnit, AbstractMoney $exclusive = null, Vat $vat = null) : ?AbstractMoney
public function apply(RationalMoney $build, $units, $perUnit, RationalMoney $exclusive = null, Vat $vat = null) : ?RationalMoney
{
$tax = Money::ofMinor(100, 'EUR');

Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/AmendableModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Brick\Math\RoundingMode;
use Whitecube\Price\Vat;
use Whitecube\Price\PriceAmendable;
use Brick\Money\AbstractMoney;
use Brick\Money\RationalMoney;

class AmendableModifier implements PriceAmendable
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public function appliesAfterVat(): bool
/**
* Apply the modifier on the given Money instance
*/
public function apply(AbstractMoney $build, $units, $perUnit, AbstractMoney $exclusive = null, Vat $vat = null) : ?AbstractMoney
public function apply(RationalMoney $build, $units, $perUnit, RationalMoney $exclusive = null, Vat $vat = null) : ?RationalMoney
{
return $build->multipliedBy(1.25, RoundingMode::HALF_UP);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/CustomAmendableModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Brick\Math\RoundingMode;
use Whitecube\Price\Vat;
use Whitecube\Price\PriceAmendable;
use Brick\Money\AbstractMoney;
use Brick\Money\RationalMoney;

class CustomAmendableModifier implements PriceAmendable
{
Expand Down Expand Up @@ -75,7 +75,7 @@ public function appliesAfterVat(): bool
/**
* Apply the modifier on the given Money instance
*/
public function apply(AbstractMoney $build, $units, $perUnit, AbstractMoney $exclusive = null, Vat $vat = null) : ?AbstractMoney
public function apply(RationalMoney $build, $units, $perUnit, RationalMoney $exclusive = null, Vat $vat = null) : ?RationalMoney
{
if($perUnit) {
return $build->plus($this->tax);
Expand Down

0 comments on commit a4cb67a

Please sign in to comment.