mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Make sure the user can create liabilities in the "credit" direction with the right transactions.
This commit is contained in:
@@ -125,7 +125,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
$query = $this->user->accounts()->where('iban', '!=', '')->whereNotNull('iban');
|
||||
|
||||
if (0!==count($types)) {
|
||||
if (0 !== count($types)) {
|
||||
$query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
@@ -747,4 +747,21 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
return $service->update($account, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getCreditTransactionGroup(Account $account): ?TransactionGroup
|
||||
{
|
||||
$journal = TransactionJournal
|
||||
::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||
->where('transactions.account_id', $account->id)
|
||||
->transactionTypes([TransactionType::LIABILITY_CREDIT])
|
||||
->first(['transaction_journals.*']);
|
||||
if (null === $journal) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $journal->transactionGroup;
|
||||
}
|
||||
}
|
||||
|
@@ -198,6 +198,13 @@ interface AccountRepositoryInterface
|
||||
*/
|
||||
public function getOpeningBalanceDate(Account $account): ?string;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return TransactionGroup|null
|
||||
*/
|
||||
public function getCreditTransactionGroup(Account $account): ?TransactionGroup;
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
|
Reference in New Issue
Block a user