mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Fix: Free items in the PoS were generating top-up invoices rather than settled invoices
This commit is contained in:
committed by
Andrew Camilleri (Kukks)
parent
886df54469
commit
f52cb053fe
@@ -172,6 +172,8 @@ orange:
|
||||
donation:
|
||||
price: 1.02
|
||||
custom: true
|
||||
goodies:
|
||||
price: 0
|
||||
";
|
||||
vmpos.Currency = "EUR";
|
||||
vmpos.Template = AppService.SerializeTemplate(MigrationStartupTask.ParsePOSYML(vmpos.Template));
|
||||
@@ -182,7 +184,7 @@ donation:
|
||||
|
||||
Assert.Equal("EUR", vmview.CurrencyCode);
|
||||
// apple shouldn't be available since we it's set to "disabled: true" above
|
||||
Assert.Equal(2, vmview.Items.Length);
|
||||
Assert.Equal(3, vmview.Items.Length);
|
||||
Assert.Equal("orange", vmview.Items[0].Title);
|
||||
Assert.Equal("donation", vmview.Items[1].Title);
|
||||
// orange is available
|
||||
@@ -192,6 +194,14 @@ donation:
|
||||
Assert.IsType<NotFoundResult>(publicApps
|
||||
.ViewPointOfSale(app.Id, PosViewType.Cart, 0, choiceKey: "apple").Result);
|
||||
|
||||
var redirectToCheckout = Assert.IsType<RedirectToActionResult>(publicApps.ViewPointOfSale(app.Id, PosViewType.Cart, 0, choiceKey: "goodies").Result);
|
||||
Assert.Equal("InvoiceReceipt", redirectToCheckout.ActionName);
|
||||
var invoiceId = redirectToCheckout.RouteValues!["invoiceId"]!.ToString();
|
||||
var client = await user.CreateClient();
|
||||
var inv = await client.GetInvoice(user.StoreId, invoiceId);
|
||||
Assert.Equal(0, inv.Amount);
|
||||
Assert.NotEqual(InvoiceType.TopUp, inv.Type);
|
||||
|
||||
// List
|
||||
appList = Assert.IsType<ListAppsViewModel>(Assert.IsType<ViewResult>(apps.ListApps(user.StoreId).Result).Model);
|
||||
app = appList.Apps[0];
|
||||
|
||||
@@ -232,6 +232,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
||||
{
|
||||
order.AddLine(new($"Custom Amount {i + 1}", 1, jposData.Amounts[i], settings.DefaultTaxRate));
|
||||
}
|
||||
|
||||
foreach (var cartItem in jposData.Cart)
|
||||
{
|
||||
var itemChoice = choices.FirstOrDefault(item => item.Id == cartItem.Id);
|
||||
@@ -322,7 +323,7 @@ namespace BTCPayServer.Plugins.PointOfSale.Controllers
|
||||
var receiptData = new PosReceiptData();
|
||||
var summary = order.Calculate();
|
||||
|
||||
bool isTopup = summary.PriceTaxIncludedWithTips == 0 && currentView == PosViewType.Static;
|
||||
var isTopup = selectedChoices.FirstOrDefault().Price is null && currentView == PosViewType.Static;
|
||||
if (!isTopup)
|
||||
{
|
||||
jposData.ItemsTotal = summary.ItemsTotal;
|
||||
|
||||
Reference in New Issue
Block a user