Removed logging, found bug.

This commit is contained in:
James Cole 2015-04-10 07:29:36 +02:00
parent 4a95bdd8ba
commit d8d92f147f
2 changed files with 2 additions and 21 deletions

View File

@ -19,7 +19,6 @@ use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface; use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Grumpydictator\Gchart\GChart; use Grumpydictator\Gchart\GChart;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Navigation; use Navigation;
use Preferences; use Preferences;
use Response; use Response;
@ -299,10 +298,7 @@ class GoogleChartController extends Controller
$paidDescriptions[] = $entry->description; $paidDescriptions[] = $entry->description;
$paidAmount += floatval($entry->amount); $paidAmount += floatval($entry->amount);
Log::debug('PaidChart: ' . $entry->description . ' with amount ' . floatval($entry->amount));
Log::debug('PaidChart: total amount is now: ' . $paidAmount);
} }
Log::debug('PaidChart: total amount final: ' . $paidAmount);
// loop unpaid: // loop unpaid:
/** @var Bill $entry */ /** @var Bill $entry */
@ -311,11 +307,8 @@ class GoogleChartController extends Controller
$amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; $amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
$unpaidDescriptions[] = $description; $unpaidDescriptions[] = $description;
$unpaidAmount += $amount; $unpaidAmount += $amount;
Log::debug('UnpaidChart: ' . $description . ' with amount ' . $amount);
Log::debug('UnpaidChart: total is now: ' . $unpaidAmount);
unset($amount, $description); unset($amount, $description);
} }
Log::debug('UnpaidChart: total is final: ' . $unpaidAmount);
$chart->addRow('Unpaid: ' . join(', ', $unpaidDescriptions), $unpaidAmount); $chart->addRow('Unpaid: ' . join(', ', $unpaidDescriptions), $unpaidAmount);
$chart->addRow('Paid: ' . join(', ', $paidDescriptions), $paidAmount); $chart->addRow('Paid: ' . join(', ', $paidDescriptions), $paidAmount);

View File

@ -16,7 +16,6 @@ use Preferences;
use Response; use Response;
use Session; use Session;
use Steam; use Steam;
use Log;
/** /**
* Class JsonController * Class JsonController
@ -56,7 +55,6 @@ 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) {
@ -90,17 +88,13 @@ class JsonController extends Controller
foreach ($unpaid as $entry) { foreach ($unpaid as $entry) {
$current = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; $current = ($entry[0]->amount_max + $entry[0]->amount_min) / 2;
$amount += $current; $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) {
@ -110,17 +104,15 @@ class JsonController extends Controller
// paid a bill in this range? // paid a bill in this range?
$count = $bill->transactionjournals()->before($range['end'])->after($range['start'])->count(); $count = $bill->transactionjournals()->before($range['end'])->after($range['start'])->count();
if ($count != 0) { if ($count != 0) {
// TODO this only gets the first match, may be more than one.
$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.
*/ */
@ -139,7 +131,6 @@ 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()
@ -150,16 +141,13 @@ 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;
break;
} }