Various code cleanup.

This commit is contained in:
James Cole
2017-02-25 05:57:01 +01:00
parent 444439fdab
commit 8c6972d12d
35 changed files with 133 additions and 171 deletions

View File

@@ -108,6 +108,19 @@ class PiggyBank extends Model
return $value;
}
public function getSuggestedMonthlyAmount()
{
if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) {
$thisMonth = Carbon::now()->month;
$targetMonth = $this->targetdate->month;
$remainingAmount = $this->targetamount - $this->currentRelevantRep()->currentamount;
return $thisMonth < $targetMonth ? $remainingAmount / ($targetMonth - $thisMonth) : $remainingAmount;
}
return 0;
}
/**
*
* @param Carbon $date
@@ -129,17 +142,6 @@ class PiggyBank extends Model
}
public function getSuggestedMonthlyAmount()
{
if ($this->targetdate && $this->currentRelevantRep()->currentamount < $this->targetamount) {
$thisMonth = Carbon::now()->month;
$targetMonth = $this->targetdate->month;
$remainingAmount = $this->targetamount - $this->currentRelevantRep()->currentamount;
return $thisMonth < $targetMonth ? $remainingAmount / ($targetMonth - $thisMonth) : $remainingAmount ;
}
return 0;
}
/**
* Get all of the piggy bank's notes.
*/