Fix some chart things. Again.

This commit is contained in:
James Cole 2015-09-25 16:18:50 +02:00
parent cb985f5897
commit 0a8f4017bd
3 changed files with 27 additions and 2 deletions

View File

@ -147,7 +147,7 @@ class CategoryController extends Controller
while ($start <= $end) {
$spent = $repository->spentOnDaySumCorrected($category, $start);
$earned = 0;
$earned = $repository->earnedOnDaySumCorrected($category, $start);
if ($spent < 0) {
$earned = $spent * -1;
$spent = 0;

View File

@ -200,7 +200,7 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
*/
public function spentOnDaySumCorrected(Category $category, Carbon $date)
{
return $category->transactionjournals()->onDate($date)->get(['transaction_journals.*'])->sum('correct_amount');
return $category->transactionjournals()->transactionTypes(['Withdrawal'])->onDate($date)->get(['transaction_journals.*'])->sum('correct_amount');
}
/**
@ -355,4 +355,18 @@ class CategoryRepository extends ComponentRepository implements CategoryReposito
{
return $category->transactionJournals()->before($end)->after($start)->count();
}
/**
*
* Corrected for tags.
*
* @param Category $category
* @param Carbon $date
*
* @return float
*/
public function earnedOnDaySumCorrected(Category $category, Carbon $date)
{
return $category->transactionjournals()->transactionTypes(['Deposit'])->onDate($date)->get(['transaction_journals.*'])->sum('correct_amount');
}
}

View File

@ -145,6 +145,17 @@ interface CategoryRepositoryInterface
*/
public function spentOnDaySumCorrected(Category $category, Carbon $date);
/**
*
* Corrected for tags.
*
* @param Category $category
* @param Carbon $date
*
* @return float
*/
public function earnedOnDaySumCorrected(Category $category, Carbon $date);
/**
* @param array $data
*