#nullable enable
using Baya.Application.Contracts.Payments;
using Microsoft.Extensions.Options;

namespace Baya.Infrastructure.CrossCutting.Seams;

/// <summary>
/// Deterministic mock <see cref="ICurrencyNormalizer"/> — Toman ↔ IRR at the provider boundary only. Toman is
/// multiplied by <see cref="CurrencyOptions.TomanToIrrMultiplier"/> (10) to get IRR (and divided back for
/// display); IRR passes through unchanged. A real adapter reads the multiplier from provider config; the
/// conversion never happens internally, only here.
/// </summary>
public sealed class MockCurrencyNormalizer(IOptions<SeamOptions> options) : ICurrencyNormalizer
{
    private readonly CurrencyOptions _options = options.Value.Currency;

    public long ToIrr(long amount, string currency)
        => string.Equals(currency, "TOMAN", StringComparison.OrdinalIgnoreCase)
            ? amount * _options.TomanToIrrMultiplier
            : amount;

    public long ToDisplayToman(long amountIrr)
        => _options.TomanToIrrMultiplier == 0 ? amountIrr : amountIrr / _options.TomanToIrrMultiplier;
}
