mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
* Fix rounding error for the first refund option (#2778) * Fix rounding issue
This commit is contained in:
@@ -242,10 +242,11 @@ namespace BTCPayServer.Controllers
|
|||||||
model.RefundStep = RefundSteps.SelectRate;
|
model.RefundStep = RefundSteps.SelectRate;
|
||||||
model.Title = "What to refund?";
|
model.Title = "What to refund?";
|
||||||
var paymentMethod = invoice.GetPaymentMethods()[paymentMethodId];
|
var paymentMethod = invoice.GetPaymentMethods()[paymentMethodId];
|
||||||
|
var cryptoPaid = paymentMethod.Calculate().Paid.ToDecimal(MoneyUnit.BTC);
|
||||||
var paidCurrency =
|
var paidCurrency =
|
||||||
Math.Round(paymentMethod.Calculate().Paid.ToDecimal(MoneyUnit.BTC) * paymentMethod.Rate,
|
Math.Round(cryptoPaid * paymentMethod.Rate,
|
||||||
cdCurrency.Divisibility);
|
cdCurrency.Divisibility);
|
||||||
model.CryptoAmountThen = Math.Round(paidCurrency / paymentMethod.Rate, paymentMethodDivisibility);
|
model.CryptoAmountThen = cryptoPaid.RoundToSignificant(paymentMethodDivisibility);
|
||||||
model.RateThenText =
|
model.RateThenText =
|
||||||
_CurrencyNameTable.DisplayFormatCurrency(model.CryptoAmountThen, paymentMethodId.CryptoCode);
|
_CurrencyNameTable.DisplayFormatCurrency(model.CryptoAmountThen, paymentMethodId.CryptoCode);
|
||||||
rules = store.GetStoreBlob().GetRateRules(_NetworkProvider);
|
rules = store.GetStoreBlob().GetRateRules(_NetworkProvider);
|
||||||
|
|||||||
Reference in New Issue
Block a user