mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 19:35:16 +00:00
chore: reformat code.
This commit is contained in:
@@ -70,7 +70,7 @@ class BulkController extends Controller
|
||||
*
|
||||
* TODO user wont be able to tell if the journal is part of a split.
|
||||
*
|
||||
* @param array $journals
|
||||
* @param array $journals
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ class BulkController extends Controller
|
||||
/**
|
||||
* Update all journals.
|
||||
*
|
||||
* @param BulkEditJournalRequest $request
|
||||
* @param BulkEditJournalRequest $request
|
||||
*
|
||||
* @return Application|RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -135,9 +135,9 @@ class BulkController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $ignoreUpdate
|
||||
* @param int $budgetId
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $ignoreUpdate
|
||||
* @param int $budgetId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -153,27 +153,9 @@ class BulkController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $ignoreUpdate
|
||||
* @param string $category
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function updateJournalCategory(TransactionJournal $journal, bool $ignoreUpdate, string $category): bool
|
||||
{
|
||||
if (true === $ignoreUpdate) {
|
||||
return false;
|
||||
}
|
||||
Log::debug(sprintf('Set budget to %s', $category));
|
||||
$this->repository->updateCategory($journal, $category);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $action
|
||||
* @param array $tags
|
||||
* @param TransactionJournal $journal
|
||||
* @param string $action
|
||||
* @param array $tags
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
@@ -191,4 +173,22 @@ class BulkController extends Controller
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param bool $ignoreUpdate
|
||||
* @param string $category
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function updateJournalCategory(TransactionJournal $journal, bool $ignoreUpdate, string $category): bool
|
||||
{
|
||||
if (true === $ignoreUpdate) {
|
||||
return false;
|
||||
}
|
||||
Log::debug(sprintf('Set budget to %s', $category));
|
||||
$this->repository->updateCategory($journal, $category);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -82,8 +82,8 @@ class ConvertController extends Controller
|
||||
/**
|
||||
* Show overview of a to be converted transaction.
|
||||
*
|
||||
* @param TransactionType $destinationType
|
||||
* @param TransactionGroup $group
|
||||
* @param TransactionType $destinationType
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return RedirectResponse|Redirector|Factory|View
|
||||
* @throws Exception
|
||||
@@ -104,7 +104,7 @@ class ConvertController extends Controller
|
||||
|
||||
$groupTitle = $group->title ?? $first->description;
|
||||
$groupArray = $transformer->transformObject($group);
|
||||
$subTitle = (string)trans('firefly.convert_to_'.$destinationType->type, ['description' => $groupTitle]);
|
||||
$subTitle = (string)trans('firefly.convert_to_' . $destinationType->type, ['description' => $groupTitle]);
|
||||
$subTitleIcon = 'fa-exchange';
|
||||
|
||||
// get a list of asset accounts and liabilities and stuff, in various combinations:
|
||||
@@ -120,7 +120,7 @@ class ConvertController extends Controller
|
||||
|
||||
if ($sourceType->type === $destinationType->type) { // cannot convert to its own type.
|
||||
Log::debug('This is already a transaction of the expected type..');
|
||||
session()->flash('info', (string)trans('firefly.convert_is_already_type_'.$destinationType->type));
|
||||
session()->flash('info', (string)trans('firefly.convert_is_already_type_' . $destinationType->type));
|
||||
|
||||
return redirect(route('transactions.show', [$group->id]));
|
||||
}
|
||||
@@ -144,12 +144,139 @@ class ConvertController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getValidDepositSources(): array
|
||||
{
|
||||
// make repositories
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$accountList = $this->accountRepository
|
||||
->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||
$name = $account->name;
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
}
|
||||
|
||||
// maybe it's a liability thing:
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'l_' . $account->accountType->type;
|
||||
}
|
||||
if (AccountType::CASH === $account->accountType->type) {
|
||||
$role = 'cash_account';
|
||||
$name = sprintf('(%s)', trans('firefly.cash'));
|
||||
}
|
||||
if (AccountType::REVENUE === $account->accountType->type) {
|
||||
$role = 'revenue_account';
|
||||
}
|
||||
|
||||
$key = (string)trans('firefly.opt_group_' . $role);
|
||||
$grouped[$key][$account->id] = $name;
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getValidWithdrawalDests(): array
|
||||
{
|
||||
// make repositories
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType(
|
||||
[AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]
|
||||
);
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||
$name = $account->name;
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
}
|
||||
|
||||
// maybe it's a liability thing:
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'l_' . $account->accountType->type;
|
||||
}
|
||||
if (AccountType::CASH === $account->accountType->type) {
|
||||
$role = 'cash_account';
|
||||
$name = sprintf('(%s)', trans('firefly.cash'));
|
||||
}
|
||||
if (AccountType::EXPENSE === $account->accountType->type) {
|
||||
$role = 'expense_account';
|
||||
}
|
||||
|
||||
$key = (string)trans('firefly.opt_group_' . $role);
|
||||
$grouped[$key][$account->id] = $name;
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getLiabilities(): array
|
||||
{
|
||||
// make repositories
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = app('steam')->balance($account, today());
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = 'l_' . $account->accountType->type;
|
||||
$key = (string)trans('firefly.opt_group_' . $role);
|
||||
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getAssetAccounts(): array
|
||||
{
|
||||
// make repositories
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = app('steam')->balance($account, today());
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
}
|
||||
|
||||
$key = (string)trans('firefly.opt_group_' . $role);
|
||||
$grouped[$key][$account->id] = $account->name . ' (' . app('amount')->formatAnything($currency, $balance, false) . ')';
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the conversion.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param TransactionType $destinationType
|
||||
* @param TransactionGroup $group
|
||||
* @param Request $request
|
||||
* @param TransactionType $destinationType
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*
|
||||
@@ -175,16 +302,16 @@ class ConvertController extends Controller
|
||||
// correct transfers:
|
||||
$group->refresh();
|
||||
|
||||
session()->flash('success', (string)trans('firefly.converted_to_'.$destinationType->type));
|
||||
session()->flash('success', (string)trans('firefly.converted_to_' . $destinationType->type));
|
||||
event(new UpdatedTransactionGroup($group, true, true));
|
||||
|
||||
return redirect(route('transactions.show', [$group->id]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param TransactionType $transactionType
|
||||
* @param array $data
|
||||
* @param TransactionJournal $journal
|
||||
* @param TransactionType $transactionType
|
||||
* @param array $data
|
||||
*
|
||||
* @return TransactionJournal
|
||||
* @throws FireflyException
|
||||
@@ -234,131 +361,4 @@ class ConvertController extends Controller
|
||||
|
||||
return $journal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getAssetAccounts(): array
|
||||
{
|
||||
// make repositories
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType([AccountType::ASSET]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = app('steam')->balance($account, today());
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
}
|
||||
|
||||
$key = (string)trans('firefly.opt_group_'.$role);
|
||||
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
private function getLiabilities(): array
|
||||
{
|
||||
// make repositories
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$balance = app('steam')->balance($account, today());
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $defaultCurrency;
|
||||
$role = 'l_'.$account->accountType->type;
|
||||
$key = (string)trans('firefly.opt_group_'.$role);
|
||||
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getValidDepositSources(): array
|
||||
{
|
||||
// make repositories
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$accountList = $this->accountRepository
|
||||
->getActiveAccountsByType([AccountType::REVENUE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||
$name = $account->name;
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
}
|
||||
|
||||
// maybe it's a liability thing:
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'l_'.$account->accountType->type;
|
||||
}
|
||||
if (AccountType::CASH === $account->accountType->type) {
|
||||
$role = 'cash_account';
|
||||
$name = sprintf('(%s)', trans('firefly.cash'));
|
||||
}
|
||||
if (AccountType::REVENUE === $account->accountType->type) {
|
||||
$role = 'revenue_account';
|
||||
}
|
||||
|
||||
$key = (string)trans('firefly.opt_group_'.$role);
|
||||
$grouped[$key][$account->id] = $name;
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getValidWithdrawalDests(): array
|
||||
{
|
||||
// make repositories
|
||||
$liabilityTypes = [AccountType::MORTGAGE, AccountType::DEBT, AccountType::CREDITCARD, AccountType::LOAN];
|
||||
$accountList = $this->accountRepository->getActiveAccountsByType(
|
||||
[AccountType::EXPENSE, AccountType::CASH, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]
|
||||
);
|
||||
$grouped = [];
|
||||
// group accounts:
|
||||
/** @var Account $account */
|
||||
foreach ($accountList as $account) {
|
||||
$role = (string)$this->accountRepository->getMetaValue($account, 'account_role');
|
||||
$name = $account->name;
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
}
|
||||
|
||||
// maybe it's a liability thing:
|
||||
if (in_array($account->accountType->type, $liabilityTypes, true)) {
|
||||
$role = 'l_'.$account->accountType->type;
|
||||
}
|
||||
if (AccountType::CASH === $account->accountType->type) {
|
||||
$role = 'cash_account';
|
||||
$name = sprintf('(%s)', trans('firefly.cash'));
|
||||
}
|
||||
if (AccountType::EXPENSE === $account->accountType->type) {
|
||||
$role = 'expense_account';
|
||||
}
|
||||
|
||||
$key = (string)trans('firefly.opt_group_'.$role);
|
||||
$grouped[$key][$account->id] = $name;
|
||||
}
|
||||
|
||||
return $grouped;
|
||||
}
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ class CreateController extends Controller
|
||||
/**
|
||||
* Create a new transaction group.
|
||||
*
|
||||
* @param string|null $objectType
|
||||
* @param string|null $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
|
@@ -69,7 +69,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Shows the form that allows a user to delete a transaction journal.
|
||||
*
|
||||
* @param TransactionGroup $group
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return Factory|View|Redirector|RedirectResponse
|
||||
*/
|
||||
@@ -86,7 +86,7 @@ class DeleteController extends Controller
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||
$subTitle = (string)trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);
|
||||
$subTitle = (string)trans('firefly.delete_' . $objectType, ['description' => $group->title ?? $journal->description]);
|
||||
$previous = app('steam')->getSafePreviousUrl();
|
||||
// put previous url in session
|
||||
Log::debug('Will try to remember previous URL');
|
||||
@@ -98,7 +98,7 @@ class DeleteController extends Controller
|
||||
/**
|
||||
* Actually destroys the journal.
|
||||
*
|
||||
* @param TransactionGroup $group
|
||||
* @param TransactionGroup $group
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
@@ -114,7 +114,7 @@ class DeleteController extends Controller
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);
|
||||
session()->flash('success', (string)trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));
|
||||
session()->flash('success', (string)trans('firefly.deleted_' . strtolower($objectType), ['description' => $group->title ?? $journal->description]));
|
||||
|
||||
// grab asset account(s) from group:
|
||||
$accounts = [];
|
||||
|
@@ -57,7 +57,7 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionGroup $transactionGroup
|
||||
* @param TransactionGroup $transactionGroup
|
||||
*
|
||||
* @return Factory|View|RedirectResponse|Redirector
|
||||
*/
|
||||
|
@@ -69,10 +69,10 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Index for a range of transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @param Carbon|null $start
|
||||
* @param Carbon|null $end
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
@@ -85,8 +85,8 @@ class IndexController extends Controller
|
||||
$objectType = 'transfer';
|
||||
}
|
||||
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
|
||||
$types = config('firefly.transactionTypesByType.' . $objectType);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
if (null === $start) {
|
||||
@@ -130,8 +130,8 @@ class IndexController extends Controller
|
||||
/**
|
||||
* Index for ALL transactions.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
* @param Request $request
|
||||
* @param string $objectType
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws ContainerExceptionInterface
|
||||
@@ -139,8 +139,8 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function indexAll(Request $request, string $objectType)
|
||||
{
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||
$subTitleIcon = config('firefly.transactionIconsByType.' . $objectType);
|
||||
$types = config('firefly.transactionTypesByType.' . $objectType);
|
||||
$page = (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$path = route('transactions.index.all', [$objectType]);
|
||||
@@ -148,7 +148,7 @@ class IndexController extends Controller
|
||||
$start = null === $first ? new Carbon() : $first->date;
|
||||
$last = $this->repository->getLast();
|
||||
$end = $last ? $last->date : today(config('app.timezone'));
|
||||
$subTitle = (string)trans('firefly.all_'.$objectType);
|
||||
$subTitle = (string)trans('firefly.all_' . $objectType);
|
||||
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
|
@@ -69,7 +69,7 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Delete a link.
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Actually destroy it.
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -100,7 +100,7 @@ class LinkController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
@@ -114,8 +114,8 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Store a new link.
|
||||
*
|
||||
* @param JournalLinkRequest $request
|
||||
* @param TransactionJournal $journal
|
||||
* @param JournalLinkRequest $request
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
@@ -154,7 +154,7 @@ class LinkController extends Controller
|
||||
/**
|
||||
* Switch link from A <> B to B <> A.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Request $request
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function switchLink(Request $request)
|
||||
|
@@ -74,7 +74,7 @@ class MassController extends Controller
|
||||
/**
|
||||
* Mass delete transactions.
|
||||
*
|
||||
* @param array $journals
|
||||
* @param array $journals
|
||||
*
|
||||
* @return IlluminateView
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ class MassController extends Controller
|
||||
/**
|
||||
* Do the mass delete.
|
||||
*
|
||||
* @param MassDeleteJournalRequest $request
|
||||
* @param MassDeleteJournalRequest $request
|
||||
*
|
||||
* @return Application|Redirector|RedirectResponse
|
||||
*
|
||||
@@ -127,7 +127,7 @@ class MassController extends Controller
|
||||
/**
|
||||
* Mass edit of journals.
|
||||
*
|
||||
* @param array $journals
|
||||
* @param array $journals
|
||||
*
|
||||
* @return IlluminateView
|
||||
*/
|
||||
@@ -165,7 +165,7 @@ class MassController extends Controller
|
||||
/**
|
||||
* Mass update of journals.
|
||||
*
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param MassEditJournalRequest $request
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
@@ -197,75 +197,8 @@ class MassController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param string $key
|
||||
*
|
||||
* @return Carbon|null
|
||||
*/
|
||||
private function getDateFromRequest(MassEditJournalRequest $request, int $journalId, string $key): ?Carbon
|
||||
{
|
||||
$value = $request->get($key);
|
||||
if (!is_array($value)) {
|
||||
return null;
|
||||
}
|
||||
if (!array_key_exists($journalId, $value)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
$carbon = Carbon::parse($value[$journalId]);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$e->getMessage();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $carbon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param string $string
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int
|
||||
{
|
||||
$value = $request->get($string);
|
||||
if (!is_array($value)) {
|
||||
return null;
|
||||
}
|
||||
if (!array_key_exists($journalId, $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int)$value[$journalId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param string $string
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function getStringFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?string
|
||||
{
|
||||
$value = $request->get($string);
|
||||
if (!is_array($value)) {
|
||||
return null;
|
||||
}
|
||||
if (!array_key_exists($journalId, $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)$value[$journalId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $journalId
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param MassEditJournalRequest $request
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -299,4 +232,71 @@ class MassController extends Controller
|
||||
// trigger rules
|
||||
event(new UpdatedTransactionGroup($journal->transactionGroup, true, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param string $key
|
||||
*
|
||||
* @return Carbon|null
|
||||
*/
|
||||
private function getDateFromRequest(MassEditJournalRequest $request, int $journalId, string $key): ?Carbon
|
||||
{
|
||||
$value = $request->get($key);
|
||||
if (!is_array($value)) {
|
||||
return null;
|
||||
}
|
||||
if (!array_key_exists($journalId, $value)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
$carbon = Carbon::parse($value[$journalId]);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$e->getMessage();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $carbon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param string $string
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
private function getStringFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?string
|
||||
{
|
||||
$value = $request->get($string);
|
||||
if (!is_array($value)) {
|
||||
return null;
|
||||
}
|
||||
if (!array_key_exists($journalId, $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)$value[$journalId];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MassEditJournalRequest $request
|
||||
* @param int $journalId
|
||||
* @param string $string
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int
|
||||
{
|
||||
$value = $request->get($string);
|
||||
if (!is_array($value)) {
|
||||
return null;
|
||||
}
|
||||
if (!array_key_exists($journalId, $value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int)$value[$journalId];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user