First attempt at unifying code for categories and budgets, which are basically the same thing.

This commit is contained in:
Sander Dorigo
2014-11-10 21:55:22 +01:00
parent af9473c126
commit 9fa326f630
11 changed files with 417 additions and 393 deletions

View File

@@ -148,6 +148,32 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface
// TODO: Implement findByWhat() method.
}
/**
* @param \Category $budget
* @param Carbon $date
*
* @return null
*/
public function repetitionOnStartingOnDate(\Category $category, Carbon $date)
{
return null;
}
/**
* @param \Category $category
* @param Carbon $date
*
* @return float
*/
public function spentInMonth(\Category $category, Carbon $date)
{
$end = clone $date;
$date->startOfMonth();
$end->endOfMonth();
$sum = floatval($category->transactionjournals()->before($end)->after($date)->lessThan(0)->sum('amount')) * -1;
return $sum;
}
/**
* @param Ardent $model
* @param array $data