File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public function divideBy(float $number): self
115115 public function addFee (float $ rate ): self
116116 {
117117 return $ this ->multiplyBy (
118- round (1 + $ rate , $ this ->currency ->mathDecimals ())
118+ round (1 + ( $ rate / 100 ) , $ this ->currency ->mathDecimals ())
119119 );
120120 }
121121
@@ -129,7 +129,7 @@ public function addTax(float $rate): self
129129 public function subtractFee (float $ rate ): self
130130 {
131131 return $ this ->divideBy (
132- round (1 + $ rate , $ this ->currency ->mathDecimals ())
132+ round (1 + ( $ rate / 100 ) , $ this ->currency ->mathDecimals ())
133133 );
134134 }
135135
Original file line number Diff line number Diff line change 104104test ('fees can be added to and subtracted from money ' , function () {
105105 $ money = Money::fromDecimal (10.0 );
106106
107- expect ($ money ->addFee (0.1 )->decimal ())->toBe (11.0 );
108- expect ($ money ->subtractFee (0.1 )->decimal ())->toBe (9.09 ); // 10/1.1
107+ expect ($ money ->addFee (10 )->decimal ())->toBe (11.0 );
108+ expect ($ money ->subtractFee (10 )->decimal ())->toBe (9.09 ); // 10/1.1
109109});
110110
111111test ('taxes can be added and subtracted from money ' , function () {
112112 currencies ()->add ([CZK ::class]);
113113
114114 expect (
115- Money::fromDecimal (100.0 , 'CZK ' )->addTax (0.21 )->decimal ()
115+ Money::fromDecimal (100.0 , 'CZK ' )->addTax (21.0 )->decimal ()
116116 )->toBe (121.0 );
117117
118118 expect (
119- Money::fromDecimal (121.0 , 'CZK ' )->subtractTax (0.21 )->decimal ()
119+ Money::fromDecimal (121.0 , 'CZK ' )->subtractTax (21.0 )->decimal ()
120120 )->toBe (100.0 );
121121});
122122
You can’t perform that action at this time.
0 commit comments