diff --git a/src/App/Calculator/Calculation.php b/src/App/Calculator/Calculation.php index e7c3abd..51bb286 100644 --- a/src/App/Calculator/Calculation.php +++ b/src/App/Calculator/Calculation.php @@ -14,6 +14,7 @@ private function __construct( public float $interestRate, public int $recoveryFee, public int $interestPayable, + public int $dailyAmount, public int $daysOverdue, public DateTimeImmutable $referenceDate, ) { @@ -24,6 +25,7 @@ public static function new( float $interestRate, Money $recoveryFee, Money $interestPayable, + Money $dailyAmount, int $daysOverdue, DateTimeImmutable $referenceDate, ): self { @@ -32,6 +34,7 @@ public static function new( $interestRate, (int) $recoveryFee->getAmount(), (int) $interestPayable->getAmount(), + (int) $dailyAmount->getAmount(), $daysOverdue, $referenceDate, ); @@ -47,6 +50,11 @@ public function interestPayable(): Money return new Money($this->interestPayable, $this->request->currency()); } + public function dailyAmount(): Money + { + return new Money($this->dailyAmount, $this->request->currency()); + } + public function totalPayable(): Money { return $this->request->amount()->add( diff --git a/src/App/Calculator/StandardCalculator.php b/src/App/Calculator/StandardCalculator.php index ce75fa6..2c8682e 100644 --- a/src/App/Calculator/StandardCalculator.php +++ b/src/App/Calculator/StandardCalculator.php @@ -32,7 +32,7 @@ public function calculate(Request $request): Calculation if ($dueDate >= $request->now) { $zero = new Money(0, $this->expectedCurrency); - return Calculation::new($request, 0.0, $zero, $zero, 0, $referenceDate); + return Calculation::new($request, 0.0, $zero, $zero, $zero, 0, $referenceDate); } $baseRate = $this->rateHistory->findChangeOnOrPreceding($referenceDate); @@ -52,7 +52,7 @@ public function calculate(Request $request): Calculation $dailyAmount = $request->amount()->multiply((string) ($dailyRate / 100)); $interestAmount = $dailyAmount->multiply($days); - return Calculation::new($request, $interestRate, $recovery, $interestAmount, $days, $referenceDate); + return Calculation::new($request, $interestRate, $recovery, $interestAmount, $dailyAmount, $days, $referenceDate); } /** diff --git a/src/App/Middleware/CalculationMiddleware.php b/src/App/Middleware/CalculationMiddleware.php index 7cf3d8c..11ed29a 100644 --- a/src/App/Middleware/CalculationMiddleware.php +++ b/src/App/Middleware/CalculationMiddleware.php @@ -108,6 +108,7 @@ private function result(Calculation $result): ResponseInterface 'recoveryFee' => $formatter->format($result->recoveryFee()), 'interestPayable' => $formatter->format($result->interestPayable()), 'totalPayable' => $formatter->format($result->totalPayable()), + 'dailyAmount' => $formatter->format($result->dailyAmount()), 'interestRate' => $result->interestRate, 'daysOverdue' => $result->daysOverdue, 'originalAmount' => $formatter->format($result->request->amount()), diff --git a/templates/pages/home.phtml b/templates/pages/home.phtml index 72ae55a..d2ede44 100644 --- a/templates/pages/home.phtml +++ b/templates/pages/home.phtml @@ -72,6 +72,7 @@ $initialDate = new DateTimeImmutable('-30 days'); (The statutory rate of 8.0% + The Bank of England base rate as at )