Fix formatting of currencies in Invoice detail page

This commit is contained in:
nicolas.dorier
2019-01-30 19:18:44 +09:00
parent d05bb6c60e
commit 1a98bfba36
4 changed files with 18 additions and 13 deletions

View File

@@ -65,6 +65,7 @@ namespace BTCPayServer.Controllers
OrderId = invoice.OrderId, OrderId = invoice.OrderId,
BuyerInformation = invoice.BuyerInformation, BuyerInformation = invoice.BuyerInformation,
Fiat = _CurrencyNameTable.DisplayFormatCurrency(dto.Price, dto.Currency), Fiat = _CurrencyNameTable.DisplayFormatCurrency(dto.Price, dto.Currency),
TaxIncluded = _CurrencyNameTable.DisplayFormatCurrency(invoice.ProductInformation.TaxIncluded, dto.Currency),
NotificationEmail = invoice.NotificationEmail, NotificationEmail = invoice.NotificationEmail,
NotificationUrl = invoice.NotificationURL, NotificationUrl = invoice.NotificationURL,
RedirectUrl = invoice.RedirectURL, RedirectUrl = invoice.RedirectURL,
@@ -81,9 +82,9 @@ namespace BTCPayServer.Controllers
var paymentMethodId = data.GetId(); var paymentMethodId = data.GetId();
var cryptoPayment = new InvoiceDetailsModel.CryptoPayment(); var cryptoPayment = new InvoiceDetailsModel.CryptoPayment();
cryptoPayment.PaymentMethod = ToString(paymentMethodId); cryptoPayment.PaymentMethod = ToString(paymentMethodId);
cryptoPayment.Due = $"{accounting.Due} {paymentMethodId.CryptoCode}"; cryptoPayment.Due = _CurrencyNameTable.DisplayFormatCurrency(accounting.Due.ToDecimal(MoneyUnit.BTC), paymentMethodId.CryptoCode);
cryptoPayment.Paid = $"{accounting.CryptoPaid} {paymentMethodId.CryptoCode}"; cryptoPayment.Paid = _CurrencyNameTable.DisplayFormatCurrency(accounting.CryptoPaid.ToDecimal(MoneyUnit.BTC), paymentMethodId.CryptoCode);
cryptoPayment.Overpaid = $"{accounting.OverpaidHelper} {paymentMethodId.CryptoCode}"; cryptoPayment.Overpaid = _CurrencyNameTable.DisplayFormatCurrency(accounting.OverpaidHelper.ToDecimal(MoneyUnit.BTC), paymentMethodId.CryptoCode);
var onchainMethod = data.GetPaymentMethodDetails() as Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod; var onchainMethod = data.GetPaymentMethodDetails() as Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod;
if (onchainMethod != null) if (onchainMethod != null)

View File

@@ -105,6 +105,7 @@ namespace BTCPayServer.Models.InvoicingModels
get; get;
set; set;
} }
public string TaxIncluded { get; set; }
public BuyerInformation BuyerInformation public BuyerInformation BuyerInformation
{ {
get; get;

View File

@@ -121,6 +121,8 @@ namespace BTCPayServer.Services.Rates
var provider = GetNumberFormatInfo(currency, true); var provider = GetNumberFormatInfo(currency, true);
var currencyData = GetCurrencyData(currency, true); var currencyData = GetCurrencyData(currency, true);
var divisibility = currencyData.Divisibility; var divisibility = currencyData.Divisibility;
if (value != 0m)
{
while (true) while (true)
{ {
var rounded = decimal.Round(value, divisibility, MidpointRounding.AwayFromZero); var rounded = decimal.Round(value, divisibility, MidpointRounding.AwayFromZero);
@@ -131,6 +133,7 @@ namespace BTCPayServer.Services.Rates
} }
divisibility++; divisibility++;
} }
}
if (divisibility != provider.CurrencyDecimalDigits) if (divisibility != provider.CurrencyDecimalDigits)
{ {
provider = (NumberFormatInfo)provider.Clone(); provider = (NumberFormatInfo)provider.Clone();

View File

@@ -155,11 +155,11 @@
</tr> </tr>
<tr> <tr>
<th>Price</th> <th>Price</th>
<td>@Model.ProductInformation.Price @Model.ProductInformation.Currency</td> <td>@Model.Fiat</td>
</tr> </tr>
<tr> <tr>
<th>Tax included</th> <th>Tax included</th>
<td>@Model.ProductInformation.TaxIncluded @Model.ProductInformation.Currency</td> <td>@Model.TaxIncluded</td>
</tr> </tr>
</table> </table>
} }
@@ -182,11 +182,11 @@
</tr> </tr>
<tr> <tr>
<th>Price</th> <th>Price</th>
<td>@Model.ProductInformation.Price @Model.ProductInformation.Currency</td> <td>@Model.Fiat</td>
</tr> </tr>
<tr> <tr>
<th>Tax included</th> <th>Tax included</th>
<td>@Model.ProductInformation.TaxIncluded @Model.ProductInformation.Currency</td> <td>@Model.TaxIncluded</td>
</tr> </tr>
</table> </table>
</div> </div>