Use the store's default currency when creating entities (#3585)

* Use default currency for new pull payments

Closes #3582.

* Pull payment: Improve create form

* Use default currency for new invoices

Closes  #3581.

* Clean up old invoice form code

* Use default currency for new payment requests

* Test fixes
This commit is contained in:
d11n
2022-04-11 10:50:30 +02:00
committed by GitHub
parent bfdb1b4af9
commit cd9a52706c
8 changed files with 31 additions and 40 deletions

View File

@@ -914,18 +914,6 @@ namespace BTCPayServer.Controllers
[BitpayAPIConstraint(false)]
public async Task<IActionResult> CreateInvoice(InvoicesModel? model = null)
{
var stores = new SelectList(
await _StoreRepository.GetStoresByUserId(GetUserId()),
nameof(StoreData.Id),
nameof(StoreData.StoreName),
new SearchString(model?.SearchTerm).GetFilterArray("storeid")?.ToArray().FirstOrDefault()
);
if (!stores.Any())
{
TempData[WellKnownTempData.ErrorMessage] = "You need to create at least one store before creating a transaction";
return RedirectToAction(nameof(UIHomeController.Index), "UIHome");
}
if (model?.StoreId != null)
{
var store = await _StoreRepository.FindStore(model.StoreId, GetUserId());
@@ -944,11 +932,16 @@ namespace BTCPayServer.Controllers
HttpContext.SetStoreData(store);
}
else
{
TempData[WellKnownTempData.ErrorMessage] = "You need to select a store before creating an invoice.";
return RedirectToAction(nameof(UIHomeController.Index), "UIHome");
}
var vm = new CreateInvoiceModel
{
Stores = stores,
StoreId = model?.StoreId,
StoreId = model.StoreId,
Currency = HttpContext.GetStoreData()?.GetStoreBlob().DefaultCurrency,
AvailablePaymentMethods = GetPaymentMethodsSelectList()
};
@@ -961,8 +954,6 @@ namespace BTCPayServer.Controllers
[BitpayAPIConstraint(false)]
public async Task<IActionResult> CreateInvoice(CreateInvoiceModel model, CancellationToken cancellationToken)
{
var stores = await _StoreRepository.GetStoresByUserId(GetUserId());
model.Stores = new SelectList(stores, nameof(StoreData.Id), nameof(StoreData.StoreName), model.StoreId);
model.AvailablePaymentMethods = GetPaymentMethodsSelectList();
var store = HttpContext.GetStoreData();
if (!ModelState.IsValid)