Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { Controller, Get, Param, Query, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { Company } from '@amalia/core/models';
import { CurrencySymbolsEnum } from '@amalia/ext/iso-4217';
import { EnumPipe } from '@amalia/kernel/api';
import { AmaliaAuthGuard, CheckPolicies, CurrentUserCompany, PoliciesGuard } from '@amalia/kernel/auth/core';
import { canExportStatements, canViewCompanyRates, canViewStatements } from '@amalia/kernel/auth/shared';
import { CurrencyRatesService } from './currencyRates.service';
@UseGuards(AmaliaAuthGuard, PoliciesGuard)
@ApiBearerAuth()
@ApiTags('currencies')
@Controller('currency_rates')
export class CurrencyRatesController {
public constructor(private readonly currencyRatesService: CurrencyRatesService) {}
/**
* Get a currency rate with current date or given date.
* @param company
* @param symbol
* @param date
*/
@Get(':symbol')
@CheckPolicies(
(ability) => canViewCompanyRates(ability) || canViewStatements(ability) || canExportStatements(ability),
)
public async getCurrencyRate(
@CurrentUserCompany() company: Company,
@Param('symbol', new EnumPipe({ enum: CurrencySymbolsEnum })) symbol: CurrencySymbolsEnum,
@Query('date') date?: number,
): Promise<number> {
return this.currencyRatesService.findCurrencyRate(company, symbol, date);
}
}
|