mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fixed #1405
This commit is contained in:
@@ -36,6 +36,11 @@ use FireflyIII\Models\Account;
|
||||
|
||||
/**
|
||||
* Class PiggyBank.
|
||||
*
|
||||
* @property Carbon $targetdate
|
||||
* @property Carbon $startdate
|
||||
* @property string $targetamount
|
||||
*
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
{
|
||||
@@ -132,32 +137,6 @@ class PiggyBank extends Model
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getSuggestedMonthlyAmount(): string
|
||||
{
|
||||
$savePerMonth = '0';
|
||||
if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) {
|
||||
$now = Carbon::now();
|
||||
$diffInMonths = $now->diffInMonths($this->targetdate, false);
|
||||
$remainingAmount = bcsub($this->targetamount, $this->currentRelevantRep()->currentamount);
|
||||
|
||||
// more than 1 month to go and still need money to save:
|
||||
if ($diffInMonths > 0 && 1 === bccomp($remainingAmount, '0')) {
|
||||
$savePerMonth = bcdiv($remainingAmount, (string)$diffInMonths);
|
||||
}
|
||||
|
||||
// less than 1 month to go but still need money to save:
|
||||
if (0 === $diffInMonths && 1 === bccomp($remainingAmount, '0')) {
|
||||
$savePerMonth = $remainingAmount;
|
||||
}
|
||||
}
|
||||
|
||||
return $savePerMonth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Carbon $date
|
||||
*
|
||||
|
@@ -29,6 +29,7 @@ use FireflyIII\Models\PiggyBank;
|
||||
|
||||
/**
|
||||
* Class PiggyBankRepetition.
|
||||
* @property string $currentamount
|
||||
*/
|
||||
class PiggyBankRepetition extends Model
|
||||
{
|
||||
|
Reference in New Issue
Block a user