mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-25 06:51:08 +00:00
Added temporary debug entries.
This commit is contained in:
@@ -16,6 +16,7 @@ use Preferences;
|
|||||||
use Response;
|
use Response;
|
||||||
use Session;
|
use Session;
|
||||||
use Steam;
|
use Steam;
|
||||||
|
use Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JsonController
|
* Class JsonController
|
||||||
@@ -38,8 +39,6 @@ class JsonController extends Controller
|
|||||||
case 'in':
|
case 'in':
|
||||||
$box = Input::get('box');
|
$box = Input::get('box');
|
||||||
$set = $reportQuery->incomeByPeriod($start, $end, true);
|
$set = $reportQuery->incomeByPeriod($start, $end, true);
|
||||||
|
|
||||||
|
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$amount += $entry->queryAmount;
|
$amount += $entry->queryAmount;
|
||||||
}
|
}
|
||||||
@@ -57,6 +56,7 @@ class JsonController extends Controller
|
|||||||
$box = 'bills-unpaid';
|
$box = 'bills-unpaid';
|
||||||
$bills = $repository->getActiveBills();
|
$bills = $repository->getActiveBills();
|
||||||
$unpaid = new Collection; // bills
|
$unpaid = new Collection; // bills
|
||||||
|
Log::debug('UnpaidBox: Unpaid box');
|
||||||
|
|
||||||
/** @var Bill $bill */
|
/** @var Bill $bill */
|
||||||
foreach ($bills as $bill) {
|
foreach ($bills as $bill) {
|
||||||
@@ -85,16 +85,22 @@ class JsonController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// loop unpaid:
|
// loop unpaid:
|
||||||
|
|
||||||
/** @var Bill $entry */
|
/** @var Bill $entry */
|
||||||
foreach ($unpaid as $entry) {
|
foreach ($unpaid as $entry) {
|
||||||
$amount += ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
$current = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
|
||||||
|
$amount += $current;
|
||||||
|
Log::debug('UnpaidBox: '.$entry[0]->name.': '.$current);
|
||||||
|
Log::debug('UnpaidBox: Total is now: ' . $amount);
|
||||||
}
|
}
|
||||||
|
Log::debug('UnpaidBox: Total is final: ' . $amount);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'bills-paid':
|
case 'bills-paid':
|
||||||
$box = 'bills-paid';
|
$box = 'bills-paid';
|
||||||
// these two functions are the same as the chart TODO
|
// these two functions are the same as the chart TODO
|
||||||
$bills = Auth::user()->bills()->where('active', 1)->get();
|
$bills = Auth::user()->bills()->where('active', 1)->get();
|
||||||
|
Log::debug('PaidBox: Paid box');
|
||||||
|
|
||||||
/** @var Bill $bill */
|
/** @var Bill $bill */
|
||||||
foreach ($bills as $bill) {
|
foreach ($bills as $bill) {
|
||||||
@@ -106,11 +112,15 @@ class JsonController extends Controller
|
|||||||
if ($count != 0) {
|
if ($count != 0) {
|
||||||
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
||||||
$amount += $journal->amount;
|
$amount += $journal->amount;
|
||||||
|
Log::debug('PaidBox: Journal for bill "'.$bill->name.'": ' . $journal->amount);
|
||||||
|
Log::debug('PaidBox: Total is now: ' . $amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Log::debug('PaidBox: Doing ccs now.');
|
||||||
/**
|
/**
|
||||||
* Find credit card accounts and possibly unpaid credit card bills.
|
* Find credit card accounts and possibly unpaid credit card bills.
|
||||||
*/
|
*/
|
||||||
@@ -129,6 +139,7 @@ class JsonController extends Controller
|
|||||||
foreach ($creditCards as $creditCard) {
|
foreach ($creditCards as $creditCard) {
|
||||||
$balance = Steam::balance($creditCard, null, true);
|
$balance = Steam::balance($creditCard, null, true);
|
||||||
if ($balance == 0) {
|
if ($balance == 0) {
|
||||||
|
Log::debug('PaidBox: Balance for '.$creditCard->name.' is zero.');
|
||||||
// find a transfer TO the credit card which should account for
|
// find a transfer TO the credit card which should account for
|
||||||
// anything paid. If not, the CC is not yet used.
|
// anything paid. If not, the CC is not yet used.
|
||||||
$transactions = $creditCard->transactions()
|
$transactions = $creditCard->transactions()
|
||||||
@@ -139,14 +150,19 @@ class JsonController extends Controller
|
|||||||
foreach ($transactions as $transaction) {
|
foreach ($transactions as $transaction) {
|
||||||
$journal = $transaction->transactionJournal;
|
$journal = $transaction->transactionJournal;
|
||||||
if ($journal->transactionType->type == 'Transfer') {
|
if ($journal->transactionType->type == 'Transfer') {
|
||||||
|
Log::debug('PaidBox: Found the transfer! Amount: ' . floatval($transaction->amount));
|
||||||
$amount += floatval($transaction->amount);
|
$amount += floatval($transaction->amount);
|
||||||
|
Log::debug('PaidBox: Total is now: ' . $amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log::debug('PaidBox: Total is: ' . $amount);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return Response::json(['box' => $box, 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]);
|
return Response::json(['box' => $box, 'amount' => Amount::format($amount, false), 'amount_raw' => $amount]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user