mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-02-05 03:49:04 +00:00
🤖 Auto commit for release 'develop' on 2026-01-23
This commit is contained in:
@@ -122,26 +122,26 @@ class MassController extends Controller
|
||||
*/
|
||||
public function edit(array $journals): IlluminateView
|
||||
{
|
||||
$subTitle = (string) trans('firefly.mass_edit_journals');
|
||||
$subTitle = (string) trans('firefly.mass_edit_journals');
|
||||
|
||||
/** @var AccountRepositoryInterface $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
|
||||
// valid withdrawal sources:
|
||||
$array = array_keys(config(sprintf('firefly.source_dests.%s', TransactionTypeEnum::WITHDRAWAL->value)));
|
||||
$withdrawalSources = $accountRepository->getAccountsByType($array);
|
||||
$array = array_keys(config(sprintf('firefly.source_dests.%s', TransactionTypeEnum::WITHDRAWAL->value)));
|
||||
$withdrawalSources = $accountRepository->getAccountsByType($array);
|
||||
|
||||
// valid deposit destinations:
|
||||
$array = config(sprintf('firefly.source_dests.%s.%s', TransactionTypeEnum::DEPOSIT->value, AccountTypeEnum::REVENUE->value));
|
||||
$depositDestinations = $accountRepository->getAccountsByType($array);
|
||||
|
||||
/** @var BudgetRepositoryInterface $budgetRepository */
|
||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
$budgets = $budgetRepository->getBudgets();
|
||||
$budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
$budgets = $budgetRepository->getBudgets();
|
||||
|
||||
// reverse amounts
|
||||
foreach ($journals as $index => $journal) {
|
||||
$journals[$index]['amount'] = Steam::bcround(Steam::positive($journal['amount']), $journal['currency_decimal_places']);
|
||||
$journals[$index]['amount'] = Steam::bcround(Steam::positive($journal['amount']), $journal['currency_decimal_places']);
|
||||
$journals[$index]['foreign_amount'] = null === $journal['foreign_amount'] ? null : Steam::positive($journal['foreign_amount']);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class MassController extends Controller
|
||||
'subTitle' => $subTitle,
|
||||
'withdrawalSources' => $withdrawalSources,
|
||||
'depositDestinations' => $depositDestinations,
|
||||
'budgets' => $budgets
|
||||
'budgets' => $budgets,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ class MassController extends Controller
|
||||
// TODO this is a weird error, should be caught.
|
||||
throw new FireflyException('This is not an array.');
|
||||
}
|
||||
$count = 0;
|
||||
$count = 0;
|
||||
|
||||
/** @var string $journalId */
|
||||
foreach ($journalIds as $journalId) {
|
||||
@@ -194,15 +194,15 @@ class MassController extends Controller
|
||||
*/
|
||||
private function updateJournal(int $journalId, MassEditJournalRequest $request): void
|
||||
{
|
||||
$journal = $this->repository->find($journalId);
|
||||
$journal = $this->repository->find($journalId);
|
||||
if (!$journal instanceof TransactionJournal) {
|
||||
throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));
|
||||
}
|
||||
$service = app(JournalUpdateService::class);
|
||||
$service = app(JournalUpdateService::class);
|
||||
// for each field, call the update service.
|
||||
$service->setTransactionJournal($journal);
|
||||
|
||||
$data = [
|
||||
$data = [
|
||||
'date' => $this->getDateFromRequest($request, $journal->id, 'date'),
|
||||
'description' => $this->getStringFromRequest($request, $journal->id, 'description'),
|
||||
'source_id' => $this->getIntFromRequest($request, $journal->id, 'source_id'),
|
||||
@@ -212,7 +212,7 @@ class MassController extends Controller
|
||||
'budget_id' => $this->getIntFromRequest($request, $journal->id, 'budget_id'),
|
||||
'category_name' => $this->getStringFromRequest($request, $journal->id, 'category'),
|
||||
'amount' => $this->getStringFromRequest($request, $journal->id, 'amount'),
|
||||
'foreign_amount' => $this->getStringFromRequest($request, $journal->id, 'foreign_amount')
|
||||
'foreign_amount' => $this->getStringFromRequest($request, $journal->id, 'foreign_amount'),
|
||||
];
|
||||
Log::debug(sprintf('Will update journal #%d with data.', $journal->id), $data);
|
||||
|
||||
@@ -224,7 +224,7 @@ class MassController extends Controller
|
||||
event(new UpdatedTransactionGroup($journal->transactionGroup, true, true, $runRecalculations));
|
||||
}
|
||||
|
||||
private function getDateFromRequest(MassEditJournalRequest $request, int $journalId, string $key): null|Carbon
|
||||
private function getDateFromRequest(MassEditJournalRequest $request, int $journalId, string $key): ?Carbon
|
||||
{
|
||||
$value = $request->get($key);
|
||||
if (!is_array($value)) {
|
||||
@@ -246,7 +246,7 @@ class MassController extends Controller
|
||||
return $carbon;
|
||||
}
|
||||
|
||||
private function getStringFromRequest(MassEditJournalRequest $request, int $journalId, string $string): null|string
|
||||
private function getStringFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?string
|
||||
{
|
||||
$value = $request->get($string);
|
||||
if (!is_array($value)) {
|
||||
@@ -259,7 +259,7 @@ class MassController extends Controller
|
||||
return (string) $value[$journalId];
|
||||
}
|
||||
|
||||
private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): null|int
|
||||
private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int
|
||||
{
|
||||
$value = $request->get($string);
|
||||
if (!is_array($value)) {
|
||||
|
||||
Reference in New Issue
Block a user