Billing: Add EditBillingData class
This commit is contained in:
@ -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();
|
||||
|
Reference in New Issue
Block a user