mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Fix code quality with rector [skip ci]
This commit is contained in:
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Destroy;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Enums\TransactionTypeEnum;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
@@ -65,7 +66,7 @@ class AccountDestroyService
|
||||
|
||||
private function destroyOpeningBalance(Account $account): void
|
||||
{
|
||||
app('log')->debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
|
||||
Log::debug(sprintf('Searching for opening balance for account #%d "%s"', $account->id, $account->name));
|
||||
$set = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
|
||||
@@ -74,7 +75,7 @@ class AccountDestroyService
|
||||
;
|
||||
if ($set->count() > 0) {
|
||||
$journalId = $set->first()->transaction_journal_id;
|
||||
app('log')->debug(sprintf('Found opening balance journal with ID #%d', $journalId));
|
||||
Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId));
|
||||
|
||||
// get transactions with this journal (should be just one):
|
||||
$transactions = Transaction::where('transaction_journal_id', $journalId)
|
||||
@@ -84,9 +85,9 @@ class AccountDestroyService
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
app('log')->debug(sprintf('Found transaction with ID #%d', $transaction->id));
|
||||
Log::debug(sprintf('Found transaction with ID #%d', $transaction->id));
|
||||
$ibAccount = $transaction->account;
|
||||
app('log')->debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
|
||||
Log::debug(sprintf('Connected to account #%d "%s"', $ibAccount->id, $ibAccount->name));
|
||||
|
||||
$ibAccount->accountMeta()->delete();
|
||||
$transaction->delete();
|
||||
@@ -105,7 +106,7 @@ class AccountDestroyService
|
||||
|
||||
public function moveTransactions(Account $account, Account $moveTo): void
|
||||
{
|
||||
app('log')->debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
|
||||
Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id));
|
||||
DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]);
|
||||
|
||||
$collection = Transaction::groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get(['transaction_journal_id', 'account_id', DB::raw('count(*) as the_count')]);
|
||||
@@ -123,7 +124,7 @@ class AccountDestroyService
|
||||
$journalId = $row->transaction_journal_id;
|
||||
$journal = $user->transactionJournals()->find($journalId);
|
||||
if (null !== $journal) {
|
||||
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
|
||||
Log::debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
|
||||
$service->destroy($journal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Destroy;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Models\Attachment;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
@@ -38,18 +39,18 @@ class JournalDestroyService
|
||||
{
|
||||
public function destroy(TransactionJournal $journal): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions()->get() as $transaction) {
|
||||
app('log')->debug(sprintf('Will now delete transaction #%d', $transaction->id));
|
||||
Log::debug(sprintf('Will now delete transaction #%d', $transaction->id));
|
||||
$transaction->delete();
|
||||
}
|
||||
|
||||
// also delete journal_meta entries.
|
||||
/** @var TransactionJournalMeta $meta */
|
||||
foreach ($journal->transactionJournalMeta()->get() as $meta) {
|
||||
app('log')->debug(sprintf('Will now delete meta-entry #%d', $meta->id));
|
||||
Log::debug(sprintf('Will now delete meta-entry #%d', $meta->id));
|
||||
$meta->delete();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Destroy;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Events\DestroyedTransactionGroup;
|
||||
use FireflyIII\Models\TransactionGroup;
|
||||
|
||||
@@ -34,7 +35,7 @@ class TransactionGroupDestroyService
|
||||
{
|
||||
public function destroy(TransactionGroup $transactionGroup): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
/** @var JournalDestroyService $service */
|
||||
$service = app(JournalDestroyService::class);
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Support;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Carbon\Carbon;
|
||||
use Deprecated;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
@@ -58,7 +59,7 @@ trait AccountServiceTrait
|
||||
$rules = ['iban' => 'required|iban'];
|
||||
$validator = Validator::make($data, $rules);
|
||||
if ($validator->fails()) {
|
||||
app('log')->info(sprintf('Detected invalid IBAN ("%s"). Return NULL instead.', $iban));
|
||||
Log::info(sprintf('Detected invalid IBAN ("%s"). Return NULL instead.', $iban));
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -78,14 +79,8 @@ trait AccountServiceTrait
|
||||
return false;
|
||||
}
|
||||
// if is set, but is empty:
|
||||
if (
|
||||
(array_key_exists('opening_balance', $data) && '' === $data['opening_balance'])
|
||||
|| (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date'])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (array_key_exists('opening_balance', $data) && '' === $data['opening_balance'])
|
||||
|| (array_key_exists('opening_balance_date', $data) && '' === $data['opening_balance_date']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,11 +175,11 @@ trait AccountServiceTrait
|
||||
}
|
||||
if ('' !== $data['opening_balance'] && array_key_exists('opening_balance_date', $data) && '' !== $data['opening_balance_date']
|
||||
&& $data['opening_balance_date'] instanceof Carbon) {
|
||||
app('log')->debug('Array has valid opening balance data.');
|
||||
Log::debug('Array has valid opening balance data.');
|
||||
|
||||
return true;
|
||||
}
|
||||
app('log')->debug('Array does not have valid opening balance data.');
|
||||
Log::debug('Array does not have valid opening balance data.');
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -196,7 +191,7 @@ trait AccountServiceTrait
|
||||
#[Deprecated]
|
||||
protected function createOBGroup(Account $account, array $data): TransactionGroup
|
||||
{
|
||||
app('log')->debug('Now going to create an OB group.');
|
||||
Log::debug('Now going to create an OB group.');
|
||||
$language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;
|
||||
if (is_array($language)) {
|
||||
$language = 'en_US';
|
||||
@@ -210,19 +205,19 @@ trait AccountServiceTrait
|
||||
|
||||
// amount is positive.
|
||||
if (1 === bccomp((string) $amount, '0')) {
|
||||
app('log')->debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id));
|
||||
Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $amount, $account->id));
|
||||
$sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);
|
||||
$destId = $account->id;
|
||||
}
|
||||
// amount is not positive
|
||||
if (-1 === bccomp((string) $amount, '0')) {
|
||||
app('log')->debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id));
|
||||
Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $amount, $account->id));
|
||||
$destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);
|
||||
$sourceId = $account->id;
|
||||
}
|
||||
// amount is 0
|
||||
if (0 === bccomp((string) $amount, '0')) {
|
||||
app('log')->debug('Amount is zero, so will not make an OB group.');
|
||||
Log::debug('Amount is zero, so will not make an OB group.');
|
||||
|
||||
throw new FireflyException('Amount for new opening balance was unexpectedly 0.');
|
||||
}
|
||||
@@ -268,7 +263,7 @@ trait AccountServiceTrait
|
||||
],
|
||||
],
|
||||
];
|
||||
app('log')->debug('Going for submission in createOBGroup', $submission);
|
||||
Log::debug('Going for submission in createOBGroup', $submission);
|
||||
|
||||
/** @var TransactionGroupFactory $factory */
|
||||
$factory = app(TransactionGroupFactory::class);
|
||||
@@ -277,8 +272,8 @@ trait AccountServiceTrait
|
||||
try {
|
||||
$group = $factory->create($submission);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
}
|
||||
@@ -291,11 +286,11 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function deleteCreditTransaction(Account $account): void
|
||||
{
|
||||
app('log')->debug(sprintf('deleteCreditTransaction() for account #%d', $account->id));
|
||||
Log::debug(sprintf('deleteCreditTransaction() for account #%d', $account->id));
|
||||
$creditGroup = $this->getCreditTransaction($account);
|
||||
|
||||
if (null !== $creditGroup) {
|
||||
app('log')->debug('Credit journal found, delete journal.');
|
||||
Log::debug('Credit journal found, delete journal.');
|
||||
|
||||
/** @var TransactionGroupDestroyService $service */
|
||||
$service = app(TransactionGroupDestroyService::class);
|
||||
@@ -308,7 +303,7 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function getCreditTransaction(Account $account): ?TransactionGroup
|
||||
{
|
||||
app('log')->debug(sprintf('Now at %s', __METHOD__));
|
||||
Log::debug(sprintf('Now at %s', __METHOD__));
|
||||
|
||||
return $this->accountRepository->getCreditTransactionGroup($account);
|
||||
}
|
||||
@@ -318,12 +313,12 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function deleteOBGroup(Account $account): void
|
||||
{
|
||||
app('log')->debug(sprintf('deleteOB() for account #%d', $account->id));
|
||||
Log::debug(sprintf('deleteOB() for account #%d', $account->id));
|
||||
$openingBalanceGroup = $this->getOBGroup($account);
|
||||
|
||||
// opening balance data? update it!
|
||||
if (null !== $openingBalanceGroup) {
|
||||
app('log')->debug('Opening balance journal found, delete journal.');
|
||||
Log::debug('Opening balance journal found, delete journal.');
|
||||
|
||||
/** @var TransactionGroupDestroyService $service */
|
||||
$service = app(TransactionGroupDestroyService::class);
|
||||
@@ -365,10 +360,10 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function updateCreditTransaction(Account $account, string $direction, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
|
||||
if (0 === bccomp($openingBalance, '0')) {
|
||||
app('log')->debug('Amount is zero, so will not update liability credit/debit group.');
|
||||
Log::debug('Amount is zero, so will not update liability credit/debit group.');
|
||||
|
||||
throw new FireflyException('Amount for update liability credit/debit was unexpectedly 0.');
|
||||
}
|
||||
@@ -421,10 +416,10 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function createCreditTransaction(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
|
||||
{
|
||||
app('log')->debug('Now going to create an createCreditTransaction.');
|
||||
Log::debug('Now going to create an createCreditTransaction.');
|
||||
|
||||
if (0 === bccomp($openingBalance, '0')) {
|
||||
app('log')->debug('Amount is zero, so will not make an liability credit group.');
|
||||
Log::debug('Amount is zero, so will not make an liability credit group.');
|
||||
|
||||
throw new FireflyException('Amount for new liability credit was unexpectedly 0.');
|
||||
}
|
||||
@@ -490,7 +485,7 @@ trait AccountServiceTrait
|
||||
],
|
||||
],
|
||||
];
|
||||
app('log')->debug('Going for submission in createCreditTransaction', $submission);
|
||||
Log::debug('Going for submission in createCreditTransaction', $submission);
|
||||
|
||||
/** @var TransactionGroupFactory $factory */
|
||||
$factory = app(TransactionGroupFactory::class);
|
||||
@@ -499,8 +494,8 @@ trait AccountServiceTrait
|
||||
try {
|
||||
$group = $factory->create($submission);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
}
|
||||
@@ -562,13 +557,13 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function updateOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
// create if not exists:
|
||||
$obGroup = $this->getOBGroup($account);
|
||||
if (null === $obGroup) {
|
||||
return $this->createOBGroupV2($account, $openingBalance, $openingBalanceDate);
|
||||
}
|
||||
app('log')->debug('Update OB group');
|
||||
Log::debug('Update OB group');
|
||||
|
||||
// if exists, update:
|
||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||
@@ -585,7 +580,7 @@ trait AccountServiceTrait
|
||||
|
||||
// if amount is negative:
|
||||
if (1 === bccomp('0', $openingBalance)) {
|
||||
app('log')->debug('Amount is negative.');
|
||||
Log::debug('Amount is negative.');
|
||||
// account transaction loses money:
|
||||
$accountTransaction->amount = app('steam')->negative($openingBalance);
|
||||
$accountTransaction->transaction_currency_id = $currency->id;
|
||||
@@ -595,7 +590,7 @@ trait AccountServiceTrait
|
||||
$obTransaction->transaction_currency_id = $currency->id;
|
||||
}
|
||||
if (-1 === bccomp('0', $openingBalance)) {
|
||||
app('log')->debug('Amount is positive.');
|
||||
Log::debug('Amount is positive.');
|
||||
// account gains money:
|
||||
$accountTransaction->amount = app('steam')->positive($openingBalance);
|
||||
$accountTransaction->transaction_currency_id = $currency->id;
|
||||
@@ -618,7 +613,7 @@ trait AccountServiceTrait
|
||||
*/
|
||||
protected function createOBGroupV2(Account $account, string $openingBalance, Carbon $openingBalanceDate): TransactionGroup
|
||||
{
|
||||
app('log')->debug('Now going to create an OB group.');
|
||||
Log::debug('Now going to create an OB group.');
|
||||
$language = app('preferences')->getForUser($account->user, 'language', 'en_US')->data;
|
||||
if (is_array($language)) {
|
||||
$language = 'en_US';
|
||||
@@ -631,19 +626,19 @@ trait AccountServiceTrait
|
||||
|
||||
// amount is positive.
|
||||
if (1 === bccomp($openingBalance, '0')) {
|
||||
app('log')->debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id));
|
||||
Log::debug(sprintf('Amount is %s, which is positive. Source is a new IB account, destination is #%d', $openingBalance, $account->id));
|
||||
$sourceName = trans('firefly.initial_balance_description', ['account' => $account->name], $language);
|
||||
$destId = $account->id;
|
||||
}
|
||||
// amount is not positive
|
||||
if (-1 === bccomp($openingBalance, '0')) {
|
||||
app('log')->debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id));
|
||||
Log::debug(sprintf('Amount is %s, which is negative. Destination is a new IB account, source is #%d', $openingBalance, $account->id));
|
||||
$destName = trans('firefly.initial_balance_account', ['account' => $account->name], $language);
|
||||
$sourceId = $account->id;
|
||||
}
|
||||
// amount is 0
|
||||
if (0 === bccomp($openingBalance, '0')) {
|
||||
app('log')->debug('Amount is zero, so will not make an OB group.');
|
||||
Log::debug('Amount is zero, so will not make an OB group.');
|
||||
|
||||
throw new FireflyException('Amount for new opening balance was unexpectedly 0.');
|
||||
}
|
||||
@@ -689,7 +684,7 @@ trait AccountServiceTrait
|
||||
],
|
||||
],
|
||||
];
|
||||
app('log')->debug('Going for submission in createOBGroupV2', $submission);
|
||||
Log::debug('Going for submission in createOBGroupV2', $submission);
|
||||
|
||||
/** @var TransactionGroupFactory $factory */
|
||||
$factory = app(TransactionGroupFactory::class);
|
||||
@@ -698,8 +693,8 @@ trait AccountServiceTrait
|
||||
try {
|
||||
$group = $factory->create($submission);
|
||||
} catch (DuplicateTransactionException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
app('log')->error($e->getTraceAsString());
|
||||
Log::error($e->getMessage());
|
||||
Log::error($e->getTraceAsString());
|
||||
|
||||
throw new FireflyException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Support;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\RuleAction;
|
||||
@@ -46,7 +47,7 @@ trait BillServiceTrait
|
||||
|
||||
/** @var RuleAction $ruleAction */
|
||||
foreach ($set as $ruleAction) {
|
||||
app('log')->debug(sprintf('Updated rule action #%d to search for new bill name "%s"', $ruleAction->id, $newName));
|
||||
Log::debug(sprintf('Updated rule action #%d to search for new bill name "%s"', $ruleAction->id, $newName));
|
||||
$ruleAction->action_value = $newName;
|
||||
$ruleAction->save();
|
||||
}
|
||||
|
||||
@@ -40,20 +40,10 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class CreditRecalculateService
|
||||
{
|
||||
private ?Account $account;
|
||||
private ?TransactionGroup $group;
|
||||
private ?Account $account = null;
|
||||
private ?TransactionGroup $group = null;
|
||||
private AccountRepositoryInterface $repository;
|
||||
private array $work;
|
||||
|
||||
/**
|
||||
* CreditRecalculateService constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->group = null;
|
||||
$this->account = null;
|
||||
$this->work = [];
|
||||
}
|
||||
private array $work = [];
|
||||
|
||||
public function recalculate(): void
|
||||
{
|
||||
@@ -163,12 +153,10 @@ class CreditRecalculateService
|
||||
$this->repository->setUser($account->user);
|
||||
$direction = (string) $this->repository->getMetaValue($account, 'liability_direction');
|
||||
$openingBalance = $this->repository->getOpeningBalance($account);
|
||||
if ($openingBalance instanceof TransactionJournal) {
|
||||
// Log::debug(sprintf('Found opening balance transaction journal #%d', $openingBalance->id));
|
||||
// if account direction is "debit" ("I owe this amount") the opening balance must always be AWAY from the account:
|
||||
if ('debit' === $direction) {
|
||||
$this->validateOpeningBalance($account, $openingBalance);
|
||||
}
|
||||
// Log::debug(sprintf('Found opening balance transaction journal #%d', $openingBalance->id));
|
||||
// if account direction is "debit" ("I owe this amount") the opening balance must always be AWAY from the account:
|
||||
if ($openingBalance instanceof TransactionJournal && 'debit' === $direction) {
|
||||
$this->validateOpeningBalance($account, $openingBalance);
|
||||
}
|
||||
$startOfDebt = $this->repository->getOpeningBalanceAmount($account, false) ?? '0';
|
||||
$leftOfDebt = app('steam')->positive($startOfDebt);
|
||||
@@ -188,7 +176,7 @@ class CreditRecalculateService
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
->get(['transactions.*'])
|
||||
;
|
||||
$total = $transactions->count();
|
||||
$transactions->count();
|
||||
// Log::debug(sprintf('Found %d transaction(s) to process.', $total));
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
|
||||
@@ -258,7 +258,7 @@ trait JournalServiceTrait
|
||||
|
||||
/** @var string $type */
|
||||
foreach ($types as $type) {
|
||||
if (true === in_array($type, $list, true)) {
|
||||
if (in_array($type, $list, true)) {
|
||||
$result = $type;
|
||||
|
||||
break;
|
||||
|
||||
@@ -94,9 +94,9 @@ trait RecurringTransactionTrait
|
||||
*/
|
||||
protected function createTransactions(Recurrence $recurrence, array $transactions): void
|
||||
{
|
||||
app('log')->debug('Now in createTransactions()');
|
||||
Log::debug('Now in createTransactions()');
|
||||
foreach ($transactions as $index => $array) {
|
||||
app('log')->debug(sprintf('Now at transaction #%d', $index));
|
||||
Log::debug(sprintf('Now at transaction #%d', $index));
|
||||
$sourceTypes = config(sprintf('firefly.expected_source_types.source.%s', $recurrence->transactionType->type));
|
||||
$destTypes = config(sprintf('firefly.expected_source_types.destination.%s', $recurrence->transactionType->type));
|
||||
$source = $this->findAccount($sourceTypes, $array['source_id'], null);
|
||||
@@ -110,7 +110,7 @@ trait RecurringTransactionTrait
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($recurrence->user->userGroup);
|
||||
}
|
||||
|
||||
app('log')->debug(
|
||||
Log::debug(
|
||||
sprintf('Will set the validator type to %s based on the type of the recurrence (#%d).', $recurrence->transactionType->type, $recurrence->id)
|
||||
);
|
||||
|
||||
@@ -204,7 +204,7 @@ trait RecurringTransactionTrait
|
||||
try {
|
||||
$result = $factory->findOrCreate($accountName, $expectedType);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
Log::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ trait RecurringTransactionTrait
|
||||
|
||||
protected function deleteTransactions(Recurrence $recurrence): void
|
||||
{
|
||||
app('log')->debug('deleteTransactions()');
|
||||
Log::debug('deleteTransactions()');
|
||||
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
foreach ($recurrence->recurrenceTransactions as $transaction) {
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Support;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionTypeFactory;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
@@ -44,7 +45,7 @@ trait TransactionTypeTrait
|
||||
$factory = app(TransactionTypeFactory::class);
|
||||
$transactionType = $factory->find($type);
|
||||
if (null === $transactionType) {
|
||||
app('log')->error(sprintf('Could not find transaction type for "%s"', $type));
|
||||
Log::error(sprintf('Could not find transaction type for "%s"', $type));
|
||||
|
||||
throw new FireflyException(sprintf('Could not find transaction type for "%s"', $type));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Enums\AccountTypeEnum;
|
||||
use FireflyIII\Events\UpdatedAccount;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
@@ -68,7 +69,7 @@ class AccountUpdateService
|
||||
*/
|
||||
public function update(Account $account, array $data): Account
|
||||
{
|
||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
$this->accountRepository->setUser($account->user);
|
||||
$this->user = $account->user;
|
||||
$account = $this->updateAccount($account, $data);
|
||||
@@ -166,21 +167,21 @@ class AccountUpdateService
|
||||
{
|
||||
// skip if no order info
|
||||
if (!array_key_exists('order', $data) || $data['order'] === $account->order) {
|
||||
app('log')->debug(sprintf('Account order will not be touched because its not set or already at %d.', $account->order));
|
||||
Log::debug(sprintf('Account order will not be touched because its not set or already at %d.', $account->order));
|
||||
|
||||
return $account;
|
||||
}
|
||||
// skip if not of orderable type.
|
||||
$type = $account->accountType->type;
|
||||
if (!in_array($type, [AccountTypeEnum::ASSET->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value], true)) {
|
||||
app('log')->debug('Will not change order of this account.');
|
||||
Log::debug('Will not change order of this account.');
|
||||
|
||||
return $account;
|
||||
}
|
||||
// get account type ID's because a join and an update is hard:
|
||||
$oldOrder = $account->order;
|
||||
$newOrder = $data['order'];
|
||||
app('log')->debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));
|
||||
Log::debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));
|
||||
$list = $this->getTypeIds([AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value]);
|
||||
if (AccountTypeEnum::ASSET->value === $type) {
|
||||
$list = $this->getTypeIds([AccountTypeEnum::ASSET->value]);
|
||||
@@ -193,7 +194,7 @@ class AccountUpdateService
|
||||
->decrement('order')
|
||||
;
|
||||
$account->order = $newOrder;
|
||||
app('log')->debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
|
||||
Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
|
||||
$account->save();
|
||||
|
||||
return $account;
|
||||
@@ -205,7 +206,7 @@ class AccountUpdateService
|
||||
->increment('order')
|
||||
;
|
||||
$account->order = $newOrder;
|
||||
app('log')->debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
|
||||
Log::debug(sprintf('Order of account #%d ("%s") is now %d', $account->id, $account->name, $newOrder));
|
||||
$account->save();
|
||||
|
||||
return $account;
|
||||
@@ -298,17 +299,17 @@ class AccountUpdateService
|
||||
if (!is_array($array)) {
|
||||
$array = [$array];
|
||||
}
|
||||
app('log')->debug('Old array is: ', $array);
|
||||
app('log')->debug(sprintf('Must remove : %d', $account->id));
|
||||
Log::debug('Old array is: ', $array);
|
||||
Log::debug(sprintf('Must remove : %d', $account->id));
|
||||
$removeAccountId = $account->id;
|
||||
$new = [];
|
||||
foreach ($array as $value) {
|
||||
if ((int) $value !== $removeAccountId) {
|
||||
app('log')->debug(sprintf('Will include: %d', $value));
|
||||
Log::debug(sprintf('Will include: %d', $value));
|
||||
$new[] = (int) $value;
|
||||
}
|
||||
}
|
||||
app('log')->debug('Final new array is', $new);
|
||||
Log::debug('Final new array is', $new);
|
||||
app('preferences')->setForUser($account->user, 'frontpageAccounts', $new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\ObjectGroup;
|
||||
@@ -193,18 +194,18 @@ class BillUpdateService
|
||||
|
||||
private function updateBillTriggers(Bill $bill, array $oldData, array $newData): void
|
||||
{
|
||||
app('log')->debug(sprintf('Now in updateBillTriggers(%d, "%s")', $bill->id, $bill->name));
|
||||
Log::debug(sprintf('Now in updateBillTriggers(%d, "%s")', $bill->id, $bill->name));
|
||||
|
||||
/** @var BillRepositoryInterface $repository */
|
||||
$repository = app(BillRepositoryInterface::class);
|
||||
$repository->setUser($bill->user);
|
||||
$rules = $repository->getRulesForBill($bill);
|
||||
if (0 === $rules->count()) {
|
||||
app('log')->debug('Found no rules.');
|
||||
Log::debug('Found no rules.');
|
||||
|
||||
return;
|
||||
}
|
||||
app('log')->debug(sprintf('Found %d rules', $rules->count()));
|
||||
Log::debug(sprintf('Found %d rules', $rules->count()));
|
||||
$fields = [
|
||||
'name' => 'description_contains',
|
||||
'amount_min' => 'amount_more',
|
||||
@@ -216,7 +217,7 @@ class BillUpdateService
|
||||
continue;
|
||||
}
|
||||
if ($oldData[$field] === $newData[$field]) {
|
||||
app('log')->debug(sprintf('Field %s is unchanged ("%s"), continue.', $field, $oldData[$field]));
|
||||
Log::debug(sprintf('Field %s is unchanged ("%s"), continue.', $field, $oldData[$field]));
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -230,7 +231,7 @@ class BillUpdateService
|
||||
foreach ($rules as $rule) {
|
||||
$trigger = $this->getRuleTrigger($rule, $key);
|
||||
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));
|
||||
Log::debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
|
||||
$trigger->trigger_value = $newValue;
|
||||
$trigger->save();
|
||||
|
||||
@@ -238,7 +239,7 @@ class BillUpdateService
|
||||
}
|
||||
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));
|
||||
Log::debug(sprintf('Updated rule trigger #%d from value "%s" to value "%s"', $trigger->id, $oldValue, $newValue));
|
||||
$trigger->trigger_value = $newValue;
|
||||
$trigger->save();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Exception;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Note;
|
||||
@@ -54,7 +55,7 @@ class CategoryUpdateService
|
||||
/**
|
||||
* @param mixed $user
|
||||
*/
|
||||
public function setUser($user): void
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
@@ -88,13 +89,13 @@ class CategoryUpdateService
|
||||
->where('rule_triggers.trigger_value', $oldName)
|
||||
->get(['rule_triggers.*'])
|
||||
;
|
||||
app('log')->debug(sprintf('Found %d triggers to update.', $triggers->count()));
|
||||
Log::debug(sprintf('Found %d triggers to update.', $triggers->count()));
|
||||
|
||||
/** @var RuleTrigger $trigger */
|
||||
foreach ($triggers as $trigger) {
|
||||
$trigger->trigger_value = $newName;
|
||||
$trigger->save();
|
||||
app('log')->debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
|
||||
Log::debug(sprintf('Updated trigger %d: %s', $trigger->id, $trigger->trigger_value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,13 +108,13 @@ class CategoryUpdateService
|
||||
->where('rule_actions.action_value', $oldName)
|
||||
->get(['rule_actions.*'])
|
||||
;
|
||||
app('log')->debug(sprintf('Found %d actions to update.', $actions->count()));
|
||||
Log::debug(sprintf('Found %d actions to update.', $actions->count()));
|
||||
|
||||
/** @var RuleAction $action */
|
||||
foreach ($actions as $action) {
|
||||
$action->action_value = $newName;
|
||||
$action->save();
|
||||
app('log')->debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));
|
||||
Log::debug(sprintf('Updated action %d: %s', $action->id, $action->action_value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ class CategoryUpdateService
|
||||
*/
|
||||
private function updateNotes(Category $category, array $data): void
|
||||
{
|
||||
$note = array_key_exists('notes', $data) ? $data['notes'] : null;
|
||||
$note = $data['notes'] ?? null;
|
||||
if (null === $note) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -105,16 +105,14 @@ class GroupUpdateService
|
||||
|
||||
$result = array_diff($existing, $updated);
|
||||
Log::debug('Result of DIFF: ', $result);
|
||||
if (count($result) > 0) {
|
||||
/** @var string $deletedId */
|
||||
foreach ($result as $deletedId) {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $transactionGroup->transactionJournals()->find((int) $deletedId);
|
||||
/** @var string $deletedId */
|
||||
foreach ($result as $deletedId) {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $transactionGroup->transactionJournals()->find((int) $deletedId);
|
||||
|
||||
/** @var JournalDestroyService $service */
|
||||
$service = app(JournalDestroyService::class);
|
||||
$service->destroy($journal);
|
||||
}
|
||||
/** @var JournalDestroyService $service */
|
||||
$service = app(JournalDestroyService::class);
|
||||
$service->destroy($journal);
|
||||
}
|
||||
|
||||
app('preferences')->mark();
|
||||
|
||||
@@ -63,14 +63,29 @@ class JournalUpdateService
|
||||
private CurrencyRepositoryInterface $currencyRepository;
|
||||
private TransactionGroupRepositoryInterface $transactionGroupRepository;
|
||||
private array $data;
|
||||
private ?Account $destinationAccount;
|
||||
private ?Transaction $destinationTransaction;
|
||||
private array $metaDate;
|
||||
private array $metaString;
|
||||
private ?Account $sourceAccount;
|
||||
private ?Transaction $sourceTransaction;
|
||||
private ?TransactionGroup $transactionGroup;
|
||||
private ?TransactionJournal $transactionJournal;
|
||||
private ?Account $destinationAccount = null;
|
||||
private ?Transaction $destinationTransaction = null;
|
||||
private array $metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date',
|
||||
'invoice_date', ];
|
||||
private array $metaString = [
|
||||
'sepa_cc',
|
||||
'sepa_ct_op',
|
||||
'sepa_ct_id',
|
||||
'sepa_db',
|
||||
'sepa_country',
|
||||
'sepa_ep',
|
||||
'sepa_ci',
|
||||
'sepa_batch_id',
|
||||
'recurrence_id',
|
||||
'internal_reference',
|
||||
'bunq_payment_id',
|
||||
'external_id',
|
||||
'external_url',
|
||||
];
|
||||
private ?Account $sourceAccount = null;
|
||||
private ?Transaction $sourceTransaction = null;
|
||||
private ?TransactionGroup $transactionGroup = null;
|
||||
private ?TransactionJournal $transactionJournal = null;
|
||||
private string $startCompareHash = '';
|
||||
|
||||
/**
|
||||
@@ -78,12 +93,6 @@ class JournalUpdateService
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->destinationAccount = null;
|
||||
$this->destinationTransaction = null;
|
||||
$this->sourceAccount = null;
|
||||
$this->sourceTransaction = null;
|
||||
$this->transactionGroup = null;
|
||||
$this->transactionJournal = null;
|
||||
$this->billRepository = app(BillRepositoryInterface::class);
|
||||
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
||||
$this->budgetRepository = app(BudgetRepositoryInterface::class);
|
||||
@@ -91,23 +100,6 @@ class JournalUpdateService
|
||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
|
||||
$this->transactionGroupRepository = app(TransactionGroupRepositoryInterface::class);
|
||||
$this->metaString = [
|
||||
'sepa_cc',
|
||||
'sepa_ct_op',
|
||||
'sepa_ct_id',
|
||||
'sepa_db',
|
||||
'sepa_country',
|
||||
'sepa_ep',
|
||||
'sepa_ci',
|
||||
'sepa_batch_id',
|
||||
'recurrence_id',
|
||||
'internal_reference',
|
||||
'bunq_payment_id',
|
||||
'external_id',
|
||||
'external_url',
|
||||
];
|
||||
$this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date',
|
||||
'invoice_date', ];
|
||||
}
|
||||
|
||||
public function setData(array $data): void
|
||||
@@ -141,7 +133,7 @@ class JournalUpdateService
|
||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||
Log::debug(sprintf('Now in JournalUpdateService for journal #%d.', $this->transactionJournal->id));
|
||||
|
||||
$this->data['reconciled'] = array_key_exists('reconciled', $this->data) ? $this->data['reconciled'] : null;
|
||||
$this->data['reconciled'] ??= null;
|
||||
|
||||
// can we update account data using the new type?
|
||||
if ($this->hasValidAccounts()) {
|
||||
@@ -221,7 +213,7 @@ class JournalUpdateService
|
||||
|
||||
private function hasFields(array $fields): bool
|
||||
{
|
||||
return array_any($fields, fn ($field) => array_key_exists($field, $this->data));
|
||||
return array_any($fields, fn ($field): bool => array_key_exists($field, $this->data));
|
||||
}
|
||||
|
||||
private function getOriginalSourceAccount(): Account
|
||||
|
||||
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Services\Internal\Update;
|
||||
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Factory\TransactionCurrencyFactory;
|
||||
use FireflyIII\Models\Note;
|
||||
@@ -94,7 +95,7 @@ class RecurrenceUpdateService
|
||||
|
||||
// update all repetitions
|
||||
if (array_key_exists('repetitions', $data)) {
|
||||
app('log')->debug('Will update repetitions array');
|
||||
Log::debug('Will update repetitions array');
|
||||
// update each repetition or throw error yay
|
||||
$this->updateRepetitions($recurrence, $data['repetitions'] ?? []);
|
||||
}
|
||||
@@ -135,14 +136,14 @@ class RecurrenceUpdateService
|
||||
}
|
||||
// user added or removed repetitions, delete all and recreate:
|
||||
if ($originalCount !== count($repetitions)) {
|
||||
app('log')->debug('Delete existing repetitions and create new ones.');
|
||||
Log::debug('Delete existing repetitions and create new ones.');
|
||||
$this->deleteRepetitions($recurrence);
|
||||
$this->createRepetitions($recurrence, $repetitions);
|
||||
|
||||
return;
|
||||
}
|
||||
// loop all and try to match them:
|
||||
app('log')->debug('Loop and find');
|
||||
Log::debug('Loop and find');
|
||||
foreach ($repetitions as $current) {
|
||||
$match = $this->matchRepetition($recurrence, $current);
|
||||
if (!$match instanceof RecurrenceRepetition) {
|
||||
@@ -167,7 +168,7 @@ class RecurrenceUpdateService
|
||||
{
|
||||
$originalCount = $recurrence->recurrenceRepetitions()->count();
|
||||
if (1 === $originalCount) {
|
||||
app('log')->debug('Return the first one');
|
||||
Log::debug('Return the first one');
|
||||
|
||||
/** @var null|RecurrenceRepetition */
|
||||
return $recurrence->recurrenceRepetitions()->first();
|
||||
@@ -198,12 +199,12 @@ class RecurrenceUpdateService
|
||||
*/
|
||||
private function updateTransactions(Recurrence $recurrence, array $transactions): void
|
||||
{
|
||||
app('log')->debug('Now in updateTransactions()');
|
||||
Log::debug('Now in updateTransactions()');
|
||||
$originalCount = $recurrence->recurrenceTransactions()->count();
|
||||
app('log')->debug(sprintf('Original count is %d', $originalCount));
|
||||
Log::debug(sprintf('Original count is %d', $originalCount));
|
||||
if (0 === count($transactions)) {
|
||||
// won't drop transactions, rather avoid.
|
||||
app('log')->warning('No transactions to update, too scared to continue!');
|
||||
Log::warning('No transactions to update, too scared to continue!');
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -213,7 +214,7 @@ class RecurrenceUpdateService
|
||||
foreach ($originalTransactions as $i => $originalTransaction) {
|
||||
foreach ($transactions as $ii => $submittedTransaction) {
|
||||
if (array_key_exists('id', $submittedTransaction) && (int) $originalTransaction['id'] === (int) $submittedTransaction['id']) {
|
||||
app('log')->debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id']));
|
||||
Log::debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id']));
|
||||
$combinations[] = [
|
||||
'original' => $originalTransaction,
|
||||
'submitted' => $submittedTransaction,
|
||||
@@ -225,7 +226,7 @@ class RecurrenceUpdateService
|
||||
// If one left of both we can match those as well and presto.
|
||||
if (1 === count($originalTransactions) && 1 === count($transactions)) {
|
||||
$first = array_shift($originalTransactions);
|
||||
app('log')->debug(sprintf('One left of each, link them (ID is #%d)', $first['id']));
|
||||
Log::debug(sprintf('One left of each, link them (ID is #%d)', $first['id']));
|
||||
$combinations[] = [
|
||||
'original' => $first,
|
||||
'submitted' => array_shift($transactions),
|
||||
@@ -240,7 +241,7 @@ class RecurrenceUpdateService
|
||||
}
|
||||
// anything left in the original transactions array can be deleted.
|
||||
foreach ($originalTransactions as $original) {
|
||||
app('log')->debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id']));
|
||||
Log::debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id']));
|
||||
$this->deleteTransaction($recurrence, (int) $original['id']);
|
||||
}
|
||||
// anything left is new.
|
||||
@@ -261,7 +262,7 @@ class RecurrenceUpdateService
|
||||
|
||||
/** @var RecurrenceTransaction $transaction */
|
||||
$transaction = $recurrence->recurrenceTransactions()->find($original['id']);
|
||||
app('log')->debug(sprintf('Now in updateCombination(#%d)', $original['id']));
|
||||
Log::debug(sprintf('Now in updateCombination(#%d)', $original['id']));
|
||||
|
||||
// loop all and try to match them:
|
||||
$currency = null;
|
||||
@@ -269,7 +270,7 @@ class RecurrenceUpdateService
|
||||
if (array_key_exists('currency_id', $submitted) || array_key_exists('currency_code', $submitted)) {
|
||||
$currency = $currencyFactory->find(
|
||||
array_key_exists('currency_id', $submitted) ? (int) $submitted['currency_id'] : null,
|
||||
array_key_exists('currency_code', $submitted) ? $submitted['currency_code'] : null
|
||||
$submitted['currency_code'] ?? null
|
||||
);
|
||||
}
|
||||
if (null === $currency) {
|
||||
@@ -281,7 +282,7 @@ class RecurrenceUpdateService
|
||||
if (array_key_exists('foreign_currency_id', $submitted) || array_key_exists('foreign_currency_code', $submitted)) {
|
||||
$foreignCurrency = $currencyFactory->find(
|
||||
array_key_exists('foreign_currency_id', $submitted) ? (int) $submitted['foreign_currency_id'] : null,
|
||||
array_key_exists('foreign_currency_code', $submitted) ? $submitted['foreign_currency_code'] : null
|
||||
$submitted['foreign_currency_code'] ?? null
|
||||
);
|
||||
}
|
||||
if (null === $foreignCurrency) {
|
||||
@@ -317,13 +318,13 @@ class RecurrenceUpdateService
|
||||
// reset category if name is set but empty:
|
||||
// can be removed when v1 is retired.
|
||||
if (array_key_exists('category_name', $submitted) && '' === (string) $submitted['category_name']) {
|
||||
app('log')->debug('Category name is submitted but is empty. Set category to be empty.');
|
||||
Log::debug('Category name is submitted but is empty. Set category to be empty.');
|
||||
$submitted['category_name'] = null;
|
||||
$submitted['category_id'] = 0;
|
||||
}
|
||||
|
||||
if (array_key_exists('category_id', $submitted)) {
|
||||
app('log')->debug(sprintf('Category ID is submitted, set category to be %d.', (int) $submitted['category_id']));
|
||||
Log::debug(sprintf('Category ID is submitted, set category to be %d.', (int) $submitted['category_id']));
|
||||
$this->setCategory($transaction, (int) $submitted['category_id']);
|
||||
}
|
||||
|
||||
@@ -337,7 +338,7 @@ class RecurrenceUpdateService
|
||||
|
||||
private function deleteTransaction(Recurrence $recurrence, int $transactionId): void
|
||||
{
|
||||
app('log')->debug(sprintf('Will delete transaction #%d in recurrence #%d.', $transactionId, $recurrence->id));
|
||||
Log::debug(sprintf('Will delete transaction #%d in recurrence #%d.', $transactionId, $recurrence->id));
|
||||
$recurrence->recurrenceTransactions()->where('id', $transactionId)->delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user