rateForTaxObligationDate method
Returns the NBP average rate for currency for given tax obligation date.
Per art. 31a ust. 1 ustawy o VAT: the applicable rate is the NBP average
from the last working day preceding taxObligationDate.
We assume here that NBP will publish rates on days that are considered working days.
Example: for invoice issued on 2025-06-23 (Monday) we will return rate for 2025-06-20 (Friday).
Implementation
Future<NbpRate> rateForTaxObligationDate({
required String currency,
required DateTime taxObligationDate,
}) {
final lookupFrom = taxObligationDate.subtract(const Duration(days: 1));
return _rateOnOrBefore(currency.toUpperCase(), lookupFrom);
}