mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 22:48:18 +00:00
Code cleanup.
This commit is contained in:
@@ -37,7 +37,7 @@ class JsonController extends Controller
|
|||||||
$amount = 0;
|
$amount = 0;
|
||||||
|
|
||||||
// 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 = $repository->getActiveBills();
|
||||||
|
|
||||||
/** @var Bill $bill */
|
/** @var Bill $bill */
|
||||||
foreach ($bills as $bill) {
|
foreach ($bills as $bill) {
|
||||||
@@ -45,15 +45,14 @@ class JsonController extends Controller
|
|||||||
|
|
||||||
foreach ($ranges as $range) {
|
foreach ($ranges as $range) {
|
||||||
// paid a bill in this range?
|
// paid a bill in this range?
|
||||||
$count = $bill->transactionjournals()->before($range['end'])->after($range['start'])->count();
|
$journals = $repository->getJournalsInRange($bill, $range['start'], $range['end']);
|
||||||
if ($count != 0) {
|
foreach ($journals as $journal) {
|
||||||
// TODO this only gets the first match, may be more than one.
|
|
||||||
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
|
||||||
$amount += $journal->amount;
|
$amount += $journal->amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
unset($journals, $journal);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,17 +66,11 @@ class JsonController extends Controller
|
|||||||
if ($balance == 0) {
|
if ($balance == 0) {
|
||||||
// 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()
|
$journals = $accountRepository->getTransfersInRange($creditCard, $start, $end);
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
foreach ($journals as $journal) {
|
||||||
->before($end)->after($start)->get();
|
$amount += floatval($journal->amount);
|
||||||
if ($transactions->count() > 0) {
|
|
||||||
/** @var Transaction $transaction */
|
|
||||||
foreach ($transactions as $transaction) {
|
|
||||||
$journal = $transaction->transactionJournal;
|
|
||||||
if ($journal->transactionType->type == 'Transfer') {
|
|
||||||
$amount += floatval($transaction->amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user