diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index c12e6cf..5e98b9b 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -23,6 +23,7 @@ use OCP\IDateTimeFormatter; use OCP\IL10N; use OCP\IRequest; use OCP\IUserSession; +use Psr\Log\LoggerInterface; /** * @psalm-suppress UnusedClass @@ -40,6 +41,7 @@ class ApiController extends OCSController { public function __construct( string $appName, IRequest $request, + private LoggerInterface $logger, private IAppConfig $config, private IL10N $l, private IUserSession $userSession, @@ -159,7 +161,10 @@ class ApiController extends OCSController { $id = (string)$p->getId(); $currencyName = (string)$p->getCurrencyName(); $currencies = $this->currencyMapper->findAll($id); - $currencyNames = array_map(fn ($c) => strtolower((string)$c->getName()), $currencies); + $currencyNames = array_map(function ($c) { + $resolved = $this->service->getCurrencyName((string)$c->getName()); + return $resolved ?? strtolower((string)$c->getName()); + }, $currencies); $list[] = [ 'id' => $id, @@ -230,8 +235,9 @@ class ApiController extends OCSController { } // Resolve project and its base currency + $this->logger->debug('Fetching history for project ' . $projectId . ' from ' . ($fromDt?->format(DATE_ATOM) ?? 'null') . ' to ' . ($toDt?->format(DATE_ATOM) ?? 'null')); $project = $this->projectMapper->find($projectId); - $projectBase = $project->getCurrencyName(); + $projectBase = $this->service->getCurrencyName($project->getCurrencyName()); $lbase = strtolower((string)$projectBase); $rows = $this->historyMapper->findByProjectAndBase( diff --git a/lib/Db/CospendProjectMapper.php b/lib/Db/CospendProjectMapper.php index 851ca39..d44de53 100755 --- a/lib/Db/CospendProjectMapper.php +++ b/lib/Db/CospendProjectMapper.php @@ -32,7 +32,7 @@ class CospendProjectMapper extends QBMapper { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from('cospend_projects') - ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))); + ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_STR))); return $this->findEntity($qb); } diff --git a/lib/Service/FetchCurrenciesService.php b/lib/Service/FetchCurrenciesService.php index 6fcb9e2..6834099 100644 --- a/lib/Service/FetchCurrenciesService.php +++ b/lib/Service/FetchCurrenciesService.php @@ -180,7 +180,7 @@ class FetchCurrenciesService { } /** Match the currency name from the known currencies. **/ - private function getCurrencyName(string $name): ?string { + public function getCurrencyName(string $name): ?string { $original = trim($name); $lower = mb_strtolower($original, 'UTF-8'); diff --git a/src/UserSettings.vue b/src/UserSettings.vue index 4f6dd87..82ae46d 100644 --- a/src/UserSettings.vue +++ b/src/UserSettings.vue @@ -62,10 +62,11 @@
-