mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-10 22:52:10 +00:00
Compare commits
2 Commits
b9c93091cd
...
354bbebbee
Author | SHA1 | Date | |
---|---|---|---|
|
354bbebbee | ||
|
a70fab1e87 |
@@ -331,9 +331,7 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->statistics->filter(
|
return $this->statistics->filter(
|
||||||
function (PeriodStatistic $statistic) use ($start, $end, $type) {
|
fn(PeriodStatistic $statistic) => $statistic->start->eq($start) && $statistic->end->eq($end) && $statistic->type === $type
|
||||||
return $statistic->start->eq($start) && $statistic->end->eq($end) && $statistic->type === $type;
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,9 +344,7 @@ trait PeriodOverview
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->statistics->filter(
|
return $this->statistics->filter(
|
||||||
function (PeriodStatistic $statistic) use ($start, $end, $prefix) {
|
fn(PeriodStatistic $statistic) => $statistic->start->eq($start) && $statistic->end->eq($end) && str_starts_with($statistic->type, $prefix)
|
||||||
return $statistic->start->eq($start) && $statistic->end->eq($end) && str_starts_with($statistic->type, $prefix);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,7 +31,9 @@ use FireflyIII\Models\PiggyBank;
|
|||||||
use FireflyIII\Models\RuleAction;
|
use FireflyIII\Models\RuleAction;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\Support\Facades\Amount;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@@ -176,7 +178,9 @@ class UpdatePiggyBank implements ActionInterface
|
|||||||
private function removeAmount(PiggyBank $piggyBank, array $array, TransactionJournal $journal, Account $account, string $amount): void
|
private function removeAmount(PiggyBank $piggyBank, array $array, TransactionJournal $journal, Account $account, string $amount): void
|
||||||
{
|
{
|
||||||
$repository = app(PiggyBankRepositoryInterface::class);
|
$repository = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser($journal->user);
|
$repository->setUser($journal->user);
|
||||||
|
$accountRepository->setUser($account->user);
|
||||||
|
|
||||||
// how much can we remove from this piggy bank?
|
// how much can we remove from this piggy bank?
|
||||||
$toRemove = $repository->getCurrentAmount($piggyBank, $account);
|
$toRemove = $repository->getCurrentAmount($piggyBank, $account);
|
||||||
@@ -196,7 +200,8 @@ class UpdatePiggyBank implements ActionInterface
|
|||||||
|
|
||||||
if (false === $repository->canRemoveAmount($piggyBank, $account, $amount)) {
|
if (false === $repository->canRemoveAmount($piggyBank, $account, $amount)) {
|
||||||
Log::warning(sprintf('Cannot remove %s from piggy bank.', $amount));
|
Log::warning(sprintf('Cannot remove %s from piggy bank.', $amount));
|
||||||
event(new RuleActionFailedOnArray($this->action, $array, trans('rules.cannot_remove_from_piggy', ['amount' => $amount, 'name' => $piggyBank->name])));
|
$currency = $accountRepository->getAccountCurrency($account) ?? Amount::getPrimaryCurrency();
|
||||||
|
event(new RuleActionFailedOnArray($this->action, $array, trans('rules.cannot_remove_from_piggy', ['amount' => Amount::formatAnything($amount, $currency, false), 'name' => $piggyBank->name])));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -208,7 +213,9 @@ class UpdatePiggyBank implements ActionInterface
|
|||||||
private function addAmount(PiggyBank $piggyBank, array $array, TransactionJournal $journal, Account $account, string $amount): void
|
private function addAmount(PiggyBank $piggyBank, array $array, TransactionJournal $journal, Account $account, string $amount): void
|
||||||
{
|
{
|
||||||
$repository = app(PiggyBankRepositoryInterface::class);
|
$repository = app(PiggyBankRepositoryInterface::class);
|
||||||
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser($journal->user);
|
$repository->setUser($journal->user);
|
||||||
|
$accountRepository->setUser($account->user);
|
||||||
|
|
||||||
// how much can we add to the piggy bank?
|
// how much can we add to the piggy bank?
|
||||||
if (0 !== bccomp($piggyBank->target_amount, '0')) {
|
if (0 !== bccomp($piggyBank->target_amount, '0')) {
|
||||||
@@ -233,7 +240,8 @@ class UpdatePiggyBank implements ActionInterface
|
|||||||
|
|
||||||
if (false === $repository->canAddAmount($piggyBank, $account, $amount)) {
|
if (false === $repository->canAddAmount($piggyBank, $account, $amount)) {
|
||||||
Log::warning(sprintf('Cannot add %s to piggy bank.', $amount));
|
Log::warning(sprintf('Cannot add %s to piggy bank.', $amount));
|
||||||
event(new RuleActionFailedOnArray($this->action, $array, trans('rules.cannot_add_to_piggy', ['amount' => $amount, 'name' => $piggyBank->name])));
|
$currency = $accountRepository->getAccountCurrency($account) ?? Amount::getPrimaryCurrency();
|
||||||
|
event(new RuleActionFailedOnArray($this->action, $array, trans('rules.cannot_add_to_piggy', ['amount' => Amount::formatAnything($amount, $currency, false), 'name' => $piggyBank->name])));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -75,7 +75,7 @@ return [
|
|||||||
'cannot_set_budget' => 'Firefly III can\'t set budget ":name" to a transaction of type ":type"',
|
'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.',
|
'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_zero_piggy' => 'Cannot remove zero amount from piggy bank ":name"',
|
||||||
'cannot_remove_from_piggy' => 'Cannot remove ":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_zero_piggy' => 'Cannot add zero amount to piggy bank ":name"',
|
||||||
'cannot_add_to_piggy' => 'Cannot add ":amount" to piggy bank ":name"',
|
'cannot_add_to_piggy' => 'Cannot add :amount to piggy bank ":name"',
|
||||||
];
|
];
|
||||||
|
@@ -270,7 +270,12 @@
|
|||||||
<td>
|
<td>
|
||||||
{% if (null == transaction.balance_dirty or false == transaction.balance_dirty) and null != transaction.destination_balance_after and null != transaction.source_balance_after %}
|
{% if (null == transaction.balance_dirty or false == transaction.balance_dirty) and null != transaction.destination_balance_after and null != transaction.source_balance_after %}
|
||||||
{% if transaction.transaction_type_type == 'Deposit' %}
|
{% if transaction.transaction_type_type == 'Deposit' %}
|
||||||
{{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
{% if transaction.source_account_id == account.id %}
|
||||||
|
{{ formatAmountBySymbol(transaction.source_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% else %}
|
||||||
|
{{ formatAmountBySymbol(transaction.destination_balance_after, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% elseif transaction.transaction_type_type == 'Withdrawal' %}
|
{% elseif transaction.transaction_type_type == 'Withdrawal' %}
|
||||||
{% if 'Loan' == transaction.destination_account_type or 'Mortgage' == transaction.destination_account_type or 'Debt' == transaction.destination_account_type %}
|
{% if 'Loan' == transaction.destination_account_type or 'Mortgage' == transaction.destination_account_type or 'Debt' == transaction.destination_account_type %}
|
||||||
{% if currency.id == transaction.currency_id %}
|
{% if currency.id == transaction.currency_id %}
|
||||||
|
Reference in New Issue
Block a user