[chore] cod cleanup

This commit is contained in:
James Cole 2025-01-19 18:53:32 +01:00
parent bd1f8b2497
commit 0e8bcd2e79
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
3 changed files with 16 additions and 8 deletions

View File

@ -155,13 +155,21 @@ class Amount
return $user->currencies()->orderBy('code', 'ASC')->get();
}
/**
* @deprecated
*/
public function getDefaultCurrency(): TransactionCurrency
{
return $this->getNativeCurrency();
}
public function getNativeCurrency(): TransactionCurrency
{
if (auth()->check()) {
/** @var User $user */
$user = auth()->user();
if (null !== $user->userGroup) {
return $this->getDefaultCurrencyByUserGroup($user->userGroup);
return $this->getNativeCurrencyByUserGroup($user->userGroup);
}
}

View File

@ -758,22 +758,22 @@ class ExportDataGenerator
$metaData = $repository->getMetaFields($journal['transaction_journal_id'], $metaFields);
$amount = Steam::bcround(Steam::negative($journal['amount']), $journal['currency_decimal_places']);
$foreignAmount = null === $journal['foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['foreign_amount']), $journal['foreign_currency_decimal_places']);
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::negative($journal['native_amount'], $default->decimal_places));
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['native_foreign_amount'], $default->decimal_places));
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::negative($journal['native_amount']), $default->decimal_places);
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['native_foreign_amount']), $default->decimal_places);
if (TransactionTypeEnum::WITHDRAWAL->value !== $journal['transaction_type_type']) {
$amount = Steam::bcround(Steam::positive($journal['amount']), $journal['currency_decimal_places']);
$foreignAmount = null === $journal['foreign_amount'] ? null : Steam::bcround(Steam::positive($journal['foreign_amount']), $journal['foreign_currency_decimal_places']);
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::positive($journal['native_amount'], $default->decimal_places));
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::positive($journal['native_foreign_amount'], $default->decimal_places));
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::positive($journal['native_amount']), $default->decimal_places);
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::positive($journal['native_foreign_amount']), $default->decimal_places);
}
// opening balance depends on source account type.
if (TransactionTypeEnum::OPENING_BALANCE->value === $journal['transaction_type_type'] && AccountTypeEnum::ASSET->value === $journal['source_account_type']) {
$amount = Steam::bcround(Steam::negative($journal['amount']), $journal['currency_decimal_places']);
$foreignAmount = null === $journal['foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['foreign_amount']), $journal['foreign_currency_decimal_places']);
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::negative($journal['native_amount'], $default->decimal_places));
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['native_foreign_amount'], $default->decimal_places));
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::negative($journal['native_amount']), $default->decimal_places);
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['native_foreign_amount']), $default->decimal_places);
}
$records[] = [

View File

@ -77,7 +77,7 @@ class AccountTransformer extends AbstractTransformer
$date = $this->getDate();
$date->endOfDay();
[$currencyId, $currencyCode, $currencySymbol, $decimalPlaces] = $this->getCurrency($account, $default);
[$currencyId, $currencyCode, $currencySymbol, $decimalPlaces] = $this->getCurrency($account);
[$creditCardType, $monthlyPaymentDate] = $this->getCCInfo($account, $accountRole, $accountType);
[$openingBalance, $nativeOpeningBalance, $openingBalanceDate] = $this->getOpeningBalance($account, $accountType, $convertToNative);
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);