mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #3475
This commit is contained in:
parent
1a17d5be39
commit
ed0f04d644
@ -215,47 +215,6 @@ class BoxController extends Controller
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bills to pay and paid.
|
||||
*
|
||||
* @param BillRepositoryInterface $repository
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function bills(BillRepositoryInterface $repository): JsonResponse
|
||||
{
|
||||
/** @var Carbon $start */
|
||||
$start = session('start', Carbon::now()->startOfMonth());
|
||||
/** @var Carbon $end */
|
||||
$end = session('end', Carbon::now()->endOfMonth());
|
||||
|
||||
$cache = new CacheProperties;
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('box-bills');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
/*
|
||||
* Since both this method and the chart use the exact same data, we can suffice
|
||||
* with calling the one method in the bill repository that will get this amount.
|
||||
*/
|
||||
$paidAmount = bcmul($repository->getBillsPaidInRange($start, $end), '-1');
|
||||
$unpaidAmount = $repository->getBillsUnpaidInRange($start, $end); // will be a positive amount.
|
||||
$currency = app('amount')->getDefaultCurrency();
|
||||
|
||||
$return = [
|
||||
'paid' => app('amount')->formatAnything($currency, $paidAmount, false),
|
||||
'unpaid' => app('amount')->formatAnything($currency, $unpaidAmount, false),
|
||||
];
|
||||
$cache->store($return);
|
||||
|
||||
return response()->json($return);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Total user net worth.
|
||||
*
|
||||
|
32
public/v1/js/ff/index.js
vendored
32
public/v1/js/ff/index.js
vendored
@ -83,11 +83,11 @@ function getAvailableBox() {
|
||||
$('#box-left-to-spend').html(data.left_to_spend);
|
||||
$('#box-left-per-day').html(data.left_per_day);
|
||||
}
|
||||
if(1=== data.display) {
|
||||
if (1 === data.display) {
|
||||
$('#box-left-to-spend').html(data.left_to_spend);
|
||||
$('#box-left-per-day').html(data.left_per_day);
|
||||
}
|
||||
if(2=== data.display) {
|
||||
if (2 === data.display) {
|
||||
$('#box-left-to-spend').html(data.spent_total);
|
||||
$('#box-left-per-day').html(data.spent_per_day);
|
||||
}
|
||||
@ -100,9 +100,31 @@ function getAvailableBox() {
|
||||
function getBillsBox() {
|
||||
// box-bills-unpaid
|
||||
// box-bills-paid
|
||||
$.getJSON('json/box/bills').done(function (data) {
|
||||
$('#box-bills-paid').html(data.paid);
|
||||
$('#box-bills-unpaid').html(data.unpaid);
|
||||
|
||||
// get summary.
|
||||
|
||||
$.getJSON('api/v1/summary/basic?start=' + sessionStart + '&end=' + sessionEnd).done(function (data) {
|
||||
var key;
|
||||
var unpaid = [];
|
||||
var paid = [];
|
||||
for (key in data) {
|
||||
var row = data[key];
|
||||
//console.log(key);
|
||||
if (key.substr(0, 16) === 'bills-unpaid-in-') {
|
||||
// only when less than 3.
|
||||
if (unpaid.length < 3) {
|
||||
unpaid.push(data[key].value_parsed);
|
||||
}
|
||||
}
|
||||
if (key.substr(0, 14) === 'bills-paid-in-') {
|
||||
// only when less than 5.
|
||||
if (paid.length < 3) {
|
||||
paid.push(data[key].value_parsed);
|
||||
}
|
||||
}
|
||||
}
|
||||
$('#box-bills-unpaid').html(unpaid.join(', '));
|
||||
$('#box-bills-paid').html(paid.join(', '));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,6 @@ Route::group(
|
||||
|
||||
// boxes
|
||||
Route::get('box/balance', ['uses' => 'Json\BoxController@balance', 'as' => 'box.balance']);
|
||||
Route::get('box/bills', ['uses' => 'Json\BoxController@bills', 'as' => 'box.bills']);
|
||||
Route::get('box/available', ['uses' => 'Json\BoxController@available', 'as' => 'box.available']);
|
||||
Route::get('box/net-worth', ['uses' => 'Json\BoxController@netWorth', 'as' => 'box.net-worth']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user