Billing: Add EditBillingData class

This commit is contained in:
2024-01-18 21:30:42 +01:00
parent 403e7723d2
commit cb541cb6e6
5 changed files with 112 additions and 36 deletions

View File

@ -59,24 +59,7 @@ namespace Elwig.Windows {
await RefreshGraphListQuery();
}
private static JsonObject? ParseData(PaymentVar variant) {
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 = PaymentBillingData.GetCurves(data, BillingData.CalculationMode.Elwig);
foreach (var (id, curve) in curves) {
GraphEntries.Add(new GraphEntry(id, curve.Mode, curve.Normal, MinOechsle, MaxOechsle));
}
private async Task RefreshGraphListQuery() {
var attrVariants = Context.DeliveryParts
.Where(d => d.Year == Year)
.Select(d => $"{d.SortId}{d.AttrId}")
@ -85,12 +68,12 @@ namespace Elwig.Windows {
.Union(Context.WineVarieties.Select(v => v.SortId))
.Order()
.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);
if (GraphEntries.Count == 1) {
GraphList.SelectedIndex = 0;
}
ControlUtils.RenewItemsSource(AppliedInput, attrVariants, g => g);
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.Id, null, ControlUtils.RenewSourceDefault.IfOnly);
RefreshInputs();
}
@ -98,7 +81,6 @@ namespace Elwig.Windows {
private string ParseContracts(JsonObject auszahlungsSorten, int num) {
return "";
}
private void RefreshInputs(bool validate = false) {
ResetPlot();