Clean up code.

This commit is contained in:
James Cole
2023-12-10 06:45:59 +01:00
parent 9a807fc215
commit c2b22a2bac
157 changed files with 648 additions and 669 deletions

View File

@@ -64,7 +64,7 @@ class BillTransformer extends AbstractTransformer
foreach ($objects as $object) {
$id = $object->transaction_currency_id;
$bills[] = $object->id;
$currencies[$id] = $currencies[$id] ?? TransactionCurrency::find($id);
$currencies[$id] ??= TransactionCurrency::find($id);
}
$this->currencies = $currencies;
@@ -120,7 +120,7 @@ class BillTransformer extends AbstractTransformer
$transaction = $transactions[$journal->id] ?? [];
$billId = (int)$journal->bill_id;
$currencyId = (int)($transaction['transaction_currency_id'] ?? 0);
$currencies[$currencyId] = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
$currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
// foreign currency
$foreignCurrencyId = null;
@@ -132,7 +132,7 @@ class BillTransformer extends AbstractTransformer
if (null !== $transaction['foreign_currency_id']) {
app('log')->debug(sprintf('Foreign currency is #%d', $transaction['foreign_currency_id']));
$foreignCurrencyId = (int)$transaction['foreign_currency_id'];
$currencies[$foreignCurrencyId] = $currencies[$foreignCurrencyId] ?? TransactionCurrency::find($foreignCurrencyId);
$currencies[$foreignCurrencyId] ??= TransactionCurrency::find($foreignCurrencyId);
$foreignCurrencyCode = $currencies[$foreignCurrencyId]->code;
$foreignCurrencyName = $currencies[$foreignCurrencyId]->name;
$foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol;

View File

@@ -92,7 +92,7 @@ class PiggyBankTransformer extends AbstractTransformer
foreach ($currencyPreferences as $preference) {
$currencyId = (int)$preference->data;
$accountId = $preference->account_id;
$currencies[$currencyId] = $currencies[$currencyId] ?? TransactionJournal::find($currencyId);
$currencies[$currencyId] ??= TransactionJournal::find($currencyId);
$this->currencies[$accountId] = $currencies[$currencyId];
}

View File

@@ -62,7 +62,7 @@ class TransactionGroupTransformer extends AbstractTransformer
foreach ($objects as $object) {
foreach ($object['sums'] as $sum) {
$id = (int)$sum['currency_id'];
$currencies[$id] = $currencies[$id] ?? TransactionCurrency::find($sum['currency_id']);
$currencies[$id] ??= TransactionCurrency::find($sum['currency_id']);
}
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {