mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 10:16:49 +00:00
Fixed a bug where getAmountAttribute would interfere with queries that contained a "amount"-field.
This commit is contained in:
@@ -40,9 +40,9 @@ class JsonController extends Controller
|
|||||||
->after($start)
|
->after($start)
|
||||||
->transactionTypes(['Deposit'])
|
->transactionTypes(['Deposit'])
|
||||||
->where('transactions.amount', '>', 0)
|
->where('transactions.amount', '>', 0)
|
||||||
->first([DB::Raw('SUM(transactions.amount) as `amount`')]);
|
->first([DB::Raw('SUM(transactions.amount) as `totalAmount`')]);
|
||||||
if (!is_null($in)) {
|
if (!is_null($in)) {
|
||||||
$amount = floatval($in->amount);
|
$amount = floatval($in->totalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -50,13 +50,13 @@ class JsonController extends Controller
|
|||||||
$box = Input::get('box');
|
$box = Input::get('box');
|
||||||
$in = Auth::user()->transactionjournals()
|
$in = Auth::user()->transactionjournals()
|
||||||
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->before($end)
|
//->before($end)
|
||||||
->after($start)
|
// ->after($start)
|
||||||
->transactionTypes(['Withdrawal'])
|
->transactionTypes(['Withdrawal'])
|
||||||
->where('transactions.amount', '>', 0)
|
->where('transactions.amount', '>', 0)
|
||||||
->first([DB::Raw('SUM(transactions.amount) as `amount`')]);
|
->first([DB::Raw('SUM(transactions.amount) as `totalAmount`')]);
|
||||||
if (!is_null($in)) {
|
if (!is_null($in)) {
|
||||||
$amount = floatval($in->amount);
|
$amount = floatval($in->totalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -116,13 +116,7 @@ class JsonController extends Controller
|
|||||||
$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) {
|
||||||
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
$journal = $bill->transactionjournals()->with('transactions')->before($range['end'])->after($range['start'])->first();
|
||||||
$currentAmount = 0;
|
$amount += $journal->amount;
|
||||||
foreach ($journal->transactions as $t) {
|
|
||||||
if (floatval($t->amount) > 0) {
|
|
||||||
$currentAmount = floatval($t->amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$amount += $currentAmount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user