From db5d94d95634886e66b8fb62a254f39e42248ede Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 10 Apr 2015 07:19:45 +0200 Subject: [PATCH] Added temporary debug entries. --- app/Http/Controllers/JsonController.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index effcee45e5..1e257eba0d 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -16,6 +16,7 @@ use Preferences; use Response; use Session; use Steam; +use Log; /** * Class JsonController @@ -38,8 +39,6 @@ class JsonController extends Controller case 'in': $box = Input::get('box'); $set = $reportQuery->incomeByPeriod($start, $end, true); - - foreach ($set as $entry) { $amount += $entry->queryAmount; } @@ -57,6 +56,7 @@ class JsonController extends Controller $box = 'bills-unpaid'; $bills = $repository->getActiveBills(); $unpaid = new Collection; // bills + Log::debug('UnpaidBox: Unpaid box'); /** @var Bill $bill */ foreach ($bills as $bill) { @@ -85,16 +85,22 @@ class JsonController extends Controller } } // loop unpaid: + /** @var Bill $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; case 'bills-paid': $box = 'bills-paid'; // these two functions are the same as the chart TODO $bills = Auth::user()->bills()->where('active', 1)->get(); + Log::debug('PaidBox: Paid box'); /** @var Bill $bill */ foreach ($bills as $bill) { @@ -106,11 +112,15 @@ class JsonController extends Controller if ($count != 0) { $journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first(); $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. */ @@ -129,6 +139,7 @@ class JsonController extends Controller foreach ($creditCards as $creditCard) { $balance = Steam::balance($creditCard, null, true); if ($balance == 0) { + Log::debug('PaidBox: Balance for '.$creditCard->name.' is zero.'); // find a transfer TO the credit card which should account for // anything paid. If not, the CC is not yet used. $transactions = $creditCard->transactions() @@ -139,14 +150,19 @@ class JsonController extends Controller foreach ($transactions as $transaction) { $journal = $transaction->transactionJournal; if ($journal->transactionType->type == 'Transfer') { + Log::debug('PaidBox: Found the transfer! 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]); }