mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Expand budget pages to work with new date view.
This commit is contained in:
@@ -75,11 +75,9 @@ class BudgetController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function amount(Request $request, Budget $budget)
|
public function amount(Request $request, Budget $budget)
|
||||||
{
|
{
|
||||||
$amount = intval($request->get('amount'));
|
$amount = intval($request->get('amount'));
|
||||||
/** @var Carbon $start */
|
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
|
||||||
$start = session('start', Carbon::now()->startOfMonth());
|
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
|
||||||
/** @var Carbon $end */
|
|
||||||
$end = session('end', Carbon::now()->endOfMonth());
|
|
||||||
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
|
$budgetLimit = $this->repository->updateLimitAmount($budget, $start, $end, $amount);
|
||||||
if ($amount === 0) {
|
if ($amount === 0) {
|
||||||
$budgetLimit = null;
|
$budgetLimit = null;
|
||||||
@@ -243,7 +241,7 @@ class BudgetController extends Controller
|
|||||||
compact(
|
compact(
|
||||||
'available', 'currentMonth', 'next', 'nextText', 'prev', 'prevText',
|
'available', 'currentMonth', 'next', 'nextText', 'prev', 'prevText',
|
||||||
'periodStart', 'periodEnd', 'budgetInformation', 'inactive', 'budgets',
|
'periodStart', 'periodEnd', 'budgetInformation', 'inactive', 'budgets',
|
||||||
'spent', 'budgeted', 'previousLoop', 'nextLoop', 'start'
|
'spent', 'budgeted', 'previousLoop', 'nextLoop', 'start', 'end'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -313,15 +311,15 @@ class BudgetController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function postUpdateIncome(BudgetIncomeRequest $request)
|
public function postUpdateIncome(BudgetIncomeRequest $request)
|
||||||
{
|
{
|
||||||
$start = session('start', new Carbon);
|
$start = Carbon::createFromFormat('Y-m-d', $request->string('start'));
|
||||||
$end = session('end', new Carbon);
|
$end = Carbon::createFromFormat('Y-m-d', $request->string('end'));
|
||||||
$defaultCurrency = Amount::getDefaultCurrency();
|
$defaultCurrency = Amount::getDefaultCurrency();
|
||||||
$amount = $request->get('amount');
|
$amount = $request->get('amount');
|
||||||
|
|
||||||
$this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount);
|
$this->repository->setAvailableBudget($defaultCurrency, $start, $end, $amount);
|
||||||
Preferences::mark();
|
Preferences::mark();
|
||||||
|
|
||||||
return redirect(route('budgets.index'));
|
return redirect(route('budgets.index',[$start->format('Y-m-d')]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -443,17 +441,17 @@ class BudgetController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return View
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function updateIncome()
|
public function updateIncome(Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
$start = session('start', new Carbon);
|
|
||||||
$end = session('end', new Carbon);
|
|
||||||
$defaultCurrency = Amount::getDefaultCurrency();
|
$defaultCurrency = Amount::getDefaultCurrency();
|
||||||
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
|
$available = $this->repository->getAvailableBudget($defaultCurrency, $start, $end);
|
||||||
$available = round($available, $defaultCurrency->decimal_places);
|
$available = round($available, $defaultCurrency->decimal_places);
|
||||||
|
|
||||||
|
|
||||||
return view('budgets.income', compact('available', 'start', 'end'));
|
return view('budgets.income', compact('available', 'start', 'end'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,6 +37,8 @@ class BudgetIncomeRequest extends Request
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'amount' => 'numeric|required|min:0',
|
'amount' => 'numeric|required|min:0',
|
||||||
|
'start' => 'required|date|before:end',
|
||||||
|
'end' => 'required|date|after:start',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -89,7 +89,8 @@ function updateBudgetedAmounts(e) {
|
|||||||
drawBudgetedBar();
|
drawBudgetedBar();
|
||||||
|
|
||||||
// send a post to Firefly to update the amount:
|
// send a post to Firefly to update the amount:
|
||||||
$.post('budgets/amount/' + id, {amount: value}).done(function (data) {
|
var newUri = budgetAmountUri.replace("REPLACE", id);
|
||||||
|
$.post(newUri, {amount: value,start: periodStart, end: periodEnd}).done(function (data) {
|
||||||
// update the link if relevant:
|
// update the link if relevant:
|
||||||
if (data.repetition > 0) {
|
if (data.repetition > 0) {
|
||||||
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition);
|
$('.budget-link[data-id="' + id + '"]').attr('href', 'budgets/show/' + id + '/' + data.repetition);
|
||||||
@@ -120,8 +121,8 @@ $(function () {
|
|||||||
$('.selectPeriod').change(function (e) {
|
$('.selectPeriod').change(function (e) {
|
||||||
var sel = $(e.target).val();
|
var sel = $(e.target).val();
|
||||||
if (sel !== "x") {
|
if (sel !== "x") {
|
||||||
var newURI = budgetIndexURI.replace("REPLACE", sel);
|
var newUri = budgetIndexUri.replace("REPLACE", sel);
|
||||||
window.location.assign(newURI);
|
window.location.assign(newUri);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ $(function () {
|
|||||||
|
|
||||||
function updateIncome() {
|
function updateIncome() {
|
||||||
"use strict";
|
"use strict";
|
||||||
$('#defaultModal').empty().load('budgets/income', function () {
|
$('#defaultModal').empty().load(updateIncomeUri, function () {
|
||||||
$('#defaultModal').modal('show');
|
$('#defaultModal').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
<form style="display: inline;" id="income" action="{{ route('budgets.income.post') }}" method="POST">
|
<form style="display: inline;" id="income" action="{{ route('budgets.income.post') }}" method="POST">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
|
||||||
|
<input type="hidden" name="start" value="{{ start.format('Y-m-d') }}"/>
|
||||||
|
<input type="hidden" name="end" value="{{ end.format('Y-m-d') }}"/>
|
||||||
|
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
<div class="input-group-addon">{{ getCurrencySymbol()|raw }}</div>
|
||||||
|
@@ -229,7 +229,11 @@
|
|||||||
// budgeted data:
|
// budgeted data:
|
||||||
var budgeted = {{ budgeted }};
|
var budgeted = {{ budgeted }};
|
||||||
var available = {{ available }};
|
var available = {{ available }};
|
||||||
var budgetIndexURI = "{{ route('budgets.index','REPLACE') }}";
|
var budgetIndexUri = "{{ route('budgets.index','REPLACE') }}";
|
||||||
|
var budgetAmountUri = "{{ route('budgets.amount','REPLACE') }}";
|
||||||
|
var updateIncomeUri = "{{ route('budgets.income',[start.format('Y-m-d'),end.format('Y-m-d')]) }}";
|
||||||
|
var periodStart = "{{ start.format('Y-m-d') }}";
|
||||||
|
var periodEnd = "{{ end.format('Y-m-d') }}";
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="js/lib/bootstrap-sortable.js"></script>
|
<script type="text/javascript" src="js/lib/bootstrap-sortable.js"></script>
|
||||||
<script type="text/javascript" src="js/ff/budgets/index.js"></script>
|
<script type="text/javascript" src="js/ff/budgets/index.js"></script>
|
||||||
|
@@ -136,7 +136,7 @@ Route::group(
|
|||||||
*/
|
*/
|
||||||
Route::group(
|
Route::group(
|
||||||
['middleware' => 'user-full-auth', 'prefix' => 'budgets', 'as' => 'budgets.'], function () {
|
['middleware' => 'user-full-auth', 'prefix' => 'budgets', 'as' => 'budgets.'], function () {
|
||||||
Route::get('income', ['uses' => 'BudgetController@updateIncome', 'as' => 'income']);
|
Route::get('income/{start_date}/{end_date}', ['uses' => 'BudgetController@updateIncome', 'as' => 'income']);
|
||||||
Route::get('create', ['uses' => 'BudgetController@create', 'as' => 'create']);
|
Route::get('create', ['uses' => 'BudgetController@create', 'as' => 'create']);
|
||||||
Route::get('edit/{budget}', ['uses' => 'BudgetController@edit', 'as' => 'edit']);
|
Route::get('edit/{budget}', ['uses' => 'BudgetController@edit', 'as' => 'edit']);
|
||||||
Route::get('delete/{budget}', ['uses' => 'BudgetController@delete', 'as' => 'delete']);
|
Route::get('delete/{budget}', ['uses' => 'BudgetController@delete', 'as' => 'delete']);
|
||||||
@@ -403,6 +403,7 @@ Route::group(
|
|||||||
Route::post('bank/{bank}/prerequisites', ['uses' => 'Import\BankController@postPrerequisites', 'as' => 'bank.prerequisites.post']);
|
Route::post('bank/{bank}/prerequisites', ['uses' => 'Import\BankController@postPrerequisites', 'as' => 'bank.prerequisites.post']);
|
||||||
|
|
||||||
Route::get('bank/{bank}/form', ['uses' => 'Import\BankController@form', 'as' => 'bank.form']);
|
Route::get('bank/{bank}/form', ['uses' => 'Import\BankController@form', 'as' => 'bank.form']);
|
||||||
|
Route::post('bank/{bank}/form', ['uses' => 'Import\BankController@postForm', 'as' => 'bank.form.post']);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user