Various code cleanup and fixed alignments.

This commit is contained in:
James Cole
2024-01-01 14:43:56 +01:00
parent 1368aafe5f
commit f963ac63f1
443 changed files with 3668 additions and 3672 deletions

View File

@@ -55,28 +55,28 @@ class AccountTransformer extends AbstractTransformer
$this->repository->setUser($account->user);
// get account type:
$fullType = $account->accountType->type;
$accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
$liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');
$fullType = $account->accountType->type;
$accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));
$liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');
// get account role (will only work if the type is asset.
$accountRole = $this->getAccountRole($account, $accountType);
$date = $this->getDate();
$accountRole = $this->getAccountRole($account, $accountType);
$date = $this->getDate();
$date->endOfDay();
[$currencyId, $currencyCode, $currencySymbol, $decimalPlaces] = $this->getCurrency($account);
[$creditCardType, $monthlyPaymentDate] = $this->getCCInfo($account, $accountRole, $accountType);
[$openingBalance, $openingBalanceDate] = $this->getOpeningBalance($account, $accountType);
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
[$creditCardType, $monthlyPaymentDate] = $this->getCCInfo($account, $accountRole, $accountType);
[$openingBalance, $openingBalanceDate] = $this->getOpeningBalance($account, $accountType);
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
$openingBalance = app('steam')->bcround($openingBalance, $decimalPlaces);
$includeNetWorth = '0' !== $this->repository->getMetaValue($account, 'include_net_worth');
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->repository->getLocation($account);
$openingBalance = app('steam')->bcround($openingBalance, $decimalPlaces);
$includeNetWorth = '0' !== $this->repository->getMetaValue($account, 'include_net_worth');
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->repository->getLocation($account);
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
@@ -84,7 +84,7 @@ class AccountTransformer extends AbstractTransformer
}
// no order for some accounts:
$order = $account->order;
$order = $account->order;
if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {
$order = null;
}
@@ -159,7 +159,7 @@ class AccountTransformer extends AbstractTransformer
*/
private function getCurrency(Account $account): array
{
$currency = $this->repository->getAccountCurrency($account);
$currency = $this->repository->getAccountCurrency($account);
// only grab default when result is null:
if (null === $currency) {
@@ -184,7 +184,7 @@ class AccountTransformer extends AbstractTransformer
if (null !== $monthlyPaymentDate) {
// try classic date:
if (10 === strlen($monthlyPaymentDate)) {
$object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'));
$object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'));
if (false === $object) {
$object = today(config('app.timezone'));
}
@@ -213,7 +213,7 @@ class AccountTransformer extends AbstractTransformer
$openingBalanceDate = $this->repository->getOpeningBalanceDate($account);
}
if (null !== $openingBalanceDate) {
$object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'));
$object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'));
if (false === $object) {
$object = today(config('app.timezone'));
}

View File

@@ -57,21 +57,21 @@ class BillTransformer extends AbstractTransformer
*/
public function transform(Bill $bill): array
{
$paidData = $this->paidData($bill);
$lastPaidDate = $this->getLastPaidDate($paidData);
$start = $this->parameters->get('start') ?? today()->subYears(10);
$end = $this->parameters->get('end') ?? today()->addYears(10);
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
$currency = $bill->transactionCurrency;
$notes = $this->repository->getNoteText($bill);
$notes = '' === $notes ? null : $notes;
$objectGroupId = null;
$objectGroupOrder = null;
$objectGroupTitle = null;
$paidData = $this->paidData($bill);
$lastPaidDate = $this->getLastPaidDate($paidData);
$start = $this->parameters->get('start') ?? today()->subYears(10);
$end = $this->parameters->get('end') ?? today()->addYears(10);
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
$currency = $bill->transactionCurrency;
$notes = $this->repository->getNoteText($bill);
$notes = '' === $notes ? null : $notes;
$objectGroupId = null;
$objectGroupOrder = null;
$objectGroupTitle = null;
$this->repository->setUser($bill->user);
/** @var null|ObjectGroup $objectGroup */
$objectGroup = $bill->objectGroups->first();
$objectGroup = $bill->objectGroups->first();
if (null !== $objectGroup) {
$objectGroupId = $objectGroup->id;
$objectGroupOrder = $objectGroup->order;
@@ -81,7 +81,7 @@ class BillTransformer extends AbstractTransformer
$paidDataFormatted = [];
$payDatesFormatted = [];
foreach ($paidData as $object) {
$date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));
$date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));
if (false === $date) {
$date = today(config('app.timezone'));
}
@@ -90,24 +90,24 @@ class BillTransformer extends AbstractTransformer
}
foreach ($payDates as $string) {
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
if (false === $date) {
$date = today(config('app.timezone'));
}
$payDatesFormatted[] = $date->toAtomString();
}
// next expected match
$nem = null;
$nemDate = null;
$nemDiff = trans('firefly.not_expected_period');
$firstPayDate = $payDates[0] ?? null;
$nem = null;
$nemDate = null;
$nemDiff = trans('firefly.not_expected_period');
$firstPayDate = $payDates[0] ?? null;
if (null !== $firstPayDate) {
$nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));
if (false === $nemDate) {
$nemDate = today(config('app.timezone'));
}
$nem = $nemDate->toAtomString();
$nem = $nemDate->toAtomString();
// nullify again when it's outside the current view range.
if ($nemDate->lt($this->parameters->get('start')) || $nemDate->gt($this->parameters->get('end'))) {
@@ -125,7 +125,7 @@ class BillTransformer extends AbstractTransformer
$current = $payDatesFormatted[0] ?? null;
if (null !== $current && !$nemDate->isToday()) {
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
if (false === $temp2) {
$temp2 = today(config('app.timezone'));
}
@@ -187,15 +187,15 @@ class BillTransformer extends AbstractTransformer
// 2023-07-18 this particular date is used to search for the last paid date.
// 2023-07-18 the cloned $searchDate is used to grab the correct transactions.
/** @var Carbon $start */
$start = clone $this->parameters->get('start');
$searchStart = clone $start;
$start = clone $this->parameters->get('start');
$searchStart = clone $start;
$start->subDay();
app('log')->debug(sprintf('Parameters are start: %s end: %s', $start->format('Y-m-d'), $this->parameters->get('end')->format('Y-m-d')));
app('log')->debug(sprintf('Search parameters are: start: %s', $searchStart->format('Y-m-d')));
// Get from database when bill was paid.
$set = $this->repository->getPaidDatesInRange($bill, $searchStart, $this->parameters->get('end'));
$set = $this->repository->getPaidDatesInRange($bill, $searchStart, $this->parameters->get('end'));
app('log')->debug(sprintf('Count %d entries in getPaidDatesInRange()', $set->count()));
// Grab from array the most recent payment. If none exist, fall back to the start date and pretend *that* was the last paid date.
@@ -204,7 +204,7 @@ class BillTransformer extends AbstractTransformer
app('log')->debug(sprintf('Result of lastPaidDate is %s', $lastPaidDate->format('Y-m-d')));
// At this point the "next match" is exactly after the last time the bill was paid.
$result = [];
$result = [];
foreach ($set as $entry) {
$result[] = [
'transaction_group_id' => (string) $entry->transaction_group_id,

View File

@@ -53,7 +53,7 @@ class BudgetLimitTransformer extends AbstractTransformer
*/
public function transform(BudgetLimit $budgetLimit): array
{
$repository = app(OperationsRepository::class);
$repository = app(OperationsRepository::class);
$repository->setUser($budgetLimit->budget->user);
$expenses = $repository->sumExpenses(
$budgetLimit->start_date,
@@ -77,7 +77,7 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencySymbol = $currency->symbol;
$currencyDecimalPlaces = $currency->decimal_places;
}
$amount = app('steam')->bcround($amount, $currencyDecimalPlaces);
$amount = app('steam')->bcround($amount, $currencyDecimalPlaces);
return [
'id' => (string)$budgetLimit->id,

View File

@@ -54,10 +54,10 @@ class BudgetTransformer extends AbstractTransformer
public function transform(Budget $budget): array
{
$this->opsRepository->setUser($budget->user);
$start = $this->parameters->get('start');
$end = $this->parameters->get('end');
$autoBudget = $this->repository->getAutoBudget($budget);
$spent = [];
$start = $this->parameters->get('start');
$end = $this->parameters->get('end');
$autoBudget = $this->repository->getAutoBudget($budget);
$spent = [];
if (null !== $start && null !== $end) {
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
}
@@ -69,7 +69,7 @@ class BudgetTransformer extends AbstractTransformer
$abPeriod = null;
$notes = $this->repository->getNoteText($budget);
$types = [
$types = [
AutoBudget::AUTO_BUDGET_RESET => 'reset',
AutoBudget::AUTO_BUDGET_ROLLOVER => 'rollover',
AutoBudget::AUTO_BUDGET_ADJUSTED => 'adjusted',

View File

@@ -61,7 +61,7 @@ class CategoryTransformer extends AbstractTransformer
$earned = $this->beautify($this->opsRepository->sumIncome($start, $end, null, new Collection([$category])));
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$category])));
}
$notes = $this->repository->getNoteText($category);
$notes = $this->repository->getNoteText($category);
return [
'id' => $category->id,

View File

@@ -53,14 +53,14 @@ class PiggyBankEventTransformer extends AbstractTransformer
public function transform(PiggyBankEvent $event): array
{
// get account linked to piggy bank
$account = $event->piggyBank->account;
$account = $event->piggyBank->account;
// set up repositories.
$this->repository->setUser($account->user);
$this->piggyRepos->setUser($account->user);
// get associated currency or fall back to the default:
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
// get associated journal and transaction, if any:
$journalId = $event->transaction_journal_id;

View File

@@ -53,25 +53,25 @@ class PiggyBankTransformer extends AbstractTransformer
*/
public function transform(PiggyBank $piggyBank): array
{
$account = $piggyBank->account;
$account = $piggyBank->account;
// set up repositories
$this->accountRepos->setUser($account->user);
$this->piggyRepos->setUser($account->user);
// get currency from account, or use default.
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
$currency = $this->accountRepos->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
// note
$notes = $this->piggyRepos->getNoteText($piggyBank);
$notes = '' === $notes ? null : $notes;
$notes = $this->piggyRepos->getNoteText($piggyBank);
$notes = '' === $notes ? null : $notes;
$objectGroupId = null;
$objectGroupOrder = null;
$objectGroupTitle = null;
/** @var null|ObjectGroup $objectGroup */
$objectGroup = $piggyBank->objectGroups->first();
$objectGroup = $piggyBank->objectGroups->first();
if (null !== $objectGroup) {
$objectGroupId = $objectGroup->id;
$objectGroupOrder = $objectGroup->order;
@@ -79,13 +79,13 @@ class PiggyBankTransformer extends AbstractTransformer
}
// get currently saved amount:
$currentAmount = app('steam')->bcround($this->piggyRepos->getCurrentAmount($piggyBank), $currency->decimal_places);
$currentAmount = app('steam')->bcround($this->piggyRepos->getCurrentAmount($piggyBank), $currency->decimal_places);
// Amounts, depending on 0.0 state of target amount
$percentage = null;
$targetAmount = $piggyBank->targetamount;
$leftToSave = null;
$savePerMonth = null;
$percentage = null;
$targetAmount = $piggyBank->targetamount;
$leftToSave = null;
$savePerMonth = null;
if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00
$leftToSave = bcsub($piggyBank->targetamount, $currentAmount);
$percentage = (int)bcmul(bcdiv($currentAmount, $targetAmount), '100');
@@ -93,8 +93,8 @@ class PiggyBankTransformer extends AbstractTransformer
$leftToSave = app('steam')->bcround($leftToSave, $currency->decimal_places);
$savePerMonth = app('steam')->bcround($this->piggyRepos->getSuggestedMonthlyAmount($piggyBank), $currency->decimal_places);
}
$startDate = $piggyBank->startdate?->format('Y-m-d');
$targetDate = $piggyBank->targetdate?->format('Y-m-d');
$startDate = $piggyBank->startdate?->format('Y-m-d');
$targetDate = $piggyBank->targetdate?->format('Y-m-d');
return [
'id' => (string)$piggyBank->id,

View File

@@ -128,14 +128,14 @@ class RecurrenceTransformer extends AbstractTransformer
];
// get the (future) occurrences for this specific type of repetition:
$occurrences = $this->repository->getXOccurrencesSince($repetition, $fromDate, new Carbon(), 5);
$occurrences = $this->repository->getXOccurrencesSince($repetition, $fromDate, new Carbon(), 5);
/** @var Carbon $carbon */
foreach ($occurrences as $carbon) {
$repetitionArray['occurrences'][] = $carbon->toAtomString();
}
$return[] = $repetitionArray;
$return[] = $repetitionArray;
}
return $return;
@@ -153,7 +153,7 @@ class RecurrenceTransformer extends AbstractTransformer
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions()->get() as $transaction) {
/** @var null|Account $sourceAccount */
$sourceAccount = $transaction->sourceAccount;
$sourceAccount = $transaction->sourceAccount;
/** @var null|Account $destinationAccount */
$destinationAccount = $transaction->destinationAccount;
@@ -169,32 +169,32 @@ class RecurrenceTransformer extends AbstractTransformer
}
// source info:
$sourceName = '';
$sourceId = null;
$sourceType = null;
$sourceIban = null;
$sourceName = '';
$sourceId = null;
$sourceType = null;
$sourceIban = null;
if (null !== $sourceAccount) {
$sourceName = $sourceAccount->name;
$sourceId = $sourceAccount->id;
$sourceType = $sourceAccount->accountType->type;
$sourceIban = $sourceAccount->iban;
}
$destinationName = '';
$destinationId = null;
$destinationType = null;
$destinationIban = null;
$destinationName = '';
$destinationId = null;
$destinationType = null;
$destinationIban = null;
if (null !== $destinationAccount) {
$destinationName = $destinationAccount->name;
$destinationId = $destinationAccount->id;
$destinationType = $destinationAccount->accountType->type;
$destinationIban = $destinationAccount->iban;
}
$amount = app('steam')->bcround($transaction->amount, $transaction->transactionCurrency->decimal_places);
$foreignAmount = null;
$amount = app('steam')->bcround($transaction->amount, $transaction->transactionCurrency->decimal_places);
$foreignAmount = null;
if (null !== $transaction->foreign_currency_id && null !== $transaction->foreign_amount) {
$foreignAmount = app('steam')->bcround($transaction->foreign_amount, $foreignCurrencyDp);
}
$transactionArray = [
$transactionArray = [
'id' => (string)$transaction->id,
'currency_id' => (string)$transaction->transaction_currency_id,
'currency_code' => $transaction->transactionCurrency->code,
@@ -216,7 +216,7 @@ class RecurrenceTransformer extends AbstractTransformer
'foreign_amount' => $foreignAmount,
'description' => $transaction->description,
];
$transactionArray = $this->getTransactionMeta($transaction, $transactionArray);
$transactionArray = $this->getTransactionMeta($transaction, $transactionArray);
if (null !== $transaction->foreign_currency_id) {
$transactionArray['foreign_currency_code'] = $transaction->foreignCurrency->code;
$transactionArray['foreign_currency_symbol'] = $transaction->foreignCurrency->symbol;
@@ -224,7 +224,7 @@ class RecurrenceTransformer extends AbstractTransformer
}
// store transaction in recurrence array.
$return[] = $transactionArray;
$return[] = $transactionArray;
}
return $return;
@@ -253,7 +253,7 @@ class RecurrenceTransformer extends AbstractTransformer
throw new FireflyException(sprintf('Recurrence transformer cant handle field "%s"', $transactionMeta->name));
case 'bill_id':
$bill = $this->billRepos->find((int)$transactionMeta->value);
$bill = $this->billRepos->find((int)$transactionMeta->value);
if (null !== $bill) {
$array['bill_id'] = (string)$bill->id;
$array['bill_name'] = $bill->name;
@@ -267,7 +267,7 @@ class RecurrenceTransformer extends AbstractTransformer
break;
case 'piggy_bank_id':
$piggy = $this->piggyRepos->find((int)$transactionMeta->value);
$piggy = $this->piggyRepos->find((int)$transactionMeta->value);
if (null !== $piggy) {
$array['piggy_bank_id'] = (string)$piggy->id;
$array['piggy_bank_name'] = $piggy->name;
@@ -276,7 +276,7 @@ class RecurrenceTransformer extends AbstractTransformer
break;
case 'category_id':
$category = $this->factory->findOrCreate((int)$transactionMeta->value, null);
$category = $this->factory->findOrCreate((int)$transactionMeta->value, null);
if (null !== $category) {
$array['category_id'] = (string)$category->id;
$array['category_name'] = $category->name;
@@ -285,7 +285,7 @@ class RecurrenceTransformer extends AbstractTransformer
break;
case 'category_name':
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
$category = $this->factory->findOrCreate(null, $transactionMeta->value);
if (null !== $category) {
$array['category_id'] = (string)$category->id;
$array['category_name'] = $category->name;
@@ -294,7 +294,7 @@ class RecurrenceTransformer extends AbstractTransformer
break;
case 'budget_id':
$budget = $this->budgetRepos->find((int)$transactionMeta->value);
$budget = $this->budgetRepos->find((int)$transactionMeta->value);
if (null !== $budget) {
$array['budget_id'] = (string)$budget->id;
$array['budget_name'] = $budget->name;

View File

@@ -38,7 +38,7 @@ class TagTransformer extends AbstractTransformer
*/
public function transform(Tag $tag): array
{
$date = $tag->date?->format('Y-m-d');
$date = $tag->date?->format('Y-m-d');
/** @var null|Location $location */
$location = $tag->locations()->first();

View File

@@ -143,7 +143,7 @@ class TransactionGroupTransformer extends AbstractTransformer
*/
private function transformTransaction(array $transaction): array
{
$row = new NullArrayObject($transaction);
$row = new NullArrayObject($transaction);
// amount:
$amount = app('steam')->positive((string) ($row['amount'] ?? '0'));
@@ -156,10 +156,10 @@ class TransactionGroupTransformer extends AbstractTransformer
$metaDateData = $this->groupRepos->getMetaDateFields((int) $row['transaction_journal_id'], $this->metaDateFields);
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionType::WITHDRAWAL);
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->getLocationById((int) $row['transaction_journal_id']);
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->getLocationById((int) $row['transaction_journal_id']);
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
@@ -167,83 +167,83 @@ class TransactionGroupTransformer extends AbstractTransformer
}
return [
'user' => (string) $row['user_id'],
'transaction_journal_id' => (string) $row['transaction_journal_id'],
'type' => strtolower($type),
'date' => $row['date']->toAtomString(),
'order' => $row['order'],
'user' => (string) $row['user_id'],
'transaction_journal_id' => (string) $row['transaction_journal_id'],
'type' => strtolower($type),
'date' => $row['date']->toAtomString(),
'order' => $row['order'],
'currency_id' => (string) $row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_name' => $row['currency_name'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => (int) $row['currency_decimal_places'],
'currency_id' => (string) $row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_name' => $row['currency_name'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => (int) $row['currency_decimal_places'],
'foreign_currency_id' => $this->stringFromArray($transaction, 'foreign_currency_id', null),
'foreign_currency_code' => $row['foreign_currency_code'],
'foreign_currency_symbol' => $row['foreign_currency_symbol'],
'foreign_currency_decimal_places' => $row['foreign_currency_decimal_places'],
'amount' => $amount,
'foreign_amount' => $foreignAmount,
'amount' => $amount,
'foreign_amount' => $foreignAmount,
'description' => $row['description'],
'description' => $row['description'],
'source_id' => (string) $row['source_account_id'],
'source_name' => $row['source_account_name'],
'source_iban' => $row['source_account_iban'],
'source_type' => $row['source_account_type'],
'source_id' => (string) $row['source_account_id'],
'source_name' => $row['source_account_name'],
'source_iban' => $row['source_account_iban'],
'source_type' => $row['source_account_type'],
'destination_id' => (string) $row['destination_account_id'],
'destination_name' => $row['destination_account_name'],
'destination_iban' => $row['destination_account_iban'],
'destination_type' => $row['destination_account_type'],
'destination_id' => (string) $row['destination_account_id'],
'destination_name' => $row['destination_account_name'],
'destination_iban' => $row['destination_account_iban'],
'destination_type' => $row['destination_account_type'],
'budget_id' => $this->stringFromArray($transaction, 'budget_id', null),
'budget_name' => $row['budget_name'],
'budget_id' => $this->stringFromArray($transaction, 'budget_id', null),
'budget_name' => $row['budget_name'],
'category_id' => $this->stringFromArray($transaction, 'category_id', null),
'category_name' => $row['category_name'],
'category_id' => $this->stringFromArray($transaction, 'category_id', null),
'category_name' => $row['category_name'],
'bill_id' => $this->stringFromArray($transaction, 'bill_id', null),
'bill_name' => $row['bill_name'],
'bill_id' => $this->stringFromArray($transaction, 'bill_id', null),
'bill_name' => $row['bill_name'],
'reconciled' => $row['reconciled'],
'notes' => $this->groupRepos->getNoteText((int) $row['transaction_journal_id']),
'tags' => $this->groupRepos->getTags((int) $row['transaction_journal_id']),
'reconciled' => $row['reconciled'],
'notes' => $this->groupRepos->getNoteText((int) $row['transaction_journal_id']),
'tags' => $this->groupRepos->getTags((int) $row['transaction_journal_id']),
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
'original_source' => $metaFieldData['original_source'],
'recurrence_id' => $this->stringFromArray($metaFieldData->getArrayCopy(), 'recurrence_id', null),
'recurrence_total' => $this->integerFromArray($metaFieldData->getArrayCopy(), 'recurrence_total'),
'recurrence_count' => $this->integerFromArray($metaFieldData->getArrayCopy(), 'recurrence_count'),
'bunq_payment_id' => $metaFieldData['bunq_payment_id'],
'external_url' => $metaFieldData['external_url'],
'import_hash_v2' => $metaFieldData['import_hash_v2'],
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
'original_source' => $metaFieldData['original_source'],
'recurrence_id' => $this->stringFromArray($metaFieldData->getArrayCopy(), 'recurrence_id', null),
'recurrence_total' => $this->integerFromArray($metaFieldData->getArrayCopy(), 'recurrence_total'),
'recurrence_count' => $this->integerFromArray($metaFieldData->getArrayCopy(), 'recurrence_count'),
'bunq_payment_id' => $metaFieldData['bunq_payment_id'],
'external_url' => $metaFieldData['external_url'],
'import_hash_v2' => $metaFieldData['import_hash_v2'],
'sepa_cc' => $metaFieldData['sepa_cc'],
'sepa_ct_op' => $metaFieldData['sepa_ct_op'],
'sepa_ct_id' => $metaFieldData['sepa_ct_id'],
'sepa_db' => $metaFieldData['sepa_db'],
'sepa_country' => $metaFieldData['sepa_country'],
'sepa_ep' => $metaFieldData['sepa_ep'],
'sepa_ci' => $metaFieldData['sepa_ci'],
'sepa_batch_id' => $metaFieldData['sepa_batch_id'],
'sepa_cc' => $metaFieldData['sepa_cc'],
'sepa_ct_op' => $metaFieldData['sepa_ct_op'],
'sepa_ct_id' => $metaFieldData['sepa_ct_id'],
'sepa_db' => $metaFieldData['sepa_db'],
'sepa_country' => $metaFieldData['sepa_country'],
'sepa_ep' => $metaFieldData['sepa_ep'],
'sepa_ci' => $metaFieldData['sepa_ci'],
'sepa_batch_id' => $metaFieldData['sepa_batch_id'],
'interest_date' => $this->dateFromArray($metaDateData, 'interest_date'),
'book_date' => $this->dateFromArray($metaDateData, 'book_date'),
'process_date' => $this->dateFromArray($metaDateData, 'process_date'),
'due_date' => $this->dateFromArray($metaDateData, 'due_date'),
'payment_date' => $this->dateFromArray($metaDateData, 'payment_date'),
'invoice_date' => $this->dateFromArray($metaDateData, 'invoice_date'),
'interest_date' => $this->dateFromArray($metaDateData, 'interest_date'),
'book_date' => $this->dateFromArray($metaDateData, 'book_date'),
'process_date' => $this->dateFromArray($metaDateData, 'process_date'),
'due_date' => $this->dateFromArray($metaDateData, 'due_date'),
'payment_date' => $this->dateFromArray($metaDateData, 'payment_date'),
'invoice_date' => $this->dateFromArray($metaDateData, 'invoice_date'),
// location data
'longitude' => $longitude,
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
'longitude' => $longitude,
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
'has_attachments' => $this->hasAttachments((int) $row['transaction_journal_id']),
'has_attachments' => $this->hasAttachments((int) $row['transaction_journal_id']),
];
}
@@ -342,10 +342,10 @@ class TransactionGroupTransformer extends AbstractTransformer
$foreignAmount = app('steam')->bcround($foreignAmount, $foreignCurrency['decimal_places'] ?? 0);
}
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->getLocation($journal);
$longitude = null;
$latitude = null;
$zoomLevel = null;
$location = $this->getLocation($journal);
if (null !== $location) {
$longitude = $location->longitude;
$latitude = $location->latitude;
@@ -353,77 +353,77 @@ class TransactionGroupTransformer extends AbstractTransformer
}
return [
'user' => $journal->user_id,
'transaction_journal_id' => $journal->id,
'type' => strtolower($type),
'date' => $journal->date->toAtomString(),
'order' => $journal->order,
'user' => $journal->user_id,
'transaction_journal_id' => $journal->id,
'type' => strtolower($type),
'date' => $journal->date->toAtomString(),
'order' => $journal->order,
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'foreign_currency_id' => $foreignCurrency['id'],
'foreign_currency_code' => $foreignCurrency['code'],
'foreign_currency_symbol' => $foreignCurrency['symbol'],
'foreign_currency_decimal_places' => $foreignCurrency['decimal_places'],
'amount' => app('steam')->bcround($amount, $currency->decimal_places),
'foreign_amount' => $foreignAmount,
'amount' => app('steam')->bcround($amount, $currency->decimal_places),
'foreign_amount' => $foreignAmount,
'description' => $journal->description,
'description' => $journal->description,
'source_id' => $source->account_id,
'source_name' => $source->account->name,
'source_iban' => $source->account->iban,
'source_type' => $source->account->accountType->type,
'source_id' => $source->account_id,
'source_name' => $source->account->name,
'source_iban' => $source->account->iban,
'source_type' => $source->account->accountType->type,
'destination_id' => $destination->account_id,
'destination_name' => $destination->account->name,
'destination_iban' => $destination->account->iban,
'destination_type' => $destination->account->accountType->type,
'destination_id' => $destination->account_id,
'destination_name' => $destination->account->name,
'destination_iban' => $destination->account->iban,
'destination_type' => $destination->account->accountType->type,
'budget_id' => $budget['id'],
'budget_name' => $budget['name'],
'budget_id' => $budget['id'],
'budget_name' => $budget['name'],
'category_id' => $category['id'],
'category_name' => $category['name'],
'category_id' => $category['id'],
'category_name' => $category['name'],
'bill_id' => $bill['id'],
'bill_name' => $bill['name'],
'bill_id' => $bill['id'],
'bill_name' => $bill['name'],
'reconciled' => $source->reconciled,
'notes' => $this->groupRepos->getNoteText($journal->id),
'tags' => $this->groupRepos->getTags($journal->id),
'reconciled' => $source->reconciled,
'notes' => $this->groupRepos->getNoteText($journal->id),
'tags' => $this->groupRepos->getTags($journal->id),
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
'original_source' => $metaFieldData['original_source'],
'recurrence_id' => $metaFieldData['recurrence_id'],
'bunq_payment_id' => $metaFieldData['bunq_payment_id'],
'import_hash_v2' => $metaFieldData['import_hash_v2'],
'internal_reference' => $metaFieldData['internal_reference'],
'external_id' => $metaFieldData['external_id'],
'original_source' => $metaFieldData['original_source'],
'recurrence_id' => $metaFieldData['recurrence_id'],
'bunq_payment_id' => $metaFieldData['bunq_payment_id'],
'import_hash_v2' => $metaFieldData['import_hash_v2'],
'sepa_cc' => $metaFieldData['sepa_cc'],
'sepa_ct_op' => $metaFieldData['sepa_ct_op'],
'sepa_ct_id' => $metaFieldData['sepa_ct_id'],
'sepa_db' => $metaFieldData['sepa_db'],
'sepa_country' => $metaFieldData['sepa_country'],
'sepa_ep' => $metaFieldData['sepa_ep'],
'sepa_ci' => $metaFieldData['sepa_ci'],
'sepa_batch_id' => $metaFieldData['sepa_batch_id'],
'sepa_cc' => $metaFieldData['sepa_cc'],
'sepa_ct_op' => $metaFieldData['sepa_ct_op'],
'sepa_ct_id' => $metaFieldData['sepa_ct_id'],
'sepa_db' => $metaFieldData['sepa_db'],
'sepa_country' => $metaFieldData['sepa_country'],
'sepa_ep' => $metaFieldData['sepa_ep'],
'sepa_ci' => $metaFieldData['sepa_ci'],
'sepa_batch_id' => $metaFieldData['sepa_batch_id'],
'interest_date' => $metaDates['interest_date'],
'book_date' => $metaDates['book_date'],
'process_date' => $metaDates['process_date'],
'due_date' => $metaDates['due_date'],
'payment_date' => $metaDates['payment_date'],
'invoice_date' => $metaDates['invoice_date'],
'interest_date' => $metaDates['interest_date'],
'book_date' => $metaDates['book_date'],
'process_date' => $metaDates['process_date'],
'due_date' => $metaDates['due_date'],
'payment_date' => $metaDates['payment_date'],
'invoice_date' => $metaDates['invoice_date'],
// location data
'longitude' => $longitude,
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
'longitude' => $longitude,
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
];
}
@@ -499,7 +499,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function getForeignCurrency(?TransactionCurrency $currency): array
{
$array = [
$array = [
'id' => null,
'code' => null,
'symbol' => null,
@@ -518,7 +518,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function getBudget(?Budget $budget): array
{
$array = [
$array = [
'id' => null,
'name' => null,
];
@@ -533,7 +533,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function getCategory(?Category $category): array
{
$array = [
$array = [
'id' => null,
'name' => null,
];
@@ -548,7 +548,7 @@ class TransactionGroupTransformer extends AbstractTransformer
private function getBill(?Bill $bill): array
{
$array = [
$array = [
'id' => null,
'name' => null,
];

View File

@@ -57,18 +57,18 @@ class AccountTransformer extends AbstractTransformer
$this->convertedBalances = app('steam')->balancesByAccountsConverted($objects, $this->getDate());
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
$this->default = app('amount')->getDefaultCurrency();
$repository = app(CurrencyRepositoryInterface::class);
$this->default = app('amount')->getDefaultCurrency();
// get currencies:
$accountIds = $objects->pluck('id')->toArray();
$meta = AccountMeta::whereIn('account_id', $accountIds)
$accountIds = $objects->pluck('id')->toArray();
$meta = AccountMeta::whereIn('account_id', $accountIds)
->where('name', 'currency_id')
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data'])
;
$currencyIds = $meta->pluck('data')->toArray();
$currencyIds = $meta->pluck('data')->toArray();
$currencies = $repository->getByIds($currencyIds);
$currencies = $repository->getByIds($currencyIds);
foreach ($currencies as $currency) {
$id = $currency->id;
$this->currencies[$id] = $currency;
@@ -79,7 +79,7 @@ class AccountTransformer extends AbstractTransformer
}
// get account types:
// select accounts.id, account_types.type from account_types left join accounts on accounts.account_type_id = account_types.id;
$accountTypes = AccountType::leftJoin('accounts', 'accounts.account_type_id', '=', 'account_types.id')
$accountTypes = AccountType::leftJoin('accounts', 'accounts.account_type_id', '=', 'account_types.id')
->whereIn('accounts.id', $accountIds)
->get(['accounts.id', 'account_types.type'])
;
@@ -95,15 +95,15 @@ class AccountTransformer extends AbstractTransformer
*/
public function transform(Account $account): array
{
$id = $account->id;
$id = $account->id;
// various meta
$accountRole = $this->accountMeta[$id]['account_role'] ?? null;
$accountType = $this->accountTypes[$id];
$order = $account->order;
$accountRole = $this->accountMeta[$id]['account_role'] ?? null;
$accountType = $this->accountTypes[$id];
$order = $account->order;
// no currency? use default
$currency = $this->default;
$currency = $this->default;
if (0 !== (int)$this->accountMeta[$id]['currency_id']) {
$currency = $this->currencies[(int)$this->accountMeta[$id]['currency_id']];
}
@@ -117,19 +117,19 @@ class AccountTransformer extends AbstractTransformer
}
return [
'id' => (string)$account->id,
'created_at' => $account->created_at->toAtomString(),
'updated_at' => $account->updated_at->toAtomString(),
'active' => $account->active,
'order' => $order,
'name' => $account->name,
'iban' => '' === $account->iban ? null : $account->iban,
'type' => strtolower($accountType),
'account_role' => $accountRole,
'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'id' => (string)$account->id,
'created_at' => $account->created_at->toAtomString(),
'updated_at' => $account->updated_at->toAtomString(),
'active' => $account->active,
'order' => $order,
'name' => $account->name,
'iban' => '' === $account->iban ? null : $account->iban,
'type' => strtolower($accountType),
'account_role' => $accountRole,
'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'native_currency_id' => (string)$this->default->id,
'native_currency_code' => $this->default->code,

View File

@@ -56,16 +56,16 @@ class BillTransformer extends AbstractTransformer
*/
public function collectMetaData(Collection $objects): void
{
$currencies = [];
$bills = [];
$this->notes = [];
$this->groups = [];
$this->paidDates = [];
$currencies = [];
$bills = [];
$this->notes = [];
$this->groups = [];
$this->paidDates = [];
/** @var Bill $object */
foreach ($objects as $object) {
$id = $object->transaction_currency_id;
$bills[] = $object->id;
$id = $object->transaction_currency_id;
$bills[] = $object->id;
$currencies[$id] ??= TransactionCurrency::find($id);
}
$this->currencies = $currencies;
@@ -77,7 +77,7 @@ class BillTransformer extends AbstractTransformer
$this->notes[$id] = $note;
}
// grab object groups:
$set = DB::table('object_groupables')
$set = DB::table('object_groupables')
->leftJoin('object_groups', 'object_groups.id', '=', 'object_groupables.object_group_id')
->where('object_groupables.object_groupable_type', Bill::class)
->get(['object_groupables.*', 'object_groups.title', 'object_groups.order'])
@@ -95,17 +95,17 @@ class BillTransformer extends AbstractTransformer
];
}
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$this->default = app('amount')->getDefaultCurrency();
$this->converter = new ExchangeRateConverter();
$this->default = app('amount')->getDefaultCurrency();
$this->converter = new ExchangeRateConverter();
// grab all paid dates:
if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {
$journals = TransactionJournal::whereIn('bill_id', $bills)
$journals = TransactionJournal::whereIn('bill_id', $bills)
->where('date', '>=', $this->parameters->get('start'))
->where('date', '<=', $this->parameters->get('end'))
->get(['transaction_journals.id', 'transaction_journals.transaction_group_id', 'transaction_journals.date', 'transaction_journals.bill_id'])
;
$journalIds = $journals->pluck('id')->toArray();
$journalIds = $journals->pluck('id')->toArray();
// grab transactions for amount:
$set = Transaction::whereIn('transaction_journal_id', $journalIds)
@@ -123,26 +123,26 @@ class BillTransformer extends AbstractTransformer
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
app('log')->debug(sprintf('Processing journal #%d', $journal->id));
$transaction = $transactions[$journal->id] ?? [];
$billId = (int) $journal->bill_id;
$currencyId = (int) ($transaction['transaction_currency_id'] ?? 0);
$transaction = $transactions[$journal->id] ?? [];
$billId = (int) $journal->bill_id;
$currencyId = (int) ($transaction['transaction_currency_id'] ?? 0);
$currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
// foreign currency
$foreignCurrencyId = null;
$foreignCurrencyCode = null;
$foreignCurrencyName = null;
$foreignCurrencySymbol = null;
$foreignCurrencyDp = null;
$foreignCurrencyId = null;
$foreignCurrencyCode = null;
$foreignCurrencyName = null;
$foreignCurrencySymbol = null;
$foreignCurrencyDp = null;
app('log')->debug('Foreign currency is NULL');
if (null !== $transaction['foreign_currency_id']) {
app('log')->debug(sprintf('Foreign currency is #%d', $transaction['foreign_currency_id']));
$foreignCurrencyId = (int) $transaction['foreign_currency_id'];
$foreignCurrencyId = (int) $transaction['foreign_currency_id'];
$currencies[$foreignCurrencyId] ??= TransactionCurrency::find($foreignCurrencyId);
$foreignCurrencyCode = $currencies[$foreignCurrencyId]->code;
$foreignCurrencyName = $currencies[$foreignCurrencyId]->name;
$foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol;
$foreignCurrencyDp = $currencies[$foreignCurrencyId]->decimal_places;
$foreignCurrencyCode = $currencies[$foreignCurrencyId]->code;
$foreignCurrencyName = $currencies[$foreignCurrencyId]->name;
$foreignCurrencySymbol = $currencies[$foreignCurrencyId]->symbol;
$foreignCurrencyDp = $currencies[$foreignCurrencyId]->decimal_places;
}
$this->paidDates[$billId][] = [
@@ -182,18 +182,18 @@ class BillTransformer extends AbstractTransformer
*/
public function transform(Bill $bill): array
{
$paidData = $this->paidDates[$bill->id] ?? [];
$nextExpectedMatch = $this->nextExpectedMatch($bill, $this->paidDates[$bill->id] ?? []);
$payDates = $this->payDates($bill);
$currency = $this->currencies[$bill->transaction_currency_id];
$group = $this->groups[$bill->id] ?? null;
$paidData = $this->paidDates[$bill->id] ?? [];
$nextExpectedMatch = $this->nextExpectedMatch($bill, $this->paidDates[$bill->id] ?? []);
$payDates = $this->payDates($bill);
$currency = $this->currencies[$bill->transaction_currency_id];
$group = $this->groups[$bill->id] ?? null;
// date for currency conversion
/** @var null|Carbon $startParam */
$startParam = $this->parameters->get('start');
$startParam = $this->parameters->get('start');
/** @var null|Carbon $date */
$date = null === $startParam ? today() : clone $startParam;
$date = null === $startParam ? today() : clone $startParam;
$nextExpectedMatchDiff = $this->getNextExpectedMatchDiff($nextExpectedMatch, $payDates);
$this->converter->summarize();
@@ -251,10 +251,10 @@ class BillTransformer extends AbstractTransformer
// 2023-07-18 the cloned $searchDate is used to grab the correct transactions.
/** @var null|Carbon $startParam */
$startParam = $this->parameters->get('start');
$startParam = $this->parameters->get('start');
/** @var null|Carbon $start */
$start = null === $startParam ? today() : clone $startParam;
$start = null === $startParam ? today() : clone $startParam;
$start->subDay();
$lastPaidDate = $this->lastPaidDate($dates, $start);
@@ -307,7 +307,7 @@ class BillTransformer extends AbstractTransformer
$currentStart = clone $this->parameters->get('start');
// 2023-06-23 subDay to fix 7655
$currentStart->subDay();
$loop = 0;
$loop = 0;
while ($currentStart <= $this->parameters->get('end')) {
$nextExpectedMatch = $this->nextDateMatch($bill, $currentStart);
// If nextExpectedMatch is after end, we continue:
@@ -317,13 +317,13 @@ class BillTransformer extends AbstractTransformer
// add to set
$set->push(clone $nextExpectedMatch);
$nextExpectedMatch->addDay();
$currentStart = clone $nextExpectedMatch;
$currentStart = clone $nextExpectedMatch;
++$loop;
if ($loop > 4) {
break;
}
}
$simple = $set->map(
$simple = $set->map(
static function (Carbon $date) {
return $date->toAtomString();
}
@@ -361,7 +361,7 @@ class BillTransformer extends AbstractTransformer
if (null === $current) {
return trans('firefly.not_expected_period');
}
$carbon = new Carbon($current);
$carbon = new Carbon($current);
return $carbon->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW);
}

View File

@@ -77,7 +77,7 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencySymbol = $currency->symbol;
$currencyDecimalPlaces = $currency->decimal_places;
}
$amount = number_format((float)$amount, $currencyDecimalPlaces, '.', '');
$amount = number_format((float)$amount, $currencyDecimalPlaces, '.', '');
return [
'id' => (string)$budgetLimit->id,

View File

@@ -89,12 +89,12 @@ class PiggyBankTransformer extends AbstractTransformer
foreach ($currencyPreferences as $preference) {
$currencyId = (int)$preference->data;
$accountId = $preference->account_id;
$currencies[$currencyId] ??= TransactionJournal::find($currencyId);
$currencies[$currencyId] ??= TransactionJournal::find($currencyId);
$this->currencies[$accountId] = $currencies[$currencyId];
}
// grab object groups:
$set = DB::table('object_groupables')
$set = DB::table('object_groupables')
->leftJoin('object_groups', 'object_groups.id', '=', 'object_groupables.object_group_id')
->where('object_groupables.object_groupable_type', PiggyBank::class)
->get(['object_groupables.*', 'object_groups.title', 'object_groups.order'])
@@ -113,7 +113,7 @@ class PiggyBankTransformer extends AbstractTransformer
}
// grab repetitions (for current amount):
$repetitions = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get();
$repetitions = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get();
/** @var PiggyBankRepetition $repetition */
foreach ($repetitions as $repetition) {
@@ -124,7 +124,7 @@ class PiggyBankTransformer extends AbstractTransformer
// grab notes
// continue with notes
$notes = Note::whereNoteableType(PiggyBank::class)->whereIn('noteable_id', array_keys($piggyBanks))->get();
$notes = Note::whereNoteableType(PiggyBank::class)->whereIn('noteable_id', array_keys($piggyBanks))->get();
/** @var Note $note */
foreach ($notes as $note) {
@@ -133,8 +133,8 @@ class PiggyBankTransformer extends AbstractTransformer
}
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$this->default = app('amount')->getDefaultCurrencyByUserGroup(auth()->user()->userGroup);
$this->converter = new ExchangeRateConverter();
$this->default = app('amount')->getDefaultCurrencyByUserGroup(auth()->user()->userGroup);
$this->converter = new ExchangeRateConverter();
}
/**

View File

@@ -52,13 +52,13 @@ class TransactionGroupTransformer extends AbstractTransformer
public function collectMetaData(Collection $objects): void
{
// start with currencies:
$currencies = [];
$journals = [];
$currencies = [];
$journals = [];
/** @var array $object */
foreach ($objects as $object) {
foreach ($object['sums'] as $sum) {
$id = (int) $sum['currency_id'];
$id = (int) $sum['currency_id'];
$currencies[$id] ??= TransactionCurrency::find($sum['currency_id']);
}
@@ -72,7 +72,7 @@ class TransactionGroupTransformer extends AbstractTransformer
$this->default = app('amount')->getDefaultCurrency();
// grab meta for all journals:
$meta = TransactionJournalMeta::whereIn('transaction_journal_id', array_keys($journals))->get();
$meta = TransactionJournalMeta::whereIn('transaction_journal_id', array_keys($journals))->get();
/** @var TransactionJournalMeta $entry */
foreach ($meta as $entry) {
@@ -81,7 +81,7 @@ class TransactionGroupTransformer extends AbstractTransformer
}
// grab all notes for all journals:
$notes = Note::whereNoteableType(TransactionJournal::class)->whereIn('noteable_id', array_keys($journals))->get();
$notes = Note::whereNoteableType(TransactionJournal::class)->whereIn('noteable_id', array_keys($journals))->get();
/** @var Note $note */
foreach ($notes as $note) {
@@ -90,7 +90,7 @@ class TransactionGroupTransformer extends AbstractTransformer
}
// grab all tags for all journals:
$tags = DB::table('tag_transaction_journal')
$tags = DB::table('tag_transaction_journal')
->leftJoin('tags', 'tags.id', 'tag_transaction_journal.tag_id')
->whereIn('tag_transaction_journal.transaction_journal_id', array_keys($journals))
->get(['tag_transaction_journal.transaction_journal_id', 'tags.tag'])
@@ -104,7 +104,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// create converter
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$this->converter = new ExchangeRateConverter();
$this->converter = new ExchangeRateConverter();
}
public function transform(array $group): array
@@ -147,10 +147,10 @@ class TransactionGroupTransformer extends AbstractTransformer
*/
private function transformTransaction(array $transaction): array
{
$transaction = new NullArrayObject($transaction);
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionType::WITHDRAWAL);
$journalId = (int) $transaction['transaction_journal_id'];
$meta = new NullArrayObject($this->meta[$journalId] ?? []);
$transaction = new NullArrayObject($transaction);
$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionType::WITHDRAWAL);
$journalId = (int) $transaction['transaction_journal_id'];
$meta = new NullArrayObject($this->meta[$journalId] ?? []);
/**
* Convert and use amount: