Auto commit for release 'v6.1.17' on 2024-06-15

This commit is contained in:
github-actions
2024-06-15 13:07:23 +02:00
parent d426e09474
commit 2d7d05e985
10 changed files with 432 additions and 340 deletions

View File

@@ -86,16 +86,16 @@ class ConvertController extends Controller
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer = app(TransactionGroupTransformer::class);
/** @var TransactionJournal $first */
$first = $group->transactionJournals()->first();
$sourceType = $first->transactionType;
$first = $group->transactionJournals()->first();
$sourceType = $first->transactionType;
$groupTitle = $group->title ?? $first->description;
$groupArray = $transformer->transformObject($group);
$subTitle = (string) trans('firefly.convert_to_' . $destinationType->type, ['description' => $groupTitle]);
$subTitleIcon = 'fa-exchange';
$groupTitle = $group->title ?? $first->description;
$groupArray = $transformer->transformObject($group);
$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:
$validDepositSources = $this->getValidDepositSources();
@@ -104,13 +104,13 @@ class ConvertController extends Controller
$assets = $this->getAssetAccounts();
// old input variables:
$preFilled = [
$preFilled = [
'source_name' => old('source_name'),
];
if ($sourceType->type === $destinationType->type) { // cannot convert to its own type.
app('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]));
}
@@ -139,21 +139,22 @@ class ConvertController extends Controller
// 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]);
->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;
$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;
$role = 'l_'.$account->accountType->type;
}
if (AccountType::CASH === $account->accountType->type) {
$role = 'cash_account';
@@ -163,7 +164,7 @@ class ConvertController extends Controller
$role = 'revenue_account';
}
$key = (string) trans('firefly.opt_group_' . $role);
$key = (string) trans('firefly.opt_group_'.$role);
$grouped[$key][$account->id] = $name;
}
@@ -182,15 +183,15 @@ class ConvertController extends Controller
// group accounts:
/** @var Account $account */
foreach ($accountList as $account) {
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
$name = $account->name;
$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;
$role = 'l_'.$account->accountType->type;
}
if (AccountType::CASH === $account->accountType->type) {
$role = 'cash_account';
@@ -200,7 +201,7 @@ class ConvertController extends Controller
$role = 'expense_account';
}
$key = (string) trans('firefly.opt_group_' . $role);
$key = (string) trans('firefly.opt_group_'.$role);
$grouped[$key][$account->id] = $name;
}
@@ -222,9 +223,9 @@ class ConvertController extends Controller
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) . ')';
$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;
@@ -243,15 +244,15 @@ class ConvertController extends Controller
// 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');
$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) . ')';
$key = (string) trans('firefly.opt_group_'.$role);
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
}
return $grouped;
@@ -283,7 +284,7 @@ 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]));
@@ -295,14 +296,14 @@ class ConvertController extends Controller
private function convertJournal(TransactionJournal $journal, TransactionType $transactionType, array $data): TransactionJournal
{
/** @var AccountValidator $validator */
$validator = app(AccountValidator::class);
$validator = app(AccountValidator::class);
$validator->setUser(auth()->user());
$validator->setTransactionType($transactionType->type);
$sourceId = $data['source_id'][$journal->id] ?? null;
$sourceName = $data['source_name'][$journal->id] ?? null;
$destinationId = $data['destination_id'][$journal->id] ?? null;
$destinationName = $data['destination_name'][$journal->id] ?? null;
$sourceId = $data['source_id'][$journal->id] ?? null;
$sourceName = $data['source_name'][$journal->id] ?? null;
$destinationId = $data['destination_id'][$journal->id] ?? null;
$destinationName = $data['destination_name'][$journal->id] ?? null;
// double check it's not an empty string.
$sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId;
@@ -321,7 +322,7 @@ class ConvertController extends Controller
// TODO typeOverrule: the account validator may have another opinion on the transaction type.
$update = [
$update = [
'source_id' => $sourceId,
'source_name' => $sourceName,
'destination_id' => $destinationId,
@@ -342,9 +343,8 @@ class ConvertController extends Controller
}
}
/** @var JournalUpdateService $service */
$service = app(JournalUpdateService::class);
$service = app(JournalUpdateService::class);
$service->setTransactionJournal($journal);
$service->setData($update);
$service->update();