2023-06-30 09:13:15 +09:00
|
|
|
using System;
|
2023-05-23 02:18:57 +02:00
|
|
|
using System.Collections.Generic;
|
2021-07-23 03:57:19 -07:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-06-30 09:13:15 +09:00
|
|
|
using System.Linq;
|
2023-05-23 02:18:57 +02:00
|
|
|
using BTCPayServer.JsonConverters;
|
2023-12-01 16:13:44 +01:00
|
|
|
using BTCPayServer.Models;
|
2020-05-26 16:48:47 +02:00
|
|
|
using BTCPayServer.Services.Apps;
|
2023-06-30 09:13:15 +09:00
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
2023-05-23 02:18:57 +02:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
using Newtonsoft.Json.Linq;
|
2018-04-03 11:50:41 +09:00
|
|
|
|
2022-07-18 20:51:53 +02:00
|
|
|
namespace BTCPayServer.Plugins.PointOfSale.Models
|
2018-04-03 11:50:41 +09:00
|
|
|
{
|
|
|
|
public class ViewPointOfSaleViewModel
|
|
|
|
{
|
2023-05-23 02:18:57 +02:00
|
|
|
public enum ItemPriceType
|
|
|
|
{
|
|
|
|
Topup,
|
|
|
|
Minimum,
|
|
|
|
Fixed
|
|
|
|
}
|
|
|
|
|
2018-04-03 11:50:41 +09:00
|
|
|
public class Item
|
|
|
|
{
|
2023-05-23 02:18:57 +02:00
|
|
|
|
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
2018-11-10 14:38:26 +08:00
|
|
|
public string Description { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
public string Id { get; set; }
|
2023-05-23 02:18:57 +02:00
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
2023-06-30 09:13:15 +09:00
|
|
|
public string[] Categories { get; set; }
|
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
2018-11-10 14:38:26 +08:00
|
|
|
public string Image { get; set; }
|
2023-05-23 02:18:57 +02:00
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
|
|
public ItemPriceType PriceType { get; set; }
|
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
|
|
|
[JsonConverter(typeof(NumericStringJsonConverter))]
|
|
|
|
public decimal? Price { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
public string Title { get; set; }
|
2023-05-23 02:18:57 +02:00
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
2021-02-18 10:54:06 +01:00
|
|
|
public string BuyButtonText { get; set; }
|
2023-05-23 02:18:57 +02:00
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
2019-09-02 15:37:52 +02:00
|
|
|
public int? Inventory { get; set; } = null;
|
2023-05-23 02:18:57 +02:00
|
|
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
2020-05-19 20:54:24 +02:00
|
|
|
public string[] PaymentMethods { get; set; }
|
2021-09-12 21:59:18 -07:00
|
|
|
public bool Disabled { get; set; } = false;
|
2023-05-23 02:18:57 +02:00
|
|
|
|
|
|
|
[JsonExtensionData] public Dictionary<string, JToken> AdditionalData { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
}
|
2018-11-15 21:31:38 -06:00
|
|
|
|
2018-12-04 13:04:26 +09:00
|
|
|
public class CurrencyInfoData
|
|
|
|
{
|
|
|
|
public bool Prefixed { get; set; }
|
|
|
|
public string CurrencySymbol { get; set; }
|
|
|
|
public string ThousandSeparator { get; set; }
|
|
|
|
public string DecimalSeparator { get; set; }
|
2018-12-18 00:25:17 +09:00
|
|
|
public int Divisibility { get; set; }
|
|
|
|
public bool SymbolSpace { get; set; }
|
2018-12-04 13:04:26 +09:00
|
|
|
}
|
|
|
|
|
2023-12-01 16:13:44 +01:00
|
|
|
public StoreBrandingViewModel StoreBranding { get; set; }
|
2023-01-30 09:23:49 +01:00
|
|
|
public string StoreName { get; set; }
|
2018-12-04 13:04:26 +09:00
|
|
|
public CurrencyInfoData CurrencyInfo { get; set; }
|
2020-05-26 17:38:30 +02:00
|
|
|
public PosViewType ViewType { get; set; }
|
2018-04-26 22:09:18 +09:00
|
|
|
public bool ShowCustomAmount { get; set; }
|
2019-02-25 14:11:03 +08:00
|
|
|
public bool ShowDiscount { get; set; }
|
2023-11-13 13:59:14 +01:00
|
|
|
public bool ShowSearch { get; set; } = true;
|
|
|
|
public bool ShowCategories { get; set; } = true;
|
2019-02-25 14:11:03 +08:00
|
|
|
public bool EnableTips { get; set; }
|
2018-04-26 22:09:18 +09:00
|
|
|
public string Step { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
public string Title { get; set; }
|
2023-06-30 09:13:15 +09:00
|
|
|
Item[] _Items;
|
|
|
|
public Item[] Items
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return _Items;
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
_Items = value;
|
|
|
|
UpdateGroups();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void UpdateGroups()
|
|
|
|
{
|
|
|
|
AllCategories = null;
|
|
|
|
if (Items is null)
|
|
|
|
return;
|
|
|
|
var groups = Items.SelectMany(g => g.Categories ?? Array.Empty<string>())
|
|
|
|
.ToHashSet()
|
|
|
|
.Select(o => new KeyValuePair<string, string>(o, o))
|
|
|
|
.ToList();
|
|
|
|
if (groups.Count == 0)
|
|
|
|
return;
|
2023-07-22 14:15:41 +02:00
|
|
|
groups.Insert(0, new KeyValuePair<string, string>("All", "*"));
|
2023-06-30 09:13:15 +09:00
|
|
|
AllCategories = new SelectList(groups, "Value", "Key", "*");
|
|
|
|
}
|
|
|
|
|
2018-12-01 12:59:45 +08:00
|
|
|
public string CurrencyCode { get; set; }
|
2018-11-15 21:31:38 -06:00
|
|
|
public string CurrencySymbol { get; set; }
|
2018-12-04 13:04:26 +09:00
|
|
|
public string AppId { get; set; }
|
2018-11-16 20:39:43 -06:00
|
|
|
public string ButtonText { get; set; }
|
|
|
|
public string CustomButtonText { get; set; }
|
2018-11-27 14:14:32 +08:00
|
|
|
public string CustomTipText { get; set; }
|
2018-12-19 14:07:05 +08:00
|
|
|
public int[] CustomTipPercentages { get; set; }
|
2019-08-19 07:13:42 +02:00
|
|
|
public string Description { get; set; }
|
2023-06-30 09:13:15 +09:00
|
|
|
public SelectList AllCategories { get; set; }
|
2021-07-23 03:57:19 -07:00
|
|
|
[Display(Name = "Custom CSS Code")]
|
2021-10-27 07:32:56 -07:00
|
|
|
public RequiresRefundEmail RequiresRefundEmail { get; set; } = RequiresRefundEmail.InheritFromStore;
|
2022-05-27 16:26:31 +09:00
|
|
|
public string StoreId { get; set; }
|
2018-04-03 11:50:41 +09:00
|
|
|
}
|
2021-09-05 15:19:27 -07:00
|
|
|
}
|