mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-29 12:14:34 -06:00
This should fix a bug in split expenses.
This commit is contained in:
parent
7e3f9048fe
commit
0db9852769
@ -197,7 +197,7 @@ class TransactionController extends Controller
|
||||
*/
|
||||
public function index(Request $request, JournalRepositoryInterface $repository, string $what)
|
||||
{
|
||||
$pageSize = Preferences::get('transactionPageSize', 50)->data;
|
||||
$pageSize = intval(Preferences::get('transactionPageSize', 50)->data);
|
||||
$subTitleIcon = config('firefly.transactionIconsByWhat.' . $what);
|
||||
$types = config('firefly.transactionTypesByWhat.' . $what);
|
||||
$subTitle = trans('firefly.title_' . $what);
|
||||
@ -274,6 +274,8 @@ class TransactionController extends Controller
|
||||
// store the journal only, flash the rest.
|
||||
if ($doSplit) {
|
||||
$journal = $repository->storeJournal($journalData);
|
||||
$journal->completed = false;
|
||||
$journal->save();
|
||||
|
||||
// store attachments:
|
||||
$att->saveAttachmentsForModel($journal);
|
||||
|
@ -568,6 +568,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$join->on('source.transaction_journal_id', '=', 'transaction_journals.id')->where('source.amount', '<', 0);
|
||||
}
|
||||
);
|
||||
|
||||
$query->leftJoin(
|
||||
'transactions as destination', function (JoinClause $join) {
|
||||
$join->on('destination.transaction_journal_id', '=', 'transaction_journals.id')->where('destination.amount', '>', 0);
|
||||
@ -575,15 +576,22 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
);
|
||||
$query->whereIn('source.account_id', $accountIds);
|
||||
$query->whereNotIn('destination.account_id', $accountIds);
|
||||
$query->whereNull('source.deleted_at');
|
||||
$query->whereNull('destination.deleted_at');
|
||||
$query->distinct();
|
||||
|
||||
}
|
||||
// remove group by
|
||||
$query->getQuery()->getQuery()->groups = null;
|
||||
$ids = $query->get(['transaction_journals.id'])->pluck('id')->toArray();
|
||||
|
||||
// that should do it:
|
||||
$sum = strval($query->sum('source.amount'));
|
||||
$sum = $this->user->transactions()
|
||||
->whereIn('transaction_journal_id', $ids)
|
||||
->where('amount', '<', '0')
|
||||
->whereNull('transactions.deleted_at')
|
||||
->sum('amount');
|
||||
|
||||
return $sum;
|
||||
return strval($sum);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -144,6 +144,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
{
|
||||
$offset = ($page - 1) * $pageSize;
|
||||
$query = $this->user->transactionJournals()->expanded()->sortCorrectly();
|
||||
$query->where('transaction_journals.completed', 1);
|
||||
if (count($types) > 0) {
|
||||
$query->transactionTypes($types);
|
||||
}
|
||||
@ -166,6 +167,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
public function getJournalsInRange(Collection $accounts, Carbon $start, Carbon $end): Collection
|
||||
{
|
||||
$query = $this->user->transactionJournals()->expanded()->sortCorrectly();
|
||||
$query->where('transaction_journals.completed', 1);
|
||||
$query->before($end);
|
||||
$query->after($start);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user