From 203ae2812f5b9669668ddbd41a3a306743ca4b33 Mon Sep 17 00:00:00 2001 From: Rick Cuddy Date: Fri, 22 Jul 2022 19:57:40 +1000 Subject: [PATCH] Use Piggy Bank's start date in monthly suggestion #6254 --- app/Repositories/PiggyBank/PiggyBankRepository.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 9acd034ec8..e74d486dd3 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -341,7 +341,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface } if (null !== $piggyBank->targetdate && $repetition->currentamount < $piggyBank->targetamount) { $now = Carbon::now(); - $diffInMonths = $now->diffInMonths($piggyBank->targetdate, false); + $startDate = null !== $piggyBank->startdate && $piggyBank->startdate->gte($now) ? $piggyBank->startdate : $now; + $diffInMonths = $startDate->diffInMonths($piggyBank->targetdate, false); $remainingAmount = bcsub($piggyBank->targetamount, $repetition->currentamount); // more than 1 month to go and still need money to save: