From f727a38b69a9cf8e303d6381fdfdd44916c6bada Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 16:47:50 +0100 Subject: [PATCH] Auto commit for release 'develop' on 2025-01-01 --- .../Actions/UpdatePiggybank.php | 18 +-- resources/assets/v1/src/locales/nl.json | 2 +- resources/lang/en_US/rules.php | 104 +++++++++--------- 3 files changed, 63 insertions(+), 61 deletions(-) diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.php index b2774a5630..bb3ff0fc84 100644 --- a/app/TransactionRules/Actions/UpdatePiggybank.php +++ b/app/TransactionRules/Actions/UpdatePiggybank.php @@ -58,12 +58,12 @@ class UpdatePiggybank implements ActionInterface // refresh the transaction type. /** @var User $user */ - $user = User::find($journal['user_id']); + $user = User::find($journal['user_id']); /** @var TransactionJournal $journalObj */ - $journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']); + $journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']); - $piggyBank = $this->findPiggyBank($user, $actionValue); + $piggyBank = $this->findPiggyBank($user, $actionValue); if (null === $piggyBank) { Log::info( sprintf('No piggy bank named "%s", cant execute action #%d of rule #%d', $actionValue, $this->action->id, $this->action->rule_id) @@ -78,7 +78,7 @@ class UpdatePiggybank implements ActionInterface /** @var Transaction $destination */ $destination = $journalObj->transactions()->where('amount', '>', 0)->first(); - $accounts = $this->getAccounts($journalObj); + $accounts = $this->getAccounts($journalObj); Log::debug(sprintf('Source account is #%d: "%s"', $accounts['source']->id, $accounts['source']->name)); Log::debug(sprintf('Destination account is #%d: "%s"', $accounts['destination']->id, $accounts['source']->name)); @@ -130,6 +130,7 @@ class UpdatePiggybank implements ActionInterface if ($this->isConnected($piggyBank, $accounts['source']) && $this->isConnected($piggyBank, $accounts['destination'])) { Log::info(sprintf('Piggy bank is linked to BOTH source ("#%d") and destination ("#%d"), so no action will be taken.', $accounts['source']->id, $accounts['destination']->id)); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_link_piggy', ['name' => $actionValue]))); + return false; } Log::info(sprintf('Piggy bank is not linked to source ("#%d") or destination ("#%d"), so no action will be taken.', $accounts['source']->id, $accounts['destination']->id)); @@ -143,6 +144,7 @@ class UpdatePiggybank implements ActionInterface /** @var PiggyBankRepositoryInterface $repository */ $repository = app(PiggyBankRepositoryInterface::class); $repository->setUser($user); + return $repository->findByName($name); } @@ -152,11 +154,11 @@ class UpdatePiggybank implements ActionInterface $repository->setUser($journal->user); // how much can we remove from this piggy bank? - $toRemove = $repository->getCurrentAmount($piggyBank, $account); + $toRemove = $repository->getCurrentAmount($piggyBank, $account); Log::debug(sprintf('Amount is %s, max to remove is %s', $amount, $toRemove)); // if $amount is bigger than $toRemove, shrink it. - $amount = -1 === bccomp($amount, $toRemove) ? $amount : $toRemove; + $amount = -1 === bccomp($amount, $toRemove) ? $amount : $toRemove; Log::debug(sprintf('Amount is now %s', $amount)); // if amount is zero, stop. @@ -185,7 +187,7 @@ class UpdatePiggybank implements ActionInterface // how much can we add to the piggy bank? if (0 !== bccomp($piggyBank->target_amount, '0')) { - $toAdd = bcsub($piggyBank->target_amount, $repository->getCurrentAmount($piggyBank, $account)); + $toAdd = bcsub($piggyBank->target_amount, $repository->getCurrentAmount($piggyBank, $account)); Log::debug(sprintf('Max amount to add to piggy bank is %s, amount is %s', $toAdd, $amount)); // update amount to fit: @@ -234,7 +236,7 @@ class UpdatePiggybank implements ActionInterface } } Log::debug(sprintf('Piggy bank is not connected to account #%d "%s"', $account->id, $account->name)); + return false; } - } diff --git a/resources/assets/v1/src/locales/nl.json b/resources/assets/v1/src/locales/nl.json index b4dc805008..73720c2720 100644 --- a/resources/assets/v1/src/locales/nl.json +++ b/resources/assets/v1/src/locales/nl.json @@ -21,7 +21,7 @@ "apply_rules_checkbox": "Regels toepassen", "fire_webhooks_checkbox": "Webhooks starten", "no_budget_pointer": "Je hebt nog geen budgetten. Maak er een aantal op de budgetten<\/a>-pagina. Met budgetten kan je je uitgaven beter bijhouden.", - "no_bill_pointer": "You seem to have no subscription yet. You should create some on the subscription<\/a>-page. Subscriptions can help you keep track of expenses.", + "no_bill_pointer": "Je hebt nog geen abonnementen. Maak er een aantal op de abonnementenpagina<\/a>. Met abonnementen kan je uitgaven bijhouden.", "source_account": "Bronrekening", "hidden_fields_preferences": "Je kan meer transactieopties inschakelen in je instellingen<\/a>.", "destination_account": "Doelrekening", diff --git a/resources/lang/en_US/rules.php b/resources/lang/en_US/rules.php index 909f45cd7c..2012fa7c83 100644 --- a/resources/lang/en_US/rules.php +++ b/resources/lang/en_US/rules.php @@ -23,57 +23,57 @@ declare(strict_types=1); return [ - 'main_message' => 'Action ":action", present in rule ":rule", could not be applied to transaction #:group: :error', - 'find_or_create_tag_failed' => 'Could not find or create tag ":tag"', - 'tag_already_added' => 'Tag ":tag" is already linked to this transaction', - 'inspect_transaction' => 'Inspect transaction ":title" @ Firefly III', - 'inspect_rule' => 'Inspect rule ":title" @ Firefly III', - 'journal_other_user' => 'This transaction doesn\'t belong to the user', - 'no_such_journal' => 'This transaction doesn\'t exist', - 'journal_already_no_budget' => 'This transaction has no budget, so it cannot be removed', - 'journal_already_no_category' => 'This transaction had no category, so it cannot be removed', - 'journal_already_no_notes' => 'This transaction had no notes, so they cannot be removed', - 'journal_not_found' => 'Firefly III can\'t find the requested transaction', - 'split_group' => 'Firefly III cannot execute this action on a transaction with multiple splits', - 'is_already_withdrawal' => 'This transaction is already a withdrawal', - 'is_already_deposit' => 'This transaction is already a deposit', - 'is_already_transfer' => 'This transaction is already a transfer', - 'is_not_transfer' => 'This transaction is not a transfer', - 'complex_error' => 'Something complicated went wrong. Sorry about that. Please inspect the logs of Firefly III', - 'no_valid_opposing' => 'Conversion failed because there is no valid account named ":account"', - 'new_notes_empty' => 'The notes to be set are empty', - 'unsupported_transaction_type_withdrawal' => 'Firefly III cannot convert a ":type" to a withdrawal', - 'unsupported_transaction_type_deposit' => 'Firefly III cannot convert a ":type" to a deposit', - 'unsupported_transaction_type_transfer' => 'Firefly III cannot convert a ":type" to a transfer', - 'already_has_source_asset' => 'This transaction already has ":name" as the source asset account', - 'already_has_destination_asset' => 'This transaction already has ":name" as the destination asset account', - 'already_has_destination' => 'This transaction already has ":name" as the destination account', - 'already_has_source' => 'This transaction already has ":name" as the source account', - 'already_linked_to_subscription' => 'The transaction is already linked to subscription ":name"', - 'already_linked_to_category' => 'The transaction is already linked to category ":name"', - 'already_linked_to_budget' => 'The transaction is already linked to budget ":name"', - 'cannot_find_subscription' => 'Firefly III can\'t find subscription ":name"', - 'no_notes_to_move' => 'The transaction has no notes to move to the description field', - 'no_tags_to_remove' => 'The transaction has no tags to remove', - 'not_withdrawal' => 'The transaction is not a withdrawal', - 'not_deposit' => 'The transaction is not a deposit', - 'cannot_find_tag' => 'Firefly III can\'t find tag ":tag"', - 'cannot_find_asset' => 'Firefly III can\'t find asset account ":name"', - 'cannot_find_accounts' => 'Firefly III can\'t find the source or destination account', - 'cannot_find_source_transaction' => 'Firefly III can\'t find the source transaction', - 'cannot_find_destination_transaction' => 'Firefly III can\'t find the destination transaction', - 'cannot_find_source_transaction_account' => 'Firefly III can\'t find the source transaction account', - 'cannot_find_destination_transaction_account' => 'Firefly III can\'t find the destination transaction account', - 'cannot_find_piggy' => 'Firefly III can\'t find a piggy bank named ":name"', - 'no_link_piggy' => 'This transaction\'s accounts are not linked to the piggy bank, so no action will be taken', + 'main_message' => 'Action ":action", present in rule ":rule", could not be applied to transaction #:group: :error', + 'find_or_create_tag_failed' => 'Could not find or create tag ":tag"', + 'tag_already_added' => 'Tag ":tag" is already linked to this transaction', + 'inspect_transaction' => 'Inspect transaction ":title" @ Firefly III', + 'inspect_rule' => 'Inspect rule ":title" @ Firefly III', + 'journal_other_user' => 'This transaction doesn\'t belong to the user', + 'no_such_journal' => 'This transaction doesn\'t exist', + 'journal_already_no_budget' => 'This transaction has no budget, so it cannot be removed', + 'journal_already_no_category' => 'This transaction had no category, so it cannot be removed', + 'journal_already_no_notes' => 'This transaction had no notes, so they cannot be removed', + 'journal_not_found' => 'Firefly III can\'t find the requested transaction', + 'split_group' => 'Firefly III cannot execute this action on a transaction with multiple splits', + 'is_already_withdrawal' => 'This transaction is already a withdrawal', + 'is_already_deposit' => 'This transaction is already a deposit', + 'is_already_transfer' => 'This transaction is already a transfer', + 'is_not_transfer' => 'This transaction is not a transfer', + 'complex_error' => 'Something complicated went wrong. Sorry about that. Please inspect the logs of Firefly III', + 'no_valid_opposing' => 'Conversion failed because there is no valid account named ":account"', + 'new_notes_empty' => 'The notes to be set are empty', + 'unsupported_transaction_type_withdrawal' => 'Firefly III cannot convert a ":type" to a withdrawal', + 'unsupported_transaction_type_deposit' => 'Firefly III cannot convert a ":type" to a deposit', + 'unsupported_transaction_type_transfer' => 'Firefly III cannot convert a ":type" to a transfer', + 'already_has_source_asset' => 'This transaction already has ":name" as the source asset account', + 'already_has_destination_asset' => 'This transaction already has ":name" as the destination asset account', + 'already_has_destination' => 'This transaction already has ":name" as the destination account', + 'already_has_source' => 'This transaction already has ":name" as the source account', + 'already_linked_to_subscription' => 'The transaction is already linked to subscription ":name"', + 'already_linked_to_category' => 'The transaction is already linked to category ":name"', + 'already_linked_to_budget' => 'The transaction is already linked to budget ":name"', + 'cannot_find_subscription' => 'Firefly III can\'t find subscription ":name"', + 'no_notes_to_move' => 'The transaction has no notes to move to the description field', + 'no_tags_to_remove' => 'The transaction has no tags to remove', + 'not_withdrawal' => 'The transaction is not a withdrawal', + 'not_deposit' => 'The transaction is not a deposit', + 'cannot_find_tag' => 'Firefly III can\'t find tag ":tag"', + 'cannot_find_asset' => 'Firefly III can\'t find asset account ":name"', + 'cannot_find_accounts' => 'Firefly III can\'t find the source or destination account', + 'cannot_find_source_transaction' => 'Firefly III can\'t find the source transaction', + 'cannot_find_destination_transaction' => 'Firefly III can\'t find the destination transaction', + 'cannot_find_source_transaction_account' => 'Firefly III can\'t find the source transaction account', + 'cannot_find_destination_transaction_account' => 'Firefly III can\'t find the destination transaction account', + 'cannot_find_piggy' => 'Firefly III can\'t find a piggy bank named ":name"', + 'no_link_piggy' => 'This transaction\'s accounts are not linked to the piggy bank, so no action will be taken', 'both_link_piggy' => 'This transaction\'s accounts are both linked to the piggy bank, so no action will be taken', - 'cannot_unlink_tag' => 'Tag ":tag" isn\'t linked to this transaction', - 'cannot_find_budget' => 'Firefly III can\'t find budget ":name"', - 'cannot_find_category' => 'Firefly III can\'t find category ":name"', - 'cannot_set_budget' => 'Firefly III can\'t set budget ":name" to a transaction of type ":type"', - 'journal_invalid_amount' => 'Firefly III can\'t set amount ":amount" because it is not a valid number.', - 'cannot_remove_zero_piggy' => 'Cannot remove zero amount from piggy bank ":name"', - 'cannot_remove_from_piggy' => 'Cannot remove ":amount" from piggy bank ":name"', - 'cannot_add_zero_piggy' => 'Cannot add zero amount to piggy bank ":name"', - 'cannot_add_to_piggy' => 'Cannot add ":amount" to piggy bank ":name"', + 'cannot_unlink_tag' => 'Tag ":tag" isn\'t linked to this transaction', + 'cannot_find_budget' => 'Firefly III can\'t find budget ":name"', + 'cannot_find_category' => 'Firefly III can\'t find category ":name"', + 'cannot_set_budget' => 'Firefly III can\'t set budget ":name" to a transaction of type ":type"', + 'journal_invalid_amount' => 'Firefly III can\'t set amount ":amount" because it is not a valid number.', + 'cannot_remove_zero_piggy' => 'Cannot remove zero amount from piggy bank ":name"', + 'cannot_remove_from_piggy' => 'Cannot remove ":amount" from piggy bank ":name"', + 'cannot_add_zero_piggy' => 'Cannot add zero amount to piggy bank ":name"', + 'cannot_add_to_piggy' => 'Cannot add ":amount" to piggy bank ":name"', ];