New methods.

This commit is contained in:
James Cole
2014-11-26 17:20:18 +01:00
parent 9f926394a6
commit 69b36ddd1d
2 changed files with 32 additions and 0 deletions

View File

@@ -250,4 +250,18 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
return $sum;
}
/**
* @param \Budget $budget
* @param Carbon $start
* @param Carbon $end
*
* @return float
*/
public function spentInPeriod(\Budget $budget, Carbon $start, Carbon $end)
{
$sum = floatval($budget->transactionjournals()->before($end)->after($start)->lessThan(0)->sum('amount')) * -1;
return $sum;
}
}