Compare commits
14 Commits
4dd036babd
...
v0.6.0
Author | SHA1 | Date | |
---|---|---|---|
42bf01656e | |||
51293baaae | |||
1d1398a9cd | |||
7d199282d0 | |||
b56a5ed5c6 | |||
201b63c2f1 | |||
b2bd0c9a21 | |||
8502afdc9a | |||
cb541cb6e6 | |||
403e7723d2 | |||
8fbce03031 | |||
b32a935150 | |||
337bfa89d9 | |||
f886888ccc |
@@ -65,22 +65,27 @@ namespace Elwig {
|
|||||||
MainDispatcher = Dispatcher;
|
MainDispatcher = Dispatcher;
|
||||||
Scales = Array.Empty<IScale>();
|
Scales = Array.Empty<IScale>();
|
||||||
CurrentApp = this;
|
CurrentApp = this;
|
||||||
|
OverrideCulture();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnStartup(StartupEventArgs evt) {
|
private static void OverrideCulture() {
|
||||||
var locale = new CultureInfo("de-AT");
|
var locale = new CultureInfo("de-AT", false);
|
||||||
locale.NumberFormat.CurrencyGroupSeparator = "\u202f";
|
locale.NumberFormat.CurrencyGroupSeparator = Utils.GroupSeparator;
|
||||||
locale.NumberFormat.NumberGroupSeparator = "\u202f";
|
locale.NumberFormat.NumberGroupSeparator = Utils.GroupSeparator;
|
||||||
locale.NumberFormat.PercentGroupSeparator = "\u202f";
|
locale.NumberFormat.PercentGroupSeparator = Utils.GroupSeparator;
|
||||||
|
CultureInfo.CurrentCulture = locale;
|
||||||
|
CultureInfo.CurrentUICulture = locale;
|
||||||
Thread.CurrentThread.CurrentCulture = locale;
|
Thread.CurrentThread.CurrentCulture = locale;
|
||||||
Thread.CurrentThread.CurrentUICulture = locale;
|
Thread.CurrentThread.CurrentUICulture = locale;
|
||||||
CultureInfo.DefaultThreadCurrentCulture = locale;
|
CultureInfo.DefaultThreadCurrentCulture = locale;
|
||||||
CultureInfo.DefaultThreadCurrentUICulture = locale;
|
CultureInfo.DefaultThreadCurrentUICulture = locale;
|
||||||
FrameworkElement.LanguageProperty.OverrideMetadata(
|
FrameworkElement.LanguageProperty.OverrideMetadata(
|
||||||
typeof(FrameworkElement),
|
typeof(FrameworkElement),
|
||||||
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag))
|
new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.Name))
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override async void OnStartup(StartupEventArgs evt) {
|
||||||
Version = typeof(App).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split("+")[0] ?? "0.0.0";
|
Version = typeof(App).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split("+")[0] ?? "0.0.0";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -12,7 +12,7 @@ namespace Elwig.Dialogs {
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
TextLsNr.Text = lsnr;
|
TextLsNr.Text = lsnr;
|
||||||
TextMember.Text = name;
|
TextMember.Text = name;
|
||||||
TextWeight.Text = $"{weight:N0}\u202fkg";
|
TextWeight.Text = $"{weight:N0}{Utils.UnitSeparator}kg";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ namespace Elwig.Dialogs {
|
|||||||
|
|
||||||
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
private void ConfirmButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
DialogResult = true;
|
DialogResult = true;
|
||||||
Price = double.Parse(PriceInput.Text.Replace("\u202f", ""));
|
Price = double.Parse(PriceInput.Text.Replace(Utils.GroupSeparator, ""));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||||
<ApplicationIcon>Resources\Images\Elwig.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\Images\Elwig.ico</ApplicationIcon>
|
||||||
<Version>0.5.1</Version>
|
<Version>0.6.0</Version>
|
||||||
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.5.1" />
|
||||||
<PackageReference Include="LinqKit" Version="1.2.5" />
|
<PackageReference Include="LinqKit" Version="1.2.5" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.25" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="6.0.26" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2151.40" />
|
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2210.55" />
|
||||||
<PackageReference Include="NJsonSchema" Version="11.0.0" />
|
<PackageReference Include="NJsonSchema" Version="11.0.0" />
|
||||||
<PackageReference Include="RazorLight" Version="2.3.1" />
|
<PackageReference Include="RazorLight" Version="2.3.1" />
|
||||||
<PackageReference Include="ScottPlot.WPF" Version="4.1.68" />
|
<PackageReference Include="ScottPlot.WPF" Version="4.1.68" />
|
||||||
|
@@ -13,7 +13,6 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
public enum CalculationMode { Elwig, WgMaster }
|
public enum CalculationMode { Elwig, WgMaster }
|
||||||
public enum CurveMode { Oe, Kmw }
|
public enum CurveMode { Oe, Kmw }
|
||||||
|
|
||||||
public record struct Curve(CurveMode Mode, Dictionary<double, decimal> Normal, Dictionary<double, decimal>? Gebunden);
|
public record struct Curve(CurveMode Mode, Dictionary<double, decimal> Normal, Dictionary<double, decimal>? Gebunden);
|
||||||
|
|
||||||
public static JsonSchema? Schema { get; private set; }
|
public static JsonSchema? Schema { get; private set; }
|
||||||
@@ -24,11 +23,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public readonly JsonObject Data;
|
public readonly JsonObject Data;
|
||||||
|
public readonly CalculationMode Mode;
|
||||||
private readonly CalculationMode Mode;
|
|
||||||
private readonly Dictionary<int, Curve> Curves;
|
|
||||||
private readonly Dictionary<string, Curve> PaymentData;
|
|
||||||
private readonly Dictionary<string, Curve> QualityData;
|
|
||||||
|
|
||||||
public bool ConsiderDelieryModifiers {
|
public bool ConsiderDelieryModifiers {
|
||||||
get => GetConsider("consider_delivery_modifiers");
|
get => GetConsider("consider_delivery_modifiers");
|
||||||
@@ -61,18 +56,13 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BillingData(JsonObject data, IEnumerable<string> attributeVariants) {
|
public BillingData(JsonObject data) {
|
||||||
if (attributeVariants.Any(e => e.Any(c => c < 'A' || c > 'Z')))
|
|
||||||
throw new ArgumentException("Invalid attributeVariants");
|
|
||||||
Data = data;
|
Data = data;
|
||||||
var mode = Data["mode"]?.GetValue<string>();
|
var mode = Data["mode"]?.GetValue<string>();
|
||||||
Mode = (mode == "elwig") ? CalculationMode.Elwig : CalculationMode.WgMaster;
|
Mode = (mode == "elwig") ? CalculationMode.Elwig : CalculationMode.WgMaster;
|
||||||
Curves = GetCurves(Data, Mode);
|
|
||||||
PaymentData = GetPaymentData(attributeVariants);
|
|
||||||
QualityData = GetQualityData(attributeVariants);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonObject ParseJson(string json) {
|
protected static JsonObject ParseJson(string json) {
|
||||||
if (Schema == null) throw new InvalidOperationException("Schema has to be initialized first");
|
if (Schema == null) throw new InvalidOperationException("Schema has to be initialized first");
|
||||||
try {
|
try {
|
||||||
var errors = Schema.Validate(json);
|
var errors = Schema.Validate(json);
|
||||||
@@ -84,11 +74,19 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static BillingData FromJson(string json) {
|
public static BillingData FromJson(string json) {
|
||||||
return FromJson(json, []);
|
return new(ParseJson(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
protected JsonArray GetCurvesEntry() {
|
||||||
return new(ParseJson(json), attributeVariants);
|
return Data[Mode == CalculationMode.Elwig ? "curves" : "Kurven"]?.AsArray() ?? throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JsonNode GetPaymentEntry() {
|
||||||
|
return Data[Mode == CalculationMode.Elwig ? "payment" : "AuszahlungSorten"] ?? throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected JsonObject? GetQualityEntry() {
|
||||||
|
return Data[Mode == CalculationMode.Elwig ? "quality" : "AuszahlungSortenQualitätsstufe"]?.AsObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<double, decimal> GetCurveData(JsonObject data, CurveMode mode) {
|
private static Dictionary<double, decimal> GetCurveData(JsonObject data, CurveMode mode) {
|
||||||
@@ -119,9 +117,9 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<int, Curve> GetCurves(JsonObject data, CalculationMode mode) {
|
protected Dictionary<int, Curve> GetCurves() {
|
||||||
var dict = new Dictionary<int, Curve>();
|
var dict = new Dictionary<int, Curve>();
|
||||||
var curves = data[mode == CalculationMode.Elwig ? "curves" : "Kurven"]?.AsArray() ?? throw new InvalidOperationException();
|
var curves = GetCurvesEntry();
|
||||||
foreach (var c in curves) {
|
foreach (var c in curves) {
|
||||||
var obj = c?.AsObject() ?? throw new InvalidOperationException();
|
var obj = c?.AsObject() ?? throw new InvalidOperationException();
|
||||||
var id = obj["id"]?.GetValue<int>() ?? throw new InvalidOperationException();
|
var id = obj["id"]?.GetValue<int>() ?? throw new InvalidOperationException();
|
||||||
@@ -147,108 +145,5 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, Curve> GetData(JsonObject data, IEnumerable<string> attributeVariants) {
|
|
||||||
Dictionary<string, Curve> dict;
|
|
||||||
if (data["default"] is JsonValue def) {
|
|
||||||
var c = LookupCurve(def);
|
|
||||||
dict = attributeVariants.ToDictionary(e => e, _ => c);
|
|
||||||
} else {
|
|
||||||
dict = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
var variants = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length == 2);
|
|
||||||
var attributes = data.Where(p => p.Key.StartsWith('/'));
|
|
||||||
var others = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length > 2);
|
|
||||||
foreach (var (idx, v) in variants) {
|
|
||||||
var curve = LookupCurve(v?.AsValue() ?? throw new InvalidOperationException());
|
|
||||||
foreach (var i in attributeVariants.Where(e => e.StartsWith(idx[..^1]))) {
|
|
||||||
dict[i] = curve;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var (idx, v) in attributes) {
|
|
||||||
var curve = LookupCurve(v?.AsValue() ?? throw new InvalidOperationException());
|
|
||||||
foreach (var i in attributeVariants.Where(e => e[2..] == idx[1..])) {
|
|
||||||
dict[i] = curve;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (var (idx, v) in others) {
|
|
||||||
var curve = LookupCurve(v?.AsValue() ?? throw new InvalidOperationException());
|
|
||||||
dict[idx.Replace("/", "")] = curve;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dict;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Curve> GetPaymentData(IEnumerable<string> attributeVariants) {
|
|
||||||
var p = Data[Mode == CalculationMode.Elwig ? "payment" : "AuszahlungSorten"];
|
|
||||||
if (p is JsonValue val) {
|
|
||||||
var c = LookupCurve(val);
|
|
||||||
return attributeVariants.ToDictionary(e => e, _ => c);
|
|
||||||
}
|
|
||||||
return GetData(p?.AsObject() ?? throw new InvalidOperationException(), attributeVariants);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<string, Curve> GetQualityData(IEnumerable<string> attributeVariants) {
|
|
||||||
var q = Data[Mode == CalculationMode.Elwig ? "quality" : "AuszahlungSortenQualitätsstufe"]?.AsObject();
|
|
||||||
Dictionary<string, Curve> dict = [];
|
|
||||||
if (q == null) return dict;
|
|
||||||
|
|
||||||
foreach (var (qualid, data) in q) {
|
|
||||||
Dictionary<string, Curve> qualDict;
|
|
||||||
if (data is JsonValue val) {
|
|
||||||
var c = LookupCurve(val);
|
|
||||||
qualDict = attributeVariants.ToDictionary(e => e, _ => c);
|
|
||||||
} else {
|
|
||||||
qualDict = GetData(data?.AsObject() ?? throw new InvalidOperationException(), attributeVariants);
|
|
||||||
}
|
|
||||||
foreach (var (idx, d) in qualDict) {
|
|
||||||
dict[$"{qualid}/{idx}"] = d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return dict;
|
|
||||||
}
|
|
||||||
|
|
||||||
public decimal CalculatePrice(string sortid, string? attrid, string qualid, bool gebunden, double oe, double kmw) {
|
|
||||||
var curve = GetQualityCurve(qualid, sortid, attrid) ?? GetCurve(sortid, attrid);
|
|
||||||
var d = (gebunden ? curve.Gebunden : null) ?? curve.Normal;
|
|
||||||
if (d.Count == 1) return d.First().Value;
|
|
||||||
|
|
||||||
var r = curve.Mode == CurveMode.Oe ? oe : kmw;
|
|
||||||
var lt = d.Keys.Where(v => v <= r);
|
|
||||||
var gt = d.Keys.Where(v => v >= r);
|
|
||||||
if (!lt.Any()) {
|
|
||||||
return d[gt.Min()];
|
|
||||||
} else if (!gt.Any()) {
|
|
||||||
return d[lt.Max()];
|
|
||||||
}
|
|
||||||
|
|
||||||
var max = lt.Max();
|
|
||||||
var min = gt.Min();
|
|
||||||
if (max == min) return d[r];
|
|
||||||
|
|
||||||
var p1 = ((decimal)r - (decimal)min) / ((decimal)max - (decimal)min);
|
|
||||||
var p2 = 1 - p1;
|
|
||||||
return d[min] * p2 + d[max] * p1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Curve LookupCurve(JsonValue val) {
|
|
||||||
if (val.TryGetValue(out string? curve)) {
|
|
||||||
var curveId = int.Parse(curve.Split(":")[1]);
|
|
||||||
return Curves[curveId];
|
|
||||||
} else if (val.TryGetValue(out decimal value)) {
|
|
||||||
return new(CurveMode.Oe, new() { { 73, value } }, null);
|
|
||||||
}
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Curve GetCurve(string sortid, string? attrid) {
|
|
||||||
return PaymentData[$"{sortid}{attrid ?? ""}"];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Curve? GetQualityCurve(string qualid, string sortid, string? attrid) {
|
|
||||||
return QualityData.TryGetValue($"{qualid}/{sortid}{attrid ?? ""}", out var curve) ? curve : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
protected readonly int AvNr;
|
protected readonly int AvNr;
|
||||||
protected readonly PaymentVar PaymentVariant;
|
protected readonly PaymentVar PaymentVariant;
|
||||||
protected readonly BillingData Data;
|
protected readonly PaymentBillingData Data;
|
||||||
|
|
||||||
public BillingVariant(int year, int avnr) : base(year) {
|
public BillingVariant(int year, int avnr) : base(year) {
|
||||||
AvNr = avnr;
|
AvNr = avnr;
|
||||||
@@ -22,7 +22,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
.ToList()
|
.ToList()
|
||||||
.Union(Context.WineVarieties.Select(v => v.SortId))
|
.Union(Context.WineVarieties.Select(v => v.SortId))
|
||||||
.ToList();
|
.ToList();
|
||||||
Data = BillingData.FromJson(PaymentVariant.Data, attrVariants);
|
Data = PaymentBillingData.FromJson(PaymentVariant.Data, attrVariants);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Calculate() {
|
public async Task Calculate() {
|
||||||
|
90
Elwig/Helpers/Billing/EditBillingData.cs
Normal file
90
Elwig/Helpers/Billing/EditBillingData.cs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers.Billing {
|
||||||
|
public class EditBillingData : BillingData {
|
||||||
|
|
||||||
|
protected readonly IEnumerable<string> AttributeVariants;
|
||||||
|
|
||||||
|
public EditBillingData(JsonObject data, IEnumerable<string> attributeVariants) :
|
||||||
|
base(data) {
|
||||||
|
AttributeVariants = attributeVariants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EditBillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
||||||
|
return new(ParseJson(json), attributeVariants);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<GraphEntry> GetPaymentGraphEntries() {
|
||||||
|
Dictionary<int, List<string>> dict1 = [];
|
||||||
|
Dictionary<decimal, List<string>> dict2 = [];
|
||||||
|
var p = GetPaymentEntry();
|
||||||
|
if (p is JsonObject paymentObj) {
|
||||||
|
foreach (var (selector, node) in paymentObj) {
|
||||||
|
var val = node?.AsValue();
|
||||||
|
if (val == null) {
|
||||||
|
continue;
|
||||||
|
} else if (val.TryGetValue<decimal>(out var price)) {
|
||||||
|
if (!dict2.ContainsKey(price)) dict2[price] = [];
|
||||||
|
dict2[price].Add(selector);
|
||||||
|
} else if (val.TryGetValue<string>(out var curve)) {
|
||||||
|
var idx = int.Parse(curve.Split(":")[1] ?? "0");
|
||||||
|
if (!dict1.ContainsKey(idx)) dict1[idx] = [];
|
||||||
|
dict1[idx].Add(selector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (p is JsonValue paymentVal) {
|
||||||
|
var idx = paymentVal.GetValue<decimal>();
|
||||||
|
if (!dict2.ContainsKey(idx)) dict2[idx] = [];
|
||||||
|
dict2[idx].Add("default");
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<int, Curve> curves = GetCurves();
|
||||||
|
decimal[] virtCurves = [.. dict2.Keys.Order()];
|
||||||
|
for (int i = 0; i < virtCurves.Length; i++) {
|
||||||
|
var idx = virtCurves[i];
|
||||||
|
dict1[1000 + i] = dict2[idx];
|
||||||
|
curves[1000 + i] = new Curve(CurveMode.Oe, new() { { 73, idx } }, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<int, List<string>> dict3 = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return dict3.Select(e => new GraphEntry(e.Key, curves[e.Key], 50, 120)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<GraphEntry> GetQualityGraphEntries() {
|
||||||
|
Dictionary<int, List<string>> dict1 = [];
|
||||||
|
Dictionary<decimal, List<string>> dict2 = [];
|
||||||
|
foreach (var (qualid, q) in GetQualityEntry() ?? []) {
|
||||||
|
if (q is JsonObject qualityObj) {
|
||||||
|
foreach (var (selector, node) in qualityObj) {
|
||||||
|
var val = node?.AsValue();
|
||||||
|
if (val == null) {
|
||||||
|
continue;
|
||||||
|
} else if (val.TryGetValue<decimal>(out var price)) {
|
||||||
|
if (!dict2.ContainsKey(price)) dict2[price] = [];
|
||||||
|
dict2[price].Add(selector);
|
||||||
|
} else if (val.TryGetValue<string>(out var curve)) {
|
||||||
|
var idx = int.Parse(curve.Split(":")[1] ?? "0");
|
||||||
|
if (!dict1.ContainsKey(idx)) dict1[idx] = [];
|
||||||
|
dict1[idx].Add(selector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (q is JsonValue qualityVal) {
|
||||||
|
var idx = qualityVal.GetValue<decimal>();
|
||||||
|
if (!dict2.ContainsKey(idx)) dict2[idx] = [];
|
||||||
|
dict2[idx].Add($"{qualid}/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
List<GraphEntry> list = [];
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -3,7 +3,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Windows.Documents;
|
|
||||||
|
|
||||||
namespace Elwig.Helpers.Billing {
|
namespace Elwig.Helpers.Billing {
|
||||||
public class Graph : ICloneable {
|
public class Graph : ICloneable {
|
||||||
|
@@ -1,9 +1,5 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Elwig.Helpers.Billing {
|
namespace Elwig.Helpers.Billing {
|
||||||
public class GraphEntry {
|
public class GraphEntry {
|
||||||
@@ -26,12 +22,20 @@ namespace Elwig.Helpers.Billing {
|
|||||||
Contracts = [];
|
Contracts = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphEntry(int id, BillingData.CurveMode mode, Dictionary<double, decimal> data, int minX, int maxX) : this(id, mode, minX, maxX) {
|
public GraphEntry(int id, BillingData.CurveMode mode, Dictionary<double, decimal> data, int minX, int maxX) :
|
||||||
|
this(id, mode, minX, maxX) {
|
||||||
DataGraph = new Graph(data, minX, maxX);
|
DataGraph = new Graph(data, minX, maxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GraphEntry(int id, BillingData.Curve curve, int minX, int maxX) :
|
||||||
|
this(id, curve.Mode, minX, maxX) {
|
||||||
|
DataGraph = new Graph(curve.Normal, minX, maxX);
|
||||||
|
if (curve.Gebunden != null)
|
||||||
|
GebundenGraph = new Graph(curve.Gebunden, minX, maxX);
|
||||||
|
}
|
||||||
|
|
||||||
private GraphEntry(int id, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
|
private GraphEntry(int id, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
|
||||||
decimal? gebundenFlatPrice, List<string> contracts, int minX, int maxX) {
|
decimal? gebundenFlatPrice, List<string> contracts, int minX, int maxX) {
|
||||||
Id = id;
|
Id = id;
|
||||||
Mode = mode;
|
Mode = mode;
|
||||||
MinX = minX;
|
MinX = minX;
|
||||||
|
132
Elwig/Helpers/Billing/PaymentBillingData.cs
Normal file
132
Elwig/Helpers/Billing/PaymentBillingData.cs
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
|
namespace Elwig.Helpers.Billing {
|
||||||
|
public class PaymentBillingData : BillingData {
|
||||||
|
|
||||||
|
protected readonly Dictionary<int, Curve> Curves;
|
||||||
|
protected readonly Dictionary<string, Curve> PaymentData;
|
||||||
|
protected readonly Dictionary<string, Curve> QualityData;
|
||||||
|
protected readonly IEnumerable<string> AttributeVariants;
|
||||||
|
|
||||||
|
public PaymentBillingData(JsonObject data, IEnumerable<string> attributeVariants) :
|
||||||
|
base(data) {
|
||||||
|
if (attributeVariants.Any(e => e.Any(c => c < 'A' || c > 'Z')))
|
||||||
|
throw new ArgumentException("Invalid attributeVariants");
|
||||||
|
AttributeVariants = attributeVariants;
|
||||||
|
Curves = GetCurves();
|
||||||
|
PaymentData = GetPaymentData();
|
||||||
|
QualityData = GetQualityData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PaymentBillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
||||||
|
return new(ParseJson(json), attributeVariants);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dictionary<string, Curve> GetData(JsonObject data) {
|
||||||
|
Dictionary<string, Curve> dict;
|
||||||
|
if (data["default"] is JsonValue def) {
|
||||||
|
var c = LookupCurve(def);
|
||||||
|
dict = AttributeVariants.ToDictionary(e => e, _ => c);
|
||||||
|
} else {
|
||||||
|
dict = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
var variants = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length == 2);
|
||||||
|
var attributes = data.Where(p => p.Key.StartsWith('/'));
|
||||||
|
var others = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length > 2);
|
||||||
|
foreach (var (idx, v) in variants) {
|
||||||
|
var curve = LookupCurve(v?.AsValue() ?? throw new InvalidOperationException());
|
||||||
|
foreach (var i in AttributeVariants.Where(e => e.StartsWith(idx[..^1]))) {
|
||||||
|
dict[i] = curve;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var (idx, v) in attributes) {
|
||||||
|
var curve = LookupCurve(v?.AsValue() ?? throw new InvalidOperationException());
|
||||||
|
foreach (var i in AttributeVariants.Where(e => e[2..] == idx[1..])) {
|
||||||
|
dict[i] = curve;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var (idx, v) in others) {
|
||||||
|
var curve = LookupCurve(v?.AsValue() ?? throw new InvalidOperationException());
|
||||||
|
dict[idx.Replace("/", "")] = curve;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Dictionary<string, Curve> GetPaymentData() {
|
||||||
|
var p = GetPaymentEntry();
|
||||||
|
if (p is JsonValue val) {
|
||||||
|
var c = LookupCurve(val);
|
||||||
|
return AttributeVariants.ToDictionary(e => e, _ => c);
|
||||||
|
}
|
||||||
|
return GetData(p?.AsObject() ?? throw new InvalidOperationException());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Dictionary<string, Curve> GetQualityData() {
|
||||||
|
Dictionary<string, Curve> dict = [];
|
||||||
|
var q = GetQualityEntry();
|
||||||
|
if (q == null) return dict;
|
||||||
|
|
||||||
|
foreach (var (qualid, data) in q) {
|
||||||
|
Dictionary<string, Curve> qualDict;
|
||||||
|
if (data is JsonValue val) {
|
||||||
|
var c = LookupCurve(val);
|
||||||
|
qualDict = AttributeVariants.ToDictionary(e => e, _ => c);
|
||||||
|
} else {
|
||||||
|
qualDict = GetData(data?.AsObject() ?? throw new InvalidOperationException());
|
||||||
|
}
|
||||||
|
foreach (var (idx, d) in qualDict) {
|
||||||
|
dict[$"{qualid}/{idx}"] = d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
public decimal CalculatePrice(string sortid, string? attrid, string qualid, bool gebunden, double oe, double kmw) {
|
||||||
|
var curve = GetQualityCurve(qualid, sortid, attrid) ?? GetCurve(sortid, attrid);
|
||||||
|
var d = (gebunden ? curve.Gebunden : null) ?? curve.Normal;
|
||||||
|
if (d.Count == 1) return d.First().Value;
|
||||||
|
|
||||||
|
var r = curve.Mode == CurveMode.Oe ? oe : kmw;
|
||||||
|
var lt = d.Keys.Where(v => v <= r);
|
||||||
|
var gt = d.Keys.Where(v => v >= r);
|
||||||
|
if (!lt.Any()) {
|
||||||
|
return d[gt.Min()];
|
||||||
|
} else if (!gt.Any()) {
|
||||||
|
return d[lt.Max()];
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = lt.Max();
|
||||||
|
var min = gt.Min();
|
||||||
|
if (max == min) return d[r];
|
||||||
|
|
||||||
|
var p1 = ((decimal)r - (decimal)min) / ((decimal)max - (decimal)min);
|
||||||
|
var p2 = 1 - p1;
|
||||||
|
return d[min] * p2 + d[max] * p1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Curve LookupCurve(JsonValue val) {
|
||||||
|
if (val.TryGetValue(out string? curve)) {
|
||||||
|
var curveId = int.Parse(curve.Split(":")[1]);
|
||||||
|
return Curves[curveId];
|
||||||
|
} else if (val.TryGetValue(out decimal value)) {
|
||||||
|
return new(CurveMode.Oe, new() { { 73, value } }, null);
|
||||||
|
}
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Curve GetCurve(string sortid, string? attrid) {
|
||||||
|
return PaymentData[$"{sortid}{attrid ?? ""}"];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Curve? GetQualityCurve(string qualid, string sortid, string? attrid) {
|
||||||
|
return QualityData.TryGetValue($"{qualid}/{sortid}{attrid ?? ""}", out var curve) ? curve : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -24,9 +24,9 @@ namespace Elwig.Helpers {
|
|||||||
public void Read() {
|
public void Read() {
|
||||||
var config = new ConfigurationBuilder().AddIniFile(FileName).Build();
|
var config = new ConfigurationBuilder().AddIniFile(FileName).Build();
|
||||||
|
|
||||||
DatabaseFile = Utils.GetAbsolutePath(config["database:file"] ?? "database.sqlite3", App.DataPath);
|
DatabaseFile = Path.Combine(App.DataPath, config["database:file"] ?? "database.sqlite3");
|
||||||
var log = config["database:log"];
|
var log = config["database:log"];
|
||||||
DatabaseLog = log != null ? Utils.GetAbsolutePath(log, App.DataPath) : null;
|
DatabaseLog = log != null ? Path.Combine(App.DataPath, log) : null;
|
||||||
Branch = config["general:branch"];
|
Branch = config["general:branch"];
|
||||||
Debug = trueValues.Contains(config["general:debug"]?.ToLower());
|
Debug = trueValues.Contains(config["general:debug"]?.ToLower());
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ namespace Elwig.Helpers {
|
|||||||
Scales = ScaleList;
|
Scales = ScaleList;
|
||||||
foreach (var s in scales) {
|
foreach (var s in scales) {
|
||||||
string? scaleLog = config[$"scale.{s}:log"];
|
string? scaleLog = config[$"scale.{s}:log"];
|
||||||
if (scaleLog != null) scaleLog = Utils.GetAbsolutePath(scaleLog, App.DataPath);
|
if (scaleLog != null) scaleLog = Path.Combine(App.DataPath, scaleLog);
|
||||||
ScaleList.Add([
|
ScaleList.Add([
|
||||||
s, config[$"scale.{s}:type"], config[$"scale.{s}:model"], config[$"scale.{s}:connection"],
|
s, config[$"scale.{s}:type"], config[$"scale.{s}:model"], config[$"scale.{s}:connection"],
|
||||||
config[$"scale.{s}:empty"], config[$"scale.{s}:filling"], config[$"scale.{s}:limit"], scaleLog
|
config[$"scale.{s}:empty"], config[$"scale.{s}:filling"], config[$"scale.{s}:limit"], scaleLog
|
||||||
|
@@ -48,6 +48,9 @@ namespace Elwig.Helpers {
|
|||||||
[GeneratedRegex(@"^(.*?) +([0-9].*)$", RegexOptions.Compiled)]
|
[GeneratedRegex(@"^(.*?) +([0-9].*)$", RegexOptions.Compiled)]
|
||||||
private static partial Regex GeneratedAddressRegex();
|
private static partial Regex GeneratedAddressRegex();
|
||||||
|
|
||||||
|
public static readonly string GroupSeparator = "\u202F";
|
||||||
|
public static readonly string UnitSeparator = "\u00A0";
|
||||||
|
|
||||||
public static readonly KeyValuePair<string, string>[] PhoneNrTypes = [
|
public static readonly KeyValuePair<string, string>[] PhoneNrTypes = [
|
||||||
new("landline", "Tel.-Nr. (Festnetz)"),
|
new("landline", "Tel.-Nr. (Festnetz)"),
|
||||||
new("mobile", "Tel.-Nr. (mobil)"),
|
new("mobile", "Tel.-Nr. (mobil)"),
|
||||||
@@ -356,9 +359,5 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
return output.OrderByDescending(l => l.Count());
|
return output.OrderByDescending(l => l.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetAbsolutePath(string path, string basePath) {
|
|
||||||
return (path.Length > 1 && (path[1] == ':' || path[0] == '/' || path[0] == '\\')) ? Path.Combine(basePath, path) : path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,6 +26,10 @@ namespace Elwig.Models.Dtos {
|
|||||||
MgNr = m.MgNr;
|
MgNr = m.MgNr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DeliveryConfirmationData CreateEmpty(int year, Member m) {
|
||||||
|
return new([], year, m);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<IDictionary<int, DeliveryConfirmationData>> ForSeason(DbSet<DeliveryPart> table, int year) {
|
public static async Task<IDictionary<int, DeliveryConfirmationData>> ForSeason(DbSet<DeliveryPart> table, int year) {
|
||||||
return (await FromDbSet(table, year))
|
return (await FromDbSet(table, year))
|
||||||
.GroupBy(
|
.GroupBy(
|
||||||
|
@@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
<PublishDir>bin\Publish</PublishDir>
|
<PublishDir>bin\Publish</PublishDir>
|
||||||
<PublishProtocol>FileSystem</PublishProtocol>
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
<_TargetId>Folder</_TargetId>
|
<_TargetId>Folder</_TargetId>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<SelfContained>true</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
<PublishSingleFile>false</PublishSingleFile>
|
<PublishSingleFile>false</PublishSingleFile>
|
||||||
|
@@ -125,6 +125,7 @@ namespace Elwig.Windows {
|
|||||||
if (old != null) _branches[old] = id;
|
if (old != null) _branches[old] = id;
|
||||||
branch.ZwstId = id;
|
branch.ZwstId = id;
|
||||||
branch.Name = BranchNameInput.Text;
|
branch.Name = BranchNameInput.Text;
|
||||||
|
branch.CountryNum = 40;
|
||||||
branch.PostalDestId = (BranchOrtInput.SelectedItem as AT_PlzDest)?.Id;
|
branch.PostalDestId = (BranchOrtInput.SelectedItem as AT_PlzDest)?.Id;
|
||||||
branch.Address = BranchAddressInput.Text;
|
branch.Address = BranchAddressInput.Text;
|
||||||
branch.PhoneNr = BranchPhoneNrInput.Text;
|
branch.PhoneNr = BranchPhoneNrInput.Text;
|
||||||
|
@@ -52,13 +52,13 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
var year = (SeasonList.SelectedItem as Season)?.Year;
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
foreach (var (modid, _) in _mods.Where(m => m.Value == null)) {
|
foreach (var (modid, _) in _mods.Where(m => m.Value == null)) {
|
||||||
Context.Remove(Context.Modifiers.Find(new object?[] { year, modid }));
|
Context.Remove(Context.Modifiers.Find(year, modid));
|
||||||
}
|
}
|
||||||
foreach (var (mod, old) in _modIds) {
|
foreach (var (mod, old) in _modIds) {
|
||||||
mod.ModId = old;
|
mod.ModId = old;
|
||||||
}
|
}
|
||||||
foreach (var (old, modid) in _mods.Where(m => m.Value != null)) {
|
foreach (var (old, modid) in _mods.Where(m => m.Value != null)) {
|
||||||
Context.Update(Context.Modifiers.Find(new object?[] { year, old }));
|
Context.Update(Context.Modifiers.Find(year, old));
|
||||||
}
|
}
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
|
|
||||||
@@ -102,8 +102,9 @@ namespace Elwig.Windows {
|
|||||||
if (_modList == null || SeasonList.SelectedItem is not Season s) return;
|
if (_modList == null || SeasonList.SelectedItem is not Season s) return;
|
||||||
_modChanged = true;
|
_modChanged = true;
|
||||||
var idx = (SeasonModifierList.SelectedIndex != -1) ? SeasonModifierList.SelectedIndex + 1 : _modList.Count;
|
var idx = (SeasonModifierList.SelectedIndex != -1) ? SeasonModifierList.SelectedIndex + 1 : _modList.Count;
|
||||||
var item = Context.CreateProxy<Modifier>();
|
var item = new Modifier {
|
||||||
item.Year = s.Year;
|
Year = s.Year
|
||||||
|
};
|
||||||
_modList.Insert(idx, item);
|
_modList.Insert(idx, item);
|
||||||
SeasonModifierList.SelectedIndex = idx;
|
SeasonModifierList.SelectedIndex = idx;
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
|
@@ -264,6 +264,8 @@ namespace Elwig.Windows {
|
|||||||
ClearInputStates();
|
ClearInputStates();
|
||||||
FillInputs(App.Client);
|
FillInputs(App.Client);
|
||||||
LockInputs();
|
LockInputs();
|
||||||
|
|
||||||
|
await HintContextChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs(ClientParameters p) {
|
private void FillInputs(ClientParameters p) {
|
||||||
|
@@ -59,24 +59,7 @@ namespace Elwig.Windows {
|
|||||||
await RefreshGraphListQuery();
|
await RefreshGraphListQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JsonObject? ParseData(PaymentVar variant) {
|
private async Task RefreshGraphListQuery() {
|
||||||
try {
|
|
||||||
return BillingData.ParseJson(variant.Data);
|
|
||||||
} catch (ArgumentException) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task RefreshGraphListQuery(bool updateSort = false) {
|
|
||||||
var data = ParseData(PaymentVar);
|
|
||||||
if (data == null) return;
|
|
||||||
|
|
||||||
var curves = BillingData.GetCurves(data, BillingData.CalculationMode.Elwig);
|
|
||||||
|
|
||||||
foreach (var (id, curve) in curves) {
|
|
||||||
GraphEntries.Add(new GraphEntry(id, curve.Mode, curve.Normal, MinOechsle, MaxOechsle));
|
|
||||||
}
|
|
||||||
|
|
||||||
var attrVariants = Context.DeliveryParts
|
var attrVariants = Context.DeliveryParts
|
||||||
.Where(d => d.Year == Year)
|
.Where(d => d.Year == Year)
|
||||||
.Select(d => $"{d.SortId}{d.AttrId}")
|
.Select(d => $"{d.SortId}{d.AttrId}")
|
||||||
@@ -85,12 +68,12 @@ namespace Elwig.Windows {
|
|||||||
.Union(Context.WineVarieties.Select(v => v.SortId))
|
.Union(Context.WineVarieties.Select(v => v.SortId))
|
||||||
.Order()
|
.Order()
|
||||||
.ToList();
|
.ToList();
|
||||||
ControlUtils.RenewItemsSource(AppliedInput, attrVariants, g => (g as GraphEntry)?.Id);
|
var data = EditBillingData.FromJson(PaymentVar.Data, attrVariants);
|
||||||
|
GraphEntries.AddRange(data.GetPaymentGraphEntries());
|
||||||
|
GraphEntries.AddRange(data.GetQualityGraphEntries());
|
||||||
|
|
||||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id);
|
ControlUtils.RenewItemsSource(AppliedInput, attrVariants, g => g);
|
||||||
if (GraphEntries.Count == 1) {
|
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id, null, ControlUtils.RenewSourceDefault.IfOnly);
|
||||||
GraphList.SelectedIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
@@ -98,7 +81,6 @@ namespace Elwig.Windows {
|
|||||||
private string ParseContracts(JsonObject auszahlungsSorten, int num) {
|
private string ParseContracts(JsonObject auszahlungsSorten, int num) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void RefreshInputs(bool validate = false) {
|
private void RefreshInputs(bool validate = false) {
|
||||||
ResetPlot();
|
ResetPlot();
|
||||||
|
@@ -100,7 +100,8 @@
|
|||||||
<LineBreak/>
|
<LineBreak/>
|
||||||
Filtern nach:<LineBreak/>
|
Filtern nach:<LineBreak/>
|
||||||
<Bold>Sorte</Bold>: z.B. GV, ZW, rr, sa, !gv (ausgenommen GV), ...<LineBreak/>
|
<Bold>Sorte</Bold>: z.B. GV, ZW, rr, sa, !gv (ausgenommen GV), ...<LineBreak/>
|
||||||
<Bold>Qualitätsstufe</Bold>: z.B. QUW, kab, ldw, ...<LineBreak/>
|
<Bold>Rot/Weiß</Bold>: z.B. r, Rot, w, weiß, ...<LineBreak/>
|
||||||
|
<Bold>Qualitätsstufe</Bold>: z.B. QUW, kab, !ldw (ausgenommen LDW), ...<LineBreak/>
|
||||||
<Bold>Gradation</Bold>: z.B. >73, <15, 17-18, 15-, >17,5, 62-75, ...<LineBreak/>
|
<Bold>Gradation</Bold>: z.B. >73, <15, 17-18, 15-, >17,5, 62-75, ...<LineBreak/>
|
||||||
<Bold>Mitglied</Bold>: z.B. 1234, 987, ...<LineBreak/>
|
<Bold>Mitglied</Bold>: z.B. 1234, 987, ...<LineBreak/>
|
||||||
<Bold>Saison</Bold>: z.B. 2020, >2015, 2017-2019, <2005, 2019-, ...<LineBreak/>
|
<Bold>Saison</Bold>: z.B. 2020, >2015, 2017-2019, <2005, 2019-, ...<LineBreak/>
|
||||||
|
@@ -326,6 +326,7 @@ namespace Elwig.Windows {
|
|||||||
var filterVar = new List<string>();
|
var filterVar = new List<string>();
|
||||||
var filterNotVar = new List<string>();
|
var filterNotVar = new List<string>();
|
||||||
var filterQual = new List<string>();
|
var filterQual = new List<string>();
|
||||||
|
var filterNotQual = new List<string>();
|
||||||
var filterMgNr = new List<int>();
|
var filterMgNr = new List<int>();
|
||||||
var filterZwst = new List<string>();
|
var filterZwst = new List<string>();
|
||||||
var filterAttr = new List<string>();
|
var filterAttr = new List<string>();
|
||||||
@@ -346,7 +347,15 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
for (int i = 0; i < filter.Count; i++) {
|
for (int i = 0; i < filter.Count; i++) {
|
||||||
var e = filter[i];
|
var e = filter[i];
|
||||||
if (e.Length == 2 && var.ContainsKey(e.ToUpper())) {
|
if (e.ToLower() is "r" or "rot") {
|
||||||
|
filterVar.AddRange(var.Values.Where(v => v.IsRed).Select(v => v.SortId));
|
||||||
|
filter.RemoveAt(i--);
|
||||||
|
filterNames.Add("Rotweinsorten");
|
||||||
|
} else if (e.ToLower() is "w" or "weiß" or "weiss") {
|
||||||
|
filterVar.AddRange(var.Values.Where(v => v.IsWhite).Select(v => v.SortId));
|
||||||
|
filter.RemoveAt(i--);
|
||||||
|
filterNames.Add("Weißweinsorten");
|
||||||
|
} else if (e.Length == 2 && var.ContainsKey(e.ToUpper())) {
|
||||||
filterVar.Add(e.ToUpper());
|
filterVar.Add(e.ToUpper());
|
||||||
filter.RemoveAt(i--);
|
filter.RemoveAt(i--);
|
||||||
filterNames.Add(var[e.ToUpper()].Name);
|
filterNames.Add(var[e.ToUpper()].Name);
|
||||||
@@ -358,6 +367,10 @@ namespace Elwig.Windows {
|
|||||||
filterQual.Add(e.ToUpper());
|
filterQual.Add(e.ToUpper());
|
||||||
filter.RemoveAt(i--);
|
filter.RemoveAt(i--);
|
||||||
filterNames.Add(qual[e.ToUpper()].Name);
|
filterNames.Add(qual[e.ToUpper()].Name);
|
||||||
|
} else if (e[0] == '!' && qual.ContainsKey(e[1..].ToUpper())) {
|
||||||
|
filterNotQual.Add(e[1..].ToUpper());
|
||||||
|
filter.RemoveAt(i--);
|
||||||
|
filterNames.Add("außer " + qual[e[1..].ToUpper()].Name);
|
||||||
} else if (e.All(char.IsAsciiDigit) && mgnr.TryGetValue(e, out var member)) {
|
} else if (e.All(char.IsAsciiDigit) && mgnr.TryGetValue(e, out var member)) {
|
||||||
filterMgNr.Add(int.Parse(e));
|
filterMgNr.Add(int.Parse(e));
|
||||||
filter.RemoveAt(i--);
|
filter.RemoveAt(i--);
|
||||||
@@ -492,9 +505,10 @@ namespace Elwig.Windows {
|
|||||||
if (filterVar.Count > 0) dpq = dpq.Where(p => filterVar.Contains(p.SortId));
|
if (filterVar.Count > 0) dpq = dpq.Where(p => filterVar.Contains(p.SortId));
|
||||||
if (filterNotVar.Count > 0) dpq = dpq.Where(p => !filterNotVar.Contains(p.SortId));
|
if (filterNotVar.Count > 0) dpq = dpq.Where(p => !filterNotVar.Contains(p.SortId));
|
||||||
if (filterQual.Count > 0) dpq = dpq.Where(p => filterQual.Contains(p.QualId));
|
if (filterQual.Count > 0) dpq = dpq.Where(p => filterQual.Contains(p.QualId));
|
||||||
|
if (filterNotQual.Count > 0) dpq = dpq.Where(p => !filterNotQual.Contains(p.QualId));
|
||||||
if (filterZwst.Count > 0) dpq = dpq.Where(p => filterZwst.Contains(p.Delivery.ZwstId));
|
if (filterZwst.Count > 0) dpq = dpq.Where(p => filterZwst.Contains(p.Delivery.ZwstId));
|
||||||
if (filterAttr.Count > 0) dpq = dpq.Where(p => p.AttrId != null && filterAttr.Contains(p.AttrId));
|
if (filterAttr.Count > 0) dpq = dpq.Where(p => p.AttrId != null && filterAttr.Contains(p.AttrId));
|
||||||
if (filterNotAttr.Count > 0) dpq = dpq.Where(p => p.AttrId == null || !filterAttr.Contains(p.AttrId));
|
if (filterNotAttr.Count > 0) dpq = dpq.Where(p => p.AttrId == null || !filterNotAttr.Contains(p.AttrId));
|
||||||
if (filterKmwGt > 0) dpq = dpq.Where(p => p.Kmw >= filterKmwGt);
|
if (filterKmwGt > 0) dpq = dpq.Where(p => p.Kmw >= filterKmwGt);
|
||||||
if (filterKmwLt > 0) dpq = dpq.Where(p => p.Kmw < filterKmwLt);
|
if (filterKmwLt > 0) dpq = dpq.Where(p => p.Kmw < filterKmwLt);
|
||||||
if (filterOeGt > 0) dpq = dpq.Where(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt);
|
if (filterOeGt > 0) dpq = dpq.Where(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt);
|
||||||
@@ -875,7 +889,7 @@ namespace Elwig.Windows {
|
|||||||
p.Acid = (AcidInput.Text == "") ? null : double.Parse(AcidInput.Text);
|
p.Acid = (AcidInput.Text == "") ? null : double.Parse(AcidInput.Text);
|
||||||
p.Comment = (PartCommentInput.Text == "") ? null : PartCommentInput.Text;
|
p.Comment = (PartCommentInput.Text == "") ? null : PartCommentInput.Text;
|
||||||
|
|
||||||
p.Weight = int.Parse(WeightInput.Text.Replace("\u202f", ""));
|
p.Weight = int.Parse(WeightInput.Text.Replace(Utils.GroupSeparator, ""));
|
||||||
p.ManualWeighing = ManualWeighingInput.IsChecked ?? false;
|
p.ManualWeighing = ManualWeighingInput.IsChecked ?? false;
|
||||||
p.ScaleId = ScaleId;
|
p.ScaleId = ScaleId;
|
||||||
p.WeighingId = WeighingId;
|
p.WeighingId = WeighingId;
|
||||||
|
@@ -76,7 +76,7 @@ namespace Elwig.Dialogs {
|
|||||||
IEnumerable<Member> list = await members.ToListAsync();
|
IEnumerable<Member> list = await members.ToListAsync();
|
||||||
var data = await DeliveryConfirmationData.ForSeason(Context.DeliveryParts, Year);
|
var data = await DeliveryConfirmationData.ForSeason(Context.DeliveryParts, Year);
|
||||||
using var doc = Document.Merge(list.Select(m =>
|
using var doc = Document.Merge(list.Select(m =>
|
||||||
new DeliveryConfirmation(Context, Year, m, data[m.MgNr]) {
|
new DeliveryConfirmation(Context, Year, m, data.TryGetValue(m.MgNr, out var d) ? d : DeliveryConfirmationData.CreateEmpty(Year, m)) {
|
||||||
//DoubleSided = true
|
//DoubleSided = true
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
@@ -259,8 +259,12 @@ namespace Elwig.Windows {
|
|||||||
return;
|
return;
|
||||||
CommitButton.IsEnabled = false;
|
CommitButton.IsEnabled = false;
|
||||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||||
var b = new BillingVariant(v.Year, v.AvNr);
|
try {
|
||||||
await b.Commit();
|
var b = new BillingVariant(v.Year, v.AvNr);
|
||||||
|
await b.Commit();
|
||||||
|
} catch (Exception exc) {
|
||||||
|
MessageBox.Show(exc.Message, "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
Mouse.OverrideCursor = null;
|
Mouse.OverrideCursor = null;
|
||||||
RevertButton.IsEnabled = true;
|
RevertButton.IsEnabled = true;
|
||||||
await App.HintContextChange();
|
await App.HintContextChange();
|
||||||
@@ -396,13 +400,13 @@ namespace Elwig.Windows {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var json = BillingData.ParseJson(DataInput.Text);
|
var data = BillingData.FromJson(DataInput.Text);
|
||||||
var origJson = v.Data;
|
var origJson = v.Data;
|
||||||
try {
|
try {
|
||||||
origJson = JsonSerializer.Serialize(BillingData.ParseJson(v.Data));
|
origJson = JsonSerializer.Serialize(BillingData.FromJson(v.Data).Data);
|
||||||
} catch { }
|
} catch { }
|
||||||
DataValid = true;
|
DataValid = true;
|
||||||
if (JsonSerializer.Serialize(json) != origJson) {
|
if (JsonSerializer.Serialize(data.Data) != origJson) {
|
||||||
ControlUtils.SetInputChanged(DataInput);
|
ControlUtils.SetInputChanged(DataInput);
|
||||||
DataChanged = true;
|
DataChanged = true;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -86,7 +86,7 @@ namespace Elwig.Windows {
|
|||||||
private async void AutoBusinessSharesButton_Click(object sender, RoutedEventArgs evt) {
|
private async void AutoBusinessSharesButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (SeasonInput.Value is not int year)
|
if (SeasonInput.Value is not int year)
|
||||||
return;
|
return;
|
||||||
if (App.Client.IsMatzen) {
|
if (false && App.Client.IsMatzen) {
|
||||||
AutoBusinessSharesButton.IsEnabled = false;
|
AutoBusinessSharesButton.IsEnabled = false;
|
||||||
Mouse.OverrideCursor = Cursors.AppStarting;
|
Mouse.OverrideCursor = Cursors.AppStarting;
|
||||||
|
|
||||||
|
@@ -60,6 +60,6 @@
|
|||||||
<None Include="Files\config.ini" />
|
<None Include="Files\config.ini" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="WixToolset.Heat" Version="4.0.1" />
|
<PackageReference Include="WixToolset.Heat" Version="4.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
</Target>
|
</Target>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Installer\Installer.wixproj" />
|
<ProjectReference Include="..\Installer\Installer.wixproj" />
|
||||||
<PackageReference Include="WixToolset.Bal.wixext" Version="4.0.1" />
|
<PackageReference Include="WixToolset.Bal.wixext" Version="4.0.3" />
|
||||||
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.1" />
|
<PackageReference Include="WixToolset.Util.wixext" Version="4.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@@ -26,14 +26,14 @@ namespace Tests.Helpers {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TestCalcOe(BillingData data, string bucket, double oe, decimal expected, string? qualid = null, bool geb = false) {
|
private static void TestCalcOe(PaymentBillingData data, string bucket, double oe, decimal expected, string? qualid = null, bool geb = false) {
|
||||||
var (sortid, attrid) = GetSortIdAttrId(bucket);
|
var (sortid, attrid) = GetSortIdAttrId(bucket);
|
||||||
var kmw = Utils.OeToKmw(oe);
|
var kmw = Utils.OeToKmw(oe);
|
||||||
var v = data.CalculatePrice(sortid, attrid, qualid ?? GetQualId(kmw), geb, oe, kmw);
|
var v = data.CalculatePrice(sortid, attrid, qualid ?? GetQualId(kmw), geb, oe, kmw);
|
||||||
Assert.That(Math.Round(v, 6), Is.EqualTo(expected));
|
Assert.That(Math.Round(v, 6), Is.EqualTo(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void TestCalcKmw(BillingData data, string bucket, double kmw, decimal expected, string? qualid = null, bool geb = false) {
|
private static void TestCalcKmw(PaymentBillingData data, string bucket, double kmw, decimal expected, string? qualid = null, bool geb = false) {
|
||||||
var (sortid, attrid) = GetSortIdAttrId(bucket);
|
var (sortid, attrid) = GetSortIdAttrId(bucket);
|
||||||
var oe = Utils.KmwToOe(kmw);
|
var oe = Utils.KmwToOe(kmw);
|
||||||
var v = data.CalculatePrice(sortid, attrid, qualid ?? GetQualId(kmw), geb, oe, kmw);
|
var v = data.CalculatePrice(sortid, attrid, qualid ?? GetQualId(kmw), geb, oe, kmw);
|
||||||
@@ -42,7 +42,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_01_Flatrate() {
|
public void Test_01_Flatrate() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -58,7 +58,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_02_Simple() {
|
public void Test_02_Simple() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -93,7 +93,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_03_GreaterThanAndLessThan() {
|
public void Test_03_GreaterThanAndLessThan() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -132,7 +132,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_04_VariantsAndAttributes() {
|
public void Test_04_VariantsAndAttributes() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -162,7 +162,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_05_QualityLevel() {
|
public void Test_05_QualityLevel() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -193,7 +193,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_06_ModeOeAndKmw() {
|
public void Test_06_ModeOeAndKmw() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -235,7 +235,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_07_MultipleCurves() {
|
public void Test_07_MultipleCurves() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "elwig",
|
"mode": "elwig",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
@@ -304,7 +304,7 @@ namespace Tests.Helpers {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Test_08_WgMaster() {
|
public void Test_08_WgMaster() {
|
||||||
var data = BillingData.FromJson("""
|
var data = PaymentBillingData.FromJson("""
|
||||||
{
|
{
|
||||||
"mode": "wgmaster",
|
"mode": "wgmaster",
|
||||||
"Grundbetrag": 0.033,
|
"Grundbetrag": 0.033,
|
||||||
|
@@ -18,11 +18,17 @@
|
|||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
<PackageReference Include="NUnit" Version="4.0.1" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||||
<PackageReference Include="NUnit.Analyzers" Version="3.5.0" />
|
<PackageReference Include="NUnit.Analyzers" Version="3.10.0">
|
||||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Reference in New Issue
Block a user