mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
use journal repository instead of direct calls.
This commit is contained in:
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,12 @@ final class AmountExactly extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$amount = $journal->destination_amount ?? $journal->amountPositive();
|
||||
/** @var JournalRepositoryInterface $repos */
|
||||
$repos = app(JournalRepositoryInterface::class);
|
||||
$repos->setUser($journal->user);
|
||||
|
||||
|
||||
$amount = $journal->destination_amount ?? $repos->getJournalTotal($journal);
|
||||
$compare = $this->triggerValue;
|
||||
$result = bccomp($amount, $compare);
|
||||
if (0 === $result) {
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,11 @@ final class AmountLess extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$amount = $journal->destination_amount ?? $journal->amountPositive();
|
||||
/** @var JournalRepositoryInterface $repos */
|
||||
$repos = app(JournalRepositoryInterface::class);
|
||||
$repos->setUser($journal->user);
|
||||
|
||||
$amount = $journal->destination_amount ?? $repos->getJournalTotal($journal);
|
||||
$compare = $this->triggerValue;
|
||||
$result = bccomp($amount, $compare);
|
||||
if ($result === -1) {
|
||||
|
@@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\TransactionRules\Triggers;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,11 @@ final class AmountMore extends AbstractTrigger implements TriggerInterface
|
||||
*/
|
||||
public function triggered(TransactionJournal $journal): bool
|
||||
{
|
||||
$amount = $journal->destination_amount ?? $journal->amountPositive();
|
||||
/** @var JournalRepositoryInterface $repos */
|
||||
$repos = app(JournalRepositoryInterface::class);
|
||||
$repos->setUser($journal->user);
|
||||
|
||||
$amount = $journal->destination_amount ?? $repos->getJournalTotal($journal);
|
||||
$compare = $this->triggerValue;
|
||||
$result = bccomp($amount, $compare);
|
||||
if (1 === $result) {
|
||||
|
Reference in New Issue
Block a user