mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Category information. #159
This commit is contained in:
parent
03691c81c2
commit
622a97c8d8
@ -16,6 +16,7 @@ use FireflyIII\Exceptions\FireflyException;
|
|||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
|
use FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface;
|
||||||
use FireflyIII\Support\Binder\AccountList;
|
use FireflyIII\Support\Binder\AccountList;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
@ -51,6 +52,9 @@ class ReportController extends Controller
|
|||||||
case 'income-entry':
|
case 'income-entry':
|
||||||
$html = $this->incomeEntry($attributes);
|
$html = $this->incomeEntry($attributes);
|
||||||
break;
|
break;
|
||||||
|
case 'category-entry':
|
||||||
|
$html = $this->categoryEntry($attributes);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json(['html' => $html]);
|
return Response::json(['html' => $html]);
|
||||||
@ -87,20 +91,20 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all the incomes that went to the given asset account.
|
* Returns all expenses in category in range.
|
||||||
*
|
*
|
||||||
* @param $attributes
|
* @param $attributes
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
private function incomeEntry($attributes)
|
private function categoryEntry($attributes)
|
||||||
{
|
{
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var SingleCategoryRepositoryInterface $repository */
|
||||||
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
$repository = app('FireflyIII\Repositories\Category\SingleCategoryRepositoryInterface');
|
||||||
$account = $repository->find(intval($attributes['accountId']));
|
$category = $repository->find(intval($attributes['categoryId']));
|
||||||
$journals = $repository->getIncomeByDestination($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
$journals = $repository->getJournalsForAccountsInRange($category, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
$view = view('popup.report.income-entry', compact('journals'))->render();
|
$view = view('popup.report.category-entry', compact('journals'))->render();
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
@ -124,6 +128,25 @@ class ReportController extends Controller
|
|||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the incomes that went to the given asset account.
|
||||||
|
*
|
||||||
|
* @param $attributes
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
private function incomeEntry($attributes)
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
$account = $repository->find(intval($attributes['accountId']));
|
||||||
|
$journals = $repository->getIncomeByDestination($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
|
$view = view('popup.report.income-entry', compact('journals'))->render();
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
|
@ -153,6 +153,28 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Category $category
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
|
{
|
||||||
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
|
|
||||||
|
return $category->transactionjournals()
|
||||||
|
->after($start)
|
||||||
|
->before($end)
|
||||||
|
->expanded()
|
||||||
|
->whereIn('source_account.id', $ids)
|
||||||
|
->whereNotIn('destination_account.id', $ids)
|
||||||
|
->get(TransactionJournal::QUERYFIELDS);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
* @param int $page
|
* @param int $page
|
||||||
@ -171,9 +193,6 @@ class SingleCategoryRepository extends ComponentRepository implements SingleCate
|
|||||||
->expanded()
|
->expanded()
|
||||||
->take(50)
|
->take(50)
|
||||||
->offset($offset)
|
->offset($offset)
|
||||||
->orderBy('transaction_journals.date', 'DESC')
|
|
||||||
->orderBy('transaction_journals.order', 'ASC')
|
|
||||||
->orderBy('transaction_journals.id', 'DESC')
|
|
||||||
->get(TransactionJournal::QUERYFIELDS);
|
->get(TransactionJournal::QUERYFIELDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,16 @@ interface SingleCategoryRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getJournals(Category $category, $page);
|
public function getJournals(Category $category, $page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Category $category
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getJournalsForAccountsInRange(Category $category, Collection $accounts, Carbon $start, Carbon $end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Category $category
|
* @param Category $category
|
||||||
|
15
resources/views/popup/report/category-entry.twig
Normal file
15
resources/views/popup/report/category-entry.twig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!-- Modal dialog to show category expenses -->
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'close'|_ }}"><span aria-hidden="true">×</span></button>
|
||||||
|
<h4 class="modal-title" id="expenseEntryTitle">{{ 'category_entry'|_ }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
{% include 'popup/list/journals.twig' %}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'close'|_ }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,4 +1,4 @@
|
|||||||
<!-- Modal dialog to show budget expenses -->
|
<!-- Modal dialog to show expenses to an account -->
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- Modal dialog to show budget expenses -->
|
<!-- Modal dialog to show incomes to an account -->
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
Loading…
Reference in New Issue
Block a user