mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fine tuning split edit screens.
This commit is contained in:
@@ -126,7 +126,6 @@ class SplitController extends Controller
|
||||
*/
|
||||
public function update(Request $request, JournalRepositoryInterface $repository, TransactionJournal $journal)
|
||||
{
|
||||
|
||||
$data = $this->arrayFromInput($request, $journal);
|
||||
$journal = $repository->updateSplitJournal($journal, $data);
|
||||
|
||||
@@ -170,7 +169,7 @@ class SplitController extends Controller
|
||||
'journal_source_account_id' => $request->get('journal_source_account_id'),
|
||||
'journal_source_account_name' => $request->get('journal_source_account_name'),
|
||||
'journal_destination_account_id' => $request->get('journal_destination_account_id'),
|
||||
'transaction_currency_id' => $request->get('transaction_currency_id'),
|
||||
'currency_id' => $request->get('currency_id'),
|
||||
'what' => $request->get('what'),
|
||||
'date' => $request->get('date'),
|
||||
// all custom fields:
|
||||
@@ -208,7 +207,7 @@ class SplitController extends Controller
|
||||
'journal_source_account_id' => $request->old('journal_source_account_id', $sourceAccounts->first()->id),
|
||||
'journal_source_account_name' => $request->old('journal_source_account_name', $sourceAccounts->first()->name),
|
||||
'journal_destination_account_id' => $request->old('journal_destination_account_id', $destinationAccounts->first()->id),
|
||||
'transaction_currency_id' => $request->old('transaction_currency_id', $journal->transaction_currency_id),
|
||||
'currency_id' => $request->old('currency_id', $journal->transaction_currency_id),
|
||||
'destinationAccounts' => $destinationAccounts,
|
||||
'what' => strtolower(TransactionJournal::transactionTypeStr($journal)),
|
||||
'date' => $request->old('date', $journal->date),
|
||||
@@ -277,7 +276,6 @@ class SplitController extends Controller
|
||||
'budget_id' => isset($transaction['budget_id']) ? intval($transaction['budget_id']) : 0,
|
||||
'category' => $transaction['category'] ?? '',
|
||||
'user' => auth()->user()->id, // needed for accounts.
|
||||
'piggy_bank_id' => $transaction['piggy_bank_id'] ?? 0,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -264,10 +264,11 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
public function updateSplitJournal(TransactionJournal $journal, array $data): TransactionJournal
|
||||
{
|
||||
// update actual journal:
|
||||
$journal->transaction_currency_id = $data['transaction_currency_id'];
|
||||
$journal->transaction_currency_id = $data['currency_id'];
|
||||
$journal->description = $data['journal_description'];
|
||||
$journal->date = $data['date'];
|
||||
|
||||
$journal->save();
|
||||
|
||||
// unlink all categories:
|
||||
$journal->categories()->detach();
|
||||
$journal->budgets()->detach();
|
||||
@@ -330,6 +331,9 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
case strtolower(TransactionType::WITHDRAWAL):
|
||||
$transaction['source_account_id'] = intval($data['journal_source_account_id']);
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($data['what']) {
|
||||
case strtolower(TransactionType::TRANSFER):
|
||||
case strtolower(TransactionType::DEPOSIT):
|
||||
$transaction['destination_account_id'] = intval($data['journal_destination_account_id']);
|
||||
@@ -379,6 +383,7 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
'source' => null,
|
||||
'destination' => null,
|
||||
];
|
||||
|
||||
Log::debug(sprintf('Going to store accounts for type %s', $type->type));
|
||||
switch ($type->type) {
|
||||
case TransactionType::WITHDRAWAL:
|
||||
@@ -390,7 +395,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
|
||||
break;
|
||||
case TransactionType::TRANSFER:
|
||||
|
||||
$accounts['source'] = Account::where('user_id', $this->user->id)->where('id', $data['source_account_id'])->first();
|
||||
$accounts['destination'] = Account::where('user_id', $this->user->id)->where('id', $data['destination_account_id'])->first();
|
||||
break;
|
||||
@@ -536,11 +540,6 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
$this->storeCategoryWithTransaction($two, $transaction['category']);
|
||||
$this->storeBudgetWithTransaction($two, $transaction['budget_id']);
|
||||
|
||||
if ($transaction['piggy_bank_id'] > 0) {
|
||||
$transaction['date'] = $journal->date->format('Y-m-d');
|
||||
event(new TransactionStored($transaction));
|
||||
}
|
||||
|
||||
return new Collection([$one, $two]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user