mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Fix various code.
This commit is contained in:
@@ -238,7 +238,7 @@ class AccountUpdateService
|
||||
// otherwise, update or create.
|
||||
if (!(null === $data['latitude'] && null === $data['longitude'] && null === $data['zoom_level'])) {
|
||||
$location = $this->accountRepository->getLocation($account);
|
||||
if (null === $location) {
|
||||
if (!$location instanceof Location) {
|
||||
$location = new Location();
|
||||
$location->locatable()->associate($account);
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||
use FireflyIII\Models\Bill;
|
||||
@@ -100,7 +101,7 @@ class BillUpdateService
|
||||
$objectGroupTitle = $data['object_group_title'] ?? '';
|
||||
if ('' !== $objectGroupTitle) {
|
||||
$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);
|
||||
if (null !== $objectGroup) {
|
||||
if ($objectGroup instanceof ObjectGroup) {
|
||||
$bill->objectGroups()->sync([$objectGroup->id]);
|
||||
$bill->save();
|
||||
}
|
||||
@@ -116,7 +117,7 @@ class BillUpdateService
|
||||
$objectGroupId = (int) ($data['object_group_id'] ?? 0);
|
||||
if (0 !== $objectGroupId) {
|
||||
$objectGroup = $this->findObjectGroupById($objectGroupId);
|
||||
if (null !== $objectGroup) {
|
||||
if ($objectGroup instanceof ObjectGroup) {
|
||||
$bill->objectGroups()->sync([$objectGroup->id]);
|
||||
$bill->save();
|
||||
}
|
||||
@@ -232,14 +233,14 @@ class BillUpdateService
|
||||
/** @var Rule $rule */
|
||||
foreach ($rules as $rule) {
|
||||
$trigger = $this->getRuleTrigger($rule, $key);
|
||||
if (null !== $trigger && $trigger->trigger_value === $oldValue) {
|
||||
if ($trigger instanceof RuleTrigger && $trigger->trigger_value === $oldValue) {
|
||||
app('log')->debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
|
||||
$trigger->trigger_value = $newValue;
|
||||
$trigger->save();
|
||||
|
||||
continue;
|
||||
}
|
||||
if (null !== $trigger && $trigger->trigger_value !== $oldValue && in_array($key, ['amount_more', 'amount_less'], true)
|
||||
if ($trigger instanceof RuleTrigger && $trigger->trigger_value !== $oldValue && in_array($key, ['amount_more', 'amount_less'], true)
|
||||
&& 0 === bccomp($trigger->trigger_value, $oldValue)) {
|
||||
app('log')->debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
|
||||
$trigger->trigger_value = $newValue;
|
||||
|
@@ -187,10 +187,10 @@ class GroupUpdateService
|
||||
Log::debug('Call createTransactionJournal');
|
||||
$newJournal = $this->createTransactionJournal($transactionGroup, $transaction);
|
||||
Log::debug('Done calling createTransactionJournal');
|
||||
if (null !== $newJournal) {
|
||||
if ($newJournal instanceof TransactionJournal) {
|
||||
$updated[] = $newJournal->id;
|
||||
}
|
||||
if (null === $newJournal) {
|
||||
if (!$newJournal instanceof TransactionJournal) {
|
||||
Log::error('createTransactionJournal returned NULL, indicating something went wrong.');
|
||||
}
|
||||
}
|
||||
|
@@ -226,7 +226,7 @@ class JournalUpdateService
|
||||
|
||||
private function getOriginalSourceAccount(): Account
|
||||
{
|
||||
if (null === $this->sourceAccount) {
|
||||
if (!$this->sourceAccount instanceof Account) {
|
||||
$source = $this->getSourceTransaction();
|
||||
$this->sourceAccount = $source->account;
|
||||
}
|
||||
@@ -236,7 +236,7 @@ class JournalUpdateService
|
||||
|
||||
private function getSourceTransaction(): Transaction
|
||||
{
|
||||
if (null === $this->sourceTransaction) {
|
||||
if (!$this->sourceTransaction instanceof Transaction) {
|
||||
/** @var null|Transaction $result */
|
||||
$result = $this->transactionJournal->transactions()->with(['account'])->where('amount', '<', 0)->first();
|
||||
$this->sourceTransaction = $result;
|
||||
@@ -304,7 +304,7 @@ class JournalUpdateService
|
||||
|
||||
private function getOriginalDestinationAccount(): Account
|
||||
{
|
||||
if (null === $this->destinationAccount) {
|
||||
if (!$this->destinationAccount instanceof Account) {
|
||||
$destination = $this->getDestinationTransaction();
|
||||
$this->destinationAccount = $destination->account;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ class JournalUpdateService
|
||||
*/
|
||||
private function getDestinationTransaction(): Transaction
|
||||
{
|
||||
if (null === $this->destinationTransaction) {
|
||||
if (!$this->destinationTransaction instanceof Transaction) {
|
||||
/** @var null|Transaction $result */
|
||||
$result = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
|
||||
$this->destinationTransaction = $result;
|
||||
|
@@ -145,7 +145,7 @@ class RecurrenceUpdateService
|
||||
app('log')->debug('Loop and find');
|
||||
foreach ($repetitions as $current) {
|
||||
$match = $this->matchRepetition($recurrence, $current);
|
||||
if (null === $match) {
|
||||
if (!$match instanceof RecurrenceRepetition) {
|
||||
throw new FireflyException('Cannot match recurring repetition to existing repetition. Not sure what to do. Break.');
|
||||
}
|
||||
$fields = [
|
||||
|
Reference in New Issue
Block a user