New IFxConverter.ConvertToChf(amount, fromCurrency) and FxConverter wrap the vendor IFxService and the FixerIo API key so callers stop threading the key through every conversion. ViewService drops IFxService and ISettingsService from its constructor and takes IFxConverter instead; GetAccountViewList and GetBalanceSheetView no longer read settingsService.GetSettings() per method. FxConverterTestShould locks in the target-currency + API-key routing. 40 tests total, all passing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
21 lines
635 B
C#
21 lines
635 B
C#
using Schaad.Accounting.Datasets;
|
|
using Schaad.Accounting.Interfaces;
|
|
using Schaad.Finance.Api;
|
|
|
|
namespace Schaad.Accounting.Services
|
|
{
|
|
public class FxConverter : IFxConverter
|
|
{
|
|
private readonly IFxService fxService;
|
|
private readonly SettingsDataset settings;
|
|
|
|
public FxConverter(IFxService fxService, SettingsDataset settings)
|
|
{
|
|
this.fxService = fxService;
|
|
this.settings = settings;
|
|
}
|
|
|
|
public decimal ConvertToChf(decimal amount, string fromCurrency)
|
|
=> fxService.ConvertCurrency(amount, fromCurrency, "CHF", settings.FixerIoApiKey);
|
|
}
|
|
}
|