mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
More code for #159
This commit is contained in:
parent
23cc7be231
commit
885b56c465
@ -14,6 +14,7 @@ namespace FireflyIII\Http\Controllers\Popup;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Http\Controllers\Controller;
|
use FireflyIII\Http\Controllers\Controller;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||||
use FireflyIII\Support\Binder\AccountList;
|
use FireflyIII\Support\Binder\AccountList;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -37,13 +38,15 @@ class ReportController extends Controller
|
|||||||
{
|
{
|
||||||
$attributes = $request->get('attributes');
|
$attributes = $request->get('attributes');
|
||||||
$attributes = $this->parseAttributes($attributes);
|
$attributes = $this->parseAttributes($attributes);
|
||||||
$html = '';
|
|
||||||
switch ($attributes['location']) {
|
switch ($attributes['location']) {
|
||||||
default:
|
default:
|
||||||
throw new FireflyException('Firefly cannot handle "' . e($attributes['location']) . '" ');
|
throw new FireflyException('Firefly cannot handle "' . e($attributes['location']) . '" ');
|
||||||
case 'budget-spent-amount':
|
case 'budget-spent-amount':
|
||||||
$html = $this->budgetSpentAmount($attributes);
|
$html = $this->budgetSpentAmount($attributes);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'expense-entry':
|
||||||
|
$html = $this->expenseEntry($attributes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +56,8 @@ class ReportController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Returns all expenses inside the given budget for the given accounts.
|
||||||
|
*
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
@ -73,12 +78,30 @@ class ReportController extends Controller
|
|||||||
$journals = $repository->getExpenses($budget, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
$journals = $repository->getExpenses($budget, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$view = view('popup.report.budget-spent-amount', compact('journals'))->render();
|
$view = view('popup.report.budget-spent-amount', compact('journals'))->render();
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all the expenses that went to the given expense account.
|
||||||
|
*
|
||||||
|
* @param $attributes
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
private function expenseEntry($attributes)
|
||||||
|
{
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app('FireflyIII\Repositories\Account\AccountRepositoryInterface');
|
||||||
|
$account = $repository->find(intval($attributes['accountId']));
|
||||||
|
$journals = $repository->getExpensesByDestination($account, $attributes['accounts'], $attributes['startDate'], $attributes['endDate']);
|
||||||
|
$view = view('popup.report.expense-entry', compact('journals'))->render();
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
*
|
*
|
||||||
|
@ -33,7 +33,6 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
|
|
||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber'];
|
private $validFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber'];
|
||||||
|
|
||||||
@ -164,6 +163,31 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return $set;
|
return $set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of transactions TO the $account, not including transfers
|
||||||
|
* and/or expenses in the $accounts list.
|
||||||
|
*
|
||||||
|
* @param Account $account
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end)
|
||||||
|
{
|
||||||
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
|
$journals = $this->user->transactionjournals()
|
||||||
|
->expanded()
|
||||||
|
->before($end)
|
||||||
|
->where('destination_account.id', $account->id)
|
||||||
|
->whereIn('source_account.id', $ids)
|
||||||
|
->after($start)
|
||||||
|
->get(TransactionJournal::QUERYFIELDS);
|
||||||
|
|
||||||
|
return $journals;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
* @param Account $account
|
* @param Account $account
|
||||||
|
@ -20,6 +20,19 @@ use Illuminate\Support\Collection;
|
|||||||
interface AccountRepositoryInterface
|
interface AccountRepositoryInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of transactions TO the $account, not including transfers
|
||||||
|
* and/or expenses in the $accounts list.
|
||||||
|
*
|
||||||
|
* @param Account $account
|
||||||
|
* @param Collection $accounts
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getExpensesByDestination(Account $account, Collection $accounts, Carbon $start, Carbon $end);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $types
|
* @param array $types
|
||||||
*
|
*
|
||||||
|
3
public/css/firefly.css
vendored
3
public/css/firefly.css
vendored
@ -1,6 +1,9 @@
|
|||||||
#daterange {cursor:pointer;}
|
#daterange {cursor:pointer;}
|
||||||
.general-chart-error {height:30px;background:url('/images/error.png') no-repeat center center;}
|
.general-chart-error {height:30px;background:url('/images/error.png') no-repeat center center;}
|
||||||
.handle {cursor:move;}
|
.handle {cursor:move;}
|
||||||
|
body.waiting * {
|
||||||
|
cursor: progress;
|
||||||
|
}
|
||||||
|
|
||||||
.ui-sortable-placeholder {
|
.ui-sortable-placeholder {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
@ -25,24 +25,29 @@ function clickInfoButton(e) {
|
|||||||
var element = $(e.target);
|
var element = $(e.target);
|
||||||
var attributes = element.data();
|
var attributes = element.data();
|
||||||
|
|
||||||
|
// set wait cursor
|
||||||
|
$('body').addClass('waiting');
|
||||||
|
|
||||||
// add some more elements:
|
// add some more elements:
|
||||||
attributes.startDate = startDate;
|
attributes.startDate = startDate;
|
||||||
attributes.endDate = endDate;
|
attributes.endDate = endDate;
|
||||||
attributes.reportType = reportType;
|
attributes.reportType = reportType;
|
||||||
attributes.accounts = accountIds;
|
attributes.accounts = accountIds;
|
||||||
|
|
||||||
console.log(attributes);
|
|
||||||
$.getJSON('popup/report', {attributes: attributes}).success(respondInfoButton).fail(errorInfoButton);
|
$.getJSON('popup/report', {attributes: attributes}).success(respondInfoButton).fail(errorInfoButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorInfoButton(data) {
|
function errorInfoButton(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
console.log(data);
|
// remove wait cursor
|
||||||
|
$('body').removeClass('waiting');
|
||||||
|
alert('Apologies. The requested data is not (yet) available.');
|
||||||
}
|
}
|
||||||
|
|
||||||
function respondInfoButton(data) {
|
function respondInfoButton(data) {
|
||||||
"use strict";
|
"use strict";
|
||||||
console.log(123);
|
// remove wait cursor
|
||||||
|
$('body').removeClass('waiting');
|
||||||
$('#defaultModal').empty().html(data.html);
|
$('#defaultModal').empty().html(data.html);
|
||||||
$('#defaultModal').modal('show');
|
$('#defaultModal').modal('show');
|
||||||
|
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'close'|_ }}"><span aria-hidden="true">×</span></button>
|
<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'close'|_ }}"><span aria-hidden="true">×</span></button>
|
||||||
<h4 class="modal-title" id="testTriggerLabel">{{ 'budget_spent_amount'|_ }}</h4>
|
<h4 class="modal-title" id="budgetSpentAmountLabel">{{ 'budget_spent_amount'|_ }}</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
{% include 'popup/list/journals.twig' %}
|
{% include 'popup/list/journals.twig' %}
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'close'|_ }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
15
resources/views/popup/report/expense-entry.twig
Normal file
15
resources/views/popup/report/expense-entry.twig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!-- Modal dialog to show budget 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">{{ 'expense_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>
|
@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'close'|_ }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user