mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Various optimisations.
This commit is contained in:
@@ -566,7 +566,6 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
);
|
||||
$journal->save();
|
||||
|
||||
|
||||
if ($data['openingBalance'] < 0) {
|
||||
$firstAccount = $opposing;
|
||||
$secondAccount = $account;
|
||||
@@ -578,26 +577,11 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$firstAmount = $data['openingBalance'];
|
||||
$secondAmount = $data['openingBalance'] * -1;
|
||||
}
|
||||
$one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]);
|
||||
$one->save();// first transaction: from
|
||||
|
||||
// first transaction: from
|
||||
$one = new Transaction(
|
||||
[
|
||||
'account_id' => $firstAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => $firstAmount
|
||||
]
|
||||
);
|
||||
$one->save();
|
||||
|
||||
// second transaction: to
|
||||
$two = new Transaction(
|
||||
[
|
||||
'account_id' => $secondAccount->id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'amount' => $secondAmount
|
||||
]
|
||||
);
|
||||
$two->save();
|
||||
$two = new Transaction(['account_id' => $secondAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $secondAmount]);
|
||||
$two->save(); // second transaction: to
|
||||
|
||||
return $journal;
|
||||
|
||||
@@ -606,6 +590,8 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param array $data
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
protected function updateMetadata(Account $account, array $data)
|
||||
{
|
||||
|
||||
@@ -115,14 +115,14 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $journalId
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date)
|
||||
public function getWithDate($journalId, Carbon $date)
|
||||
{
|
||||
return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d 00:00:00'))->first();
|
||||
return Auth::user()->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,12 +62,12 @@ interface JournalRepositoryInterface
|
||||
public function getTransactionType($type);
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param int $journalId
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return TransactionJournal
|
||||
*/
|
||||
public function getWithDate($id, Carbon $date);
|
||||
public function getWithDate($journalId, Carbon $date);
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
|
||||
Reference in New Issue
Block a user