Browse Source

Replace references to the default currency with one to the primary currency.

pull/937/head
James Cole 2 months ago
parent
commit
d2148da489
  1. 16
      app/Services/CSV/Conversion/Routine/PseudoTransactionProcessor.php
  2. 2
      app/Services/CSV/Conversion/Task/Accounts.php
  3. 2
      app/Services/CSV/Conversion/Task/Amount.php
  4. 2
      app/Services/CSV/Conversion/Task/Currency.php
  5. 2
      app/Services/CSV/Conversion/Task/EmptyAccounts.php
  6. 2
      app/Services/CSV/Conversion/Task/EmptyDescription.php
  7. 2
      app/Services/CSV/Conversion/Task/Tags.php
  8. 2
      app/Services/CSV/Conversion/Task/TaskInterface.php
  9. 2
      app/Services/SimpleFIN/Conversion/AccountMapper.php
  10. 2
      config/importer.php

16
app/Services/CSV/Conversion/Routine/PseudoTransactionProcessor.php

@ -47,7 +47,7 @@ class PseudoTransactionProcessor
use ProgressInformation;
private Account $defaultAccount;
private TransactionCurrency $defaultCurrency;
private TransactionCurrency $primaryCurrency;
private array $tasks;
/**
@ -59,7 +59,7 @@ class PseudoTransactionProcessor
{
$this->tasks = config('csv.transaction_tasks');
$this->getDefaultAccount($defaultAccountId);
$this->getDefaultCurrency();
$this->getPrimaryCurrency();
}
/**
@ -101,7 +101,7 @@ class PseudoTransactionProcessor
/**
* @throws ImporterErrorException
*/
private function getDefaultCurrency(): void
private function getPrimaryCurrency(): void
{
$url = SecretManager::getBaseUrl();
$token = SecretManager::getAccessToken();
@ -109,18 +109,18 @@ class PseudoTransactionProcessor
$currencyRequest = new GetCurrencyRequest($url, $token);
$currencyRequest->setVerify(config('importer.connection.verify'));
$currencyRequest->setTimeOut(config('importer.connection.timeout'));
$currencyRequest->setCode('default');
$currencyRequest->setCode('primary');
try {
/** @var GetCurrencyResponse $result */
$result = $currencyRequest->get();
$this->defaultCurrency = $result->getCurrency();
$this->primaryCurrency = $result->getCurrency();
} catch (ApiHttpException $e) {
Log::error(sprintf('[%s]: %s', config('importer.version'), $e->getMessage()));
throw new ImporterErrorException('The default currency could not be loaded.');
throw new ImporterErrorException('The primary currency could not be loaded.');
}
Log::debug(sprintf('Currency found, default currency is assumed to be "%s" (#%d)', $this->defaultCurrency->code, $this->defaultCurrency->id));
Log::debug(sprintf('Currency found, default currency is assumed to be "%s" (#%d)', $this->primaryCurrency->code, $this->primaryCurrency->id));
}
public function processPseudo(array $lines): array
@ -152,7 +152,7 @@ class PseudoTransactionProcessor
$object->setAccount($this->defaultAccount);
}
if ($object->requiresTransactionCurrency()) {
$object->setTransactionCurrency($this->defaultCurrency);
$object->setTransactionCurrency($this->primaryCurrency);
}
$line = $object->process($line);

2
app/Services/CSV/Conversion/Task/Accounts.php

@ -679,7 +679,7 @@ class Accounts extends AbstractTask
}
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool
{

2
app/Services/CSV/Conversion/Task/Amount.php

@ -147,7 +147,7 @@ class Amount extends AbstractTask
}
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool
{

2
app/Services/CSV/Conversion/Task/Currency.php

@ -63,7 +63,7 @@ class Currency extends AbstractTask
}
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool
{

2
app/Services/CSV/Conversion/Task/EmptyAccounts.php

@ -82,7 +82,7 @@ class EmptyAccounts extends AbstractTask
}
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool
{

2
app/Services/CSV/Conversion/Task/EmptyDescription.php

@ -58,7 +58,7 @@ class EmptyDescription extends AbstractTask
}
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool
{

2
app/Services/CSV/Conversion/Task/Tags.php

@ -59,7 +59,7 @@ class Tags extends AbstractTask
}
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool
{

2
app/Services/CSV/Conversion/Task/TaskInterface.php

@ -41,7 +41,7 @@ interface TaskInterface
public function requiresDefaultAccount(): bool;
/**
* Returns true if the task requires the default currency of the user.
* Returns true if the task requires the primary currency of the user.
*/
public function requiresTransactionCurrency(): bool;

2
app/Services/SimpleFIN/Conversion/AccountMapper.php

@ -290,7 +290,7 @@ class AccountMapper
// 2. Fall back to SimpleFIN account currency
$currency = $simplefinAccount->getCurrency();
if ($simplefinAccount->isCustomCurrency()) {
// For custom currencies, default to user's base currency or EUR
// For custom currencies, default to user's primary currency or EUR
return 'EUR'; // Could be made configurable
}

2
config/importer.php

@ -69,7 +69,7 @@ return [
'ignore_not_found_transactions' => env('IGNORE_NOT_FOUND_TRANSACTIONS', false),
'namespace' => 'c40dcba2-411d-11ec-973a-0242ac130003',
'use_cache' => env('USE_CACHE', false),
'minimum_version' => '6.3.0',
'minimum_version' => '6.3.2',
'cache_api_calls' => false,
'ignored_files' => ['.gitignore'],
'tracker_site_id' => env('TRACKER_SITE_ID', ''),

Loading…
Cancel
Save