ChartWindow/Billing: Misc improvements
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Elwig.Models.Entities;
|
||||||
|
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;
|
||||||
@ -17,7 +18,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return new(ParseJson(json), attributeVariants);
|
return new(ParseJson(json), attributeVariants);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<GraphEntry> GetPaymentGraphEntries(AppDbContext context) {
|
public IEnumerable<GraphEntry> GetPaymentGraphEntries(AppDbContext context, Season season) {
|
||||||
Dictionary<int, List<string>> dict1 = [];
|
Dictionary<int, List<string>> dict1 = [];
|
||||||
Dictionary<decimal, List<string>> dict2 = [];
|
Dictionary<decimal, List<string>> dict2 = [];
|
||||||
var p = GetPaymentEntry();
|
var p = GetPaymentEntry();
|
||||||
@ -66,13 +67,13 @@ namespace Elwig.Helpers.Billing {
|
|||||||
var attrs = context.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
var attrs = context.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
||||||
|
|
||||||
return dict3
|
return dict3
|
||||||
.Select(e => new GraphEntry(e.Key, curves[e.Key], e.Value
|
.Select(e => new GraphEntry(e.Key, season, curves[e.Key], e.Value
|
||||||
.Select(s => new ContractSelection(vars[s[..2]], s.Length > 2 ? attrs[s[2..]] : null))
|
.Select(s => new ContractSelection(vars[s[..2]], s.Length > 2 ? attrs[s[2..]] : null))
|
||||||
.ToList(), 50, 140))
|
.ToList(), 50, 73, 140))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<GraphEntry> GetQualityGraphEntries(AppDbContext context) {
|
public IEnumerable<GraphEntry> GetQualityGraphEntries(AppDbContext context, Season season) {
|
||||||
Dictionary<int, List<string>> dict1 = [];
|
Dictionary<int, List<string>> dict1 = [];
|
||||||
Dictionary<decimal, List<string>> dict2 = [];
|
Dictionary<decimal, List<string>> dict2 = [];
|
||||||
foreach (var (qualid, q) in GetQualityEntry() ?? []) {
|
foreach (var (qualid, q) in GetQualityEntry() ?? []) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using Elwig.Models.Entities;
|
||||||
using ScottPlot;
|
using ScottPlot;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -7,20 +8,32 @@ using System.Text.Json.Nodes;
|
|||||||
namespace Elwig.Helpers.Billing {
|
namespace Elwig.Helpers.Billing {
|
||||||
public class Graph : ICloneable {
|
public class Graph : ICloneable {
|
||||||
|
|
||||||
|
private readonly Season Season;
|
||||||
public double[] DataX { get; set; }
|
public double[] DataX { get; set; }
|
||||||
public double[] DataY { get; set; }
|
public double[] DataY { get; set; }
|
||||||
|
public int MinX { get; set; }
|
||||||
|
public int MaxX { get; set; }
|
||||||
|
|
||||||
public Graph(int minX, int maxX) {
|
public Graph(Season season, int minX, int maxX) {
|
||||||
|
Season = season;
|
||||||
|
MinX = minX;
|
||||||
|
MaxX = maxX;
|
||||||
DataX = DataGen.Range(minX, maxX + 1);
|
DataX = DataGen.Range(minX, maxX + 1);
|
||||||
DataY = DataGen.Zeros(maxX - minX + 1);
|
DataY = DataGen.Zeros(maxX - minX + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graph(Dictionary<double, decimal> data, int minX, int maxX) {
|
public Graph(Dictionary<double, decimal> data, Season season, int minX, int maxX) {
|
||||||
|
Season = season;
|
||||||
|
MinX = minX;
|
||||||
|
MaxX = maxX;
|
||||||
DataX = DataGen.Range(minX, maxX + 1);
|
DataX = DataGen.Range(minX, maxX + 1);
|
||||||
DataY = DataX.Select(i => (double)BillingData.GetCurveValueAt(data, i)).ToArray();
|
DataY = DataX.Select(i => (double)BillingData.GetCurveValueAt(data, i)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Graph(double[] dataX, double[] dataY) {
|
private Graph(double[] dataX, double[] dataY, Season season, int minX, int maxX) {
|
||||||
|
Season = season;
|
||||||
|
MinX = minX;
|
||||||
|
MaxX = maxX;
|
||||||
DataX = dataX;
|
DataX = dataX;
|
||||||
DataY = dataY;
|
DataY = dataY;
|
||||||
}
|
}
|
||||||
@ -57,7 +70,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
private void LinearIncreaseGraph(int begin, int end, double inc) {
|
private void LinearIncreaseGraph(int begin, int end, double inc) {
|
||||||
for (int i = begin; i < end; i++) {
|
for (int i = begin; i < end; i++) {
|
||||||
DataY[i + 1] = Math.Round(DataY[i] + inc, 4); //TODO richtig runden
|
DataY[i + 1] = Math.Round(DataY[i] + inc, Season.Precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +87,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
double step = (DataY[highIndex] - DataY[lowIndex]) / steps;
|
double step = (DataY[highIndex] - DataY[lowIndex]) / steps;
|
||||||
|
|
||||||
for (int i = lowIndex; i < highIndex - 1; i++) {
|
for (int i = lowIndex; i < highIndex - 1; i++) {
|
||||||
DataY[i + 1] = Math.Round(DataY[i] + step, 4); // TODO richtig runden
|
DataY[i + 1] = Math.Round(DataY[i] + step, Season.Precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,21 +99,21 @@ namespace Elwig.Helpers.Billing {
|
|||||||
var data = new JsonObject();
|
var data = new JsonObject();
|
||||||
|
|
||||||
if (DataY[0] != DataY[1]) {
|
if (DataY[0] != DataY[1]) {
|
||||||
data.Add(new KeyValuePair<string, JsonNode?>(DataX[0] + mode, Math.Round(DataY[0], 4)));
|
data.Add(new KeyValuePair<string, JsonNode?>(DataX[0] + mode, Math.Round(DataY[0], Season.Precision)));
|
||||||
}
|
}
|
||||||
for (int i = 1; i < DataX.Length - 1; i++) {
|
for (int i = 1; i < DataX.Length - 1; i++) {
|
||||||
if (Math.Round(DataY[i] - DataY[i - 1], 10) != Math.Round(DataY[i + 1] - DataY[i], 10)) {
|
if (Math.Round(DataY[i] - DataY[i - 1], 10) != Math.Round(DataY[i + 1] - DataY[i], 10)) {
|
||||||
data.Add(new KeyValuePair<string, JsonNode?>(DataX[i] + mode, Math.Round(DataY[i], 4)));
|
data.Add(new KeyValuePair<string, JsonNode?>(DataX[i] + mode, Math.Round(DataY[i], Season.Precision)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DataY[^1] != DataY[^2]) {
|
if (DataY[^1] != DataY[^2]) {
|
||||||
data.Add(new KeyValuePair<string, JsonNode?>(DataX[^1] + mode, Math.Round(DataY[^1], 4)));
|
data.Add(new KeyValuePair<string, JsonNode?>(DataX[^1] + mode, Math.Round(DataY[^1], Season.Precision)));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Clone() {
|
public object Clone() {
|
||||||
return new Graph((double[])DataX.Clone(), (double[])DataY.Clone());
|
return new Graph((double[])DataX.Clone(), (double[])DataY.Clone(), Season, MinX, MaxX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using Elwig.Models.Entities;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json.Nodes;
|
using System.Text.Json.Nodes;
|
||||||
|
|
||||||
@ -6,7 +7,9 @@ namespace Elwig.Helpers.Billing {
|
|||||||
public class GraphEntry {
|
public class GraphEntry {
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
private readonly Season Season;
|
||||||
public BillingData.CurveMode Mode { get; set; }
|
public BillingData.CurveMode Mode { get; set; }
|
||||||
|
public bool Abgewertet { get; set; }
|
||||||
public Graph DataGraph { get; set; }
|
public Graph DataGraph { get; set; }
|
||||||
public Graph? GebundenGraph { get; set; }
|
public Graph? GebundenGraph { get; set; }
|
||||||
public decimal? GebundenFlatBonus { get; set; }
|
public decimal? GebundenFlatBonus { get; set; }
|
||||||
@ -14,36 +17,42 @@ namespace Elwig.Helpers.Billing {
|
|||||||
public string ContractsStringSimple => Contracts.Any() ? string.Join(", ", Contracts.Select(c => c.Listing)) : "-";
|
public string ContractsStringSimple => Contracts.Any() ? string.Join(", ", Contracts.Select(c => c.Listing)) : "-";
|
||||||
public string ContractsString => Contracts.Any() ? string.Join("\n", Contracts.Select(c => c.FullName)) : "-";
|
public string ContractsString => Contracts.Any() ? string.Join("\n", Contracts.Select(c => c.FullName)) : "-";
|
||||||
private int MinX { get; set; }
|
private int MinX { get; set; }
|
||||||
|
private int MinXGebunden { get; set; }
|
||||||
private int MaxX { get; set; }
|
private int MaxX { get; set; }
|
||||||
|
|
||||||
public GraphEntry(int id, BillingData.CurveMode mode, int minX, int maxX) {
|
public GraphEntry(int id, Season season, BillingData.CurveMode mode, int minX, int minXGebunden, int maxX) {
|
||||||
Id = id;
|
Id = id;
|
||||||
|
Season = season;
|
||||||
Mode = mode;
|
Mode = mode;
|
||||||
|
Abgewertet = false;
|
||||||
MinX = minX;
|
MinX = minX;
|
||||||
|
MinXGebunden = minXGebunden;
|
||||||
MaxX = maxX;
|
MaxX = maxX;
|
||||||
DataGraph = new Graph(minX, maxX);
|
DataGraph = new Graph(season, minX, maxX);
|
||||||
Contracts = [];
|
Contracts = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphEntry(int id, BillingData.CurveMode mode, Dictionary<double, decimal> data, Dictionary<double, decimal>? gebunden,
|
public GraphEntry(int id, Season season, BillingData.CurveMode mode, Dictionary<double, decimal> data, Dictionary<double, decimal>? gebunden,
|
||||||
int minX, int maxX) : this(id, mode, minX, maxX) {
|
int minX, int minXGebunden, int maxX) : this(id, season, mode, minX, minXGebunden, maxX) {
|
||||||
DataGraph = new Graph(data, minX, maxX);
|
DataGraph = new Graph(data, season, minX, maxX);
|
||||||
if (gebunden != null) GebundenGraph = new Graph(gebunden, minX, maxX);
|
if (gebunden != null) GebundenGraph = new Graph(gebunden, season, minXGebunden, maxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphEntry(int id, BillingData.Curve curve, List<ContractSelection> contracts, int minX, int maxX) :
|
public GraphEntry(int id, Season season, BillingData.Curve curve, List<ContractSelection> contracts, int minX, int minXGebunden, int maxX) :
|
||||||
this(id, curve.Mode, minX, maxX) {
|
this(id, season, curve.Mode, minX, minXGebunden, maxX) {
|
||||||
DataGraph = new Graph(curve.Normal, minX, maxX);
|
DataGraph = new Graph(curve.Normal, season, minX, maxX);
|
||||||
if (curve.Gebunden != null)
|
if (curve.Gebunden != null)
|
||||||
GebundenGraph = new Graph(curve.Gebunden, 73, maxX);
|
GebundenGraph = new Graph(curve.Gebunden, season, minXGebunden, maxX);
|
||||||
Contracts = contracts;
|
Contracts = contracts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GraphEntry(int id, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
|
private GraphEntry(int id, Season season, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph,
|
||||||
decimal? gebundenFlatPrice, List<ContractSelection> contracts, int minX, int maxX) {
|
decimal? gebundenFlatPrice, List<ContractSelection> contracts, int minX, int minXGebunden, int maxX) {
|
||||||
Id = id;
|
Id = id;
|
||||||
|
Season = season;
|
||||||
Mode = mode;
|
Mode = mode;
|
||||||
MinX = minX;
|
MinX = minX;
|
||||||
|
MinXGebunden = minXGebunden;
|
||||||
MaxX = maxX;
|
MaxX = maxX;
|
||||||
DataGraph = dataGraph;
|
DataGraph = dataGraph;
|
||||||
GebundenGraph = gebundenGraph;
|
GebundenGraph = gebundenGraph;
|
||||||
@ -52,7 +61,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AddGebundenGraph() {
|
public void AddGebundenGraph() {
|
||||||
GebundenGraph ??= new Graph(MinX, MaxX);
|
GebundenGraph ??= new Graph(Season, MinXGebunden, MaxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveGebundenGraph() {
|
public void RemoveGebundenGraph() {
|
||||||
@ -81,7 +90,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GraphEntry Copy(int id) {
|
public GraphEntry Copy(int id) {
|
||||||
return new GraphEntry(id, Mode, (Graph)DataGraph.Clone(), (Graph?)GebundenGraph?.Clone(), GebundenFlatBonus, [], MinX, MaxX);
|
return new GraphEntry(id, Season, Mode, (Graph)DataGraph.Clone(), (Graph?)GebundenGraph?.Clone(), GebundenFlatBonus, [], MinX, MinXGebunden, MaxX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,19 +53,16 @@
|
|||||||
<ColumnDefinition Width="200"/>
|
<ColumnDefinition Width="200"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3">
|
<Grid Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="150"/>
|
<ColumnDefinition Width="560"/>
|
||||||
<ColumnDefinition Width="500"/>
|
<ColumnDefinition Width="100"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="Graph:" Margin="10,0,0,0" FontSize="14" Grid.Column="0" VerticalAlignment="Center"/>
|
<Label Content="Für:" Margin="10,0,0,0" FontSize="14" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<TextBlock x:Name="GraphNum" Margin="55,0,0,0" FontSize="14" Width="50" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
<xctk:CheckComboBox x:Name="ContractInput" Margin="50,0,0,0" Grid.Column="0"
|
||||||
|
|
||||||
<Label Content="Für:" Margin="10,0,0,0" FontSize="14" Grid.Column="1" VerticalAlignment="Center"/>
|
|
||||||
<xctk:CheckComboBox x:Name="ContractInput" Margin="0,10,-42,5" Grid.Column="1"
|
|
||||||
Delimiter=", " AllItemsSelectedContent="Alle" IsEnabled="False" ItemSelectionChanged="ContractInput_Changed"
|
Delimiter=", " AllItemsSelectedContent="Alle" IsEnabled="False" ItemSelectionChanged="ContractInput_Changed"
|
||||||
Width="500" Height="25" HorizontalAlignment="Right">
|
Width="500" Height="25" HorizontalAlignment="Left">
|
||||||
<xctk:CheckComboBox.ItemTemplate>
|
<xctk:CheckComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@ -75,9 +72,12 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</xctk:CheckComboBox.ItemTemplate>
|
</xctk:CheckComboBox.ItemTemplate>
|
||||||
</xctk:CheckComboBox>
|
</xctk:CheckComboBox>
|
||||||
|
|
||||||
|
<CheckBox x:Name="AbgewertetInput" Content="Abgewertet" IsEnabled="False" Checked="AbgewertetInput_Changed"
|
||||||
|
VerticalAlignment="Center" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Column="1"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<ListBox x:Name="GraphList" Margin="10,10,35,50" Grid.Column="0" Grid.Row="1" SelectionChanged="GraphList_SelectionChanged">
|
<ListBox x:Name="GraphList" Margin="10,10,35,50" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" SelectionChanged="GraphList_SelectionChanged">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
@ -93,13 +93,13 @@
|
|||||||
Click="SaveButton_Click"/>
|
Click="SaveButton_Click"/>
|
||||||
|
|
||||||
<Button x:Name="AddButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" ToolTip="Neue Auszahlungsvariante hinzufügen"
|
<Button x:Name="AddButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" ToolTip="Neue Auszahlungsvariante hinzufügen"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,60" Grid.Column="0" Grid.Row="1"
|
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,0,5,60" Grid.Column="0" Grid.RowSpan="2" Grid.Row="0"
|
||||||
Click="AddButton_Click"/>
|
Click="AddButton_Click"/>
|
||||||
<Button x:Name="CopyButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="12" Padding="0,0,0,0" IsEnabled="False" ToolTip="Ausgewählte Auszahlungsvariante duplizieren"
|
<Button x:Name="CopyButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="12" Padding="0,0,0,0" IsEnabled="False" ToolTip="Ausgewählte Auszahlungsvariante duplizieren"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="0,0,5,0" Grid.Column="0" Grid.Row="1"
|
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="0,0,5,0" Grid.Column="0" Grid.RowSpan="2" Grid.Row="0"
|
||||||
Click="CopyButton_Click"/>
|
Click="CopyButton_Click"/>
|
||||||
<Button x:Name="DeleteButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False" ToolTip="Ausgewählte Auszahlungsvariante löschen"
|
<Button x:Name="DeleteButton" Content="" FontFamily="Segoe MDL2 Assets" FontSize="11" Padding="0,1.5,0,0" IsEnabled="False" ToolTip="Ausgewählte Auszahlungsvariante löschen"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.Column="0" Grid.Row="1"
|
VerticalAlignment="Center" HorizontalAlignment="Right" Width="25" Height="25" Margin="5,60,5,0" Grid.Column="0" Grid.RowSpan="2" Grid.Row="0"
|
||||||
Click="DeleteButton_Click"/>
|
Click="DeleteButton_Click"/>
|
||||||
|
|
||||||
<Grid Grid.Row="1" Grid.Column="1">
|
<Grid Grid.Row="1" Grid.Column="1">
|
||||||
|
@ -15,6 +15,7 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||||
using ScottPlot;
|
using ScottPlot;
|
||||||
using ScottPlot.Plottable;
|
using ScottPlot.Plottable;
|
||||||
|
using Xceed.Wpf.Toolkit.Primitives;
|
||||||
|
|
||||||
namespace Elwig.Windows {
|
namespace Elwig.Windows {
|
||||||
public partial class ChartWindow : ContextWindow {
|
public partial class ChartWindow : ContextWindow {
|
||||||
@ -24,6 +25,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
public readonly int Year;
|
public readonly int Year;
|
||||||
public readonly int AvNr;
|
public readonly int AvNr;
|
||||||
|
public readonly Season Season;
|
||||||
private readonly PaymentVar PaymentVar;
|
private readonly PaymentVar PaymentVar;
|
||||||
|
|
||||||
private ScatterPlot DataPlot;
|
private ScatterPlot DataPlot;
|
||||||
@ -43,6 +45,7 @@ namespace Elwig.Windows {
|
|||||||
private bool FillingInputs = false;
|
private bool FillingInputs = false;
|
||||||
|
|
||||||
private const int MinOechsle = 50;
|
private const int MinOechsle = 50;
|
||||||
|
private const int MinOechsleGebunden = 73;
|
||||||
private const int MaxOechsle = 140;
|
private const int MaxOechsle = 140;
|
||||||
|
|
||||||
private List<GraphEntry> GraphEntries = [];
|
private List<GraphEntry> GraphEntries = [];
|
||||||
@ -52,6 +55,7 @@ namespace Elwig.Windows {
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Year = year;
|
Year = year;
|
||||||
AvNr = avnr;
|
AvNr = avnr;
|
||||||
|
Season = Context.Seasons.Find(year) ?? throw new ArgumentException("Season not found");
|
||||||
PaymentVar = Context.PaymentVariants.Find(year, avnr) ?? throw new ArgumentException("PaymentVar not found");
|
PaymentVar = Context.PaymentVariants.Find(year, avnr) ?? throw new ArgumentException("PaymentVar not found");
|
||||||
Title = $"{PaymentVar?.Name} - Lese {year} - Elwig";
|
Title = $"{PaymentVar?.Name} - Lese {year} - Elwig";
|
||||||
}
|
}
|
||||||
@ -72,7 +76,7 @@ namespace Elwig.Windows {
|
|||||||
.Order()
|
.Order()
|
||||||
.ToList();
|
.ToList();
|
||||||
var data = EditBillingData.FromJson(PaymentVar.Data, attrVariants);
|
var data = EditBillingData.FromJson(PaymentVar.Data, attrVariants);
|
||||||
GraphEntries = [ ..data.GetPaymentGraphEntries(Context), ..data.GetQualityGraphEntries(Context)];
|
GraphEntries = [ ..data.GetPaymentGraphEntries(Context, Season), ..data.GetQualityGraphEntries(Context, Season)];
|
||||||
|
|
||||||
var contracts = ContractSelection.GetContractsForYear(Context, Year);
|
var contracts = ContractSelection.GetContractsForYear(Context, Year);
|
||||||
ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.Listing);
|
ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.Listing);
|
||||||
@ -91,6 +95,7 @@ namespace Elwig.Windows {
|
|||||||
GebundenTypeGraph.IsEnabled = true;
|
GebundenTypeGraph.IsEnabled = true;
|
||||||
GebundenTypeNone.IsEnabled = true;
|
GebundenTypeNone.IsEnabled = true;
|
||||||
ContractInput.IsEnabled = true;
|
ContractInput.IsEnabled = true;
|
||||||
|
AbgewertetInput.IsEnabled = true;
|
||||||
EnableOptionButtons();
|
EnableOptionButtons();
|
||||||
FillInputs();
|
FillInputs();
|
||||||
} else {
|
} else {
|
||||||
@ -109,13 +114,13 @@ namespace Elwig.Windows {
|
|||||||
GebundenTypeGraph.IsEnabled = false;
|
GebundenTypeGraph.IsEnabled = false;
|
||||||
GebundenTypeNone.IsEnabled = false;
|
GebundenTypeNone.IsEnabled = false;
|
||||||
ContractInput.IsEnabled = false;
|
ContractInput.IsEnabled = false;
|
||||||
|
AbgewertetInput.IsEnabled = false;
|
||||||
}
|
}
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FillInputs() {
|
private void FillInputs() {
|
||||||
FillingInputs = true;
|
FillingInputs = true;
|
||||||
GraphNum.Text = SelectedGraphEntry?.Id.ToString();
|
|
||||||
|
|
||||||
if (SelectedGraphEntry?.GebundenFlatBonus != null) {
|
if (SelectedGraphEntry?.GebundenFlatBonus != null) {
|
||||||
GebundenTypeFixed.IsChecked = true;
|
GebundenTypeFixed.IsChecked = true;
|
||||||
@ -138,13 +143,13 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void InitPlot() {
|
private void InitPlot() {
|
||||||
if (SelectedGraphEntry?.GebundenGraph != null) {
|
if (SelectedGraphEntry?.GebundenGraph != null) {
|
||||||
GebundenPlot = OechslePricePlot.Plot.AddScatter(SelectedGraphEntry.GebundenGraph.DataX, SelectedGraphEntry.GebundenGraph.DataY);
|
GebundenPlot = OechslePricePlot.Plot.AddScatter(SelectedGraphEntry.GebundenGraph.DataX, SelectedGraphEntry.GebundenGraph.DataY, label: "Gebunden");
|
||||||
GebundenPlot.LineColor = ColorGebunden;
|
GebundenPlot.LineColor = ColorGebunden;
|
||||||
GebundenPlot.MarkerColor = ColorGebunden;
|
GebundenPlot.MarkerColor = ColorGebunden;
|
||||||
GebundenPlot.MarkerSize = 9;
|
GebundenPlot.MarkerSize = 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataPlot = OechslePricePlot.Plot.AddScatter(SelectedGraphEntry!.DataGraph.DataX, SelectedGraphEntry!.DataGraph.DataY);
|
DataPlot = OechslePricePlot.Plot.AddScatter(SelectedGraphEntry!.DataGraph.DataX, SelectedGraphEntry!.DataGraph.DataY, label: "Ungebunden");
|
||||||
DataPlot.LineColor = ColorUngebunden;
|
DataPlot.LineColor = ColorUngebunden;
|
||||||
DataPlot.MarkerColor = ColorUngebunden;
|
DataPlot.MarkerColor = ColorUngebunden;
|
||||||
DataPlot.MarkerSize = 9;
|
DataPlot.MarkerSize = 9;
|
||||||
@ -157,7 +162,7 @@ namespace Elwig.Windows {
|
|||||||
OechslePricePlot.Configuration.DoubleClickBenchmark = false;
|
OechslePricePlot.Configuration.DoubleClickBenchmark = false;
|
||||||
//OechslePricePlot.Plot.XAxis.ManualTickSpacing(1);
|
//OechslePricePlot.Plot.XAxis.ManualTickSpacing(1);
|
||||||
OechslePricePlot.Plot.YAxis.ManualTickSpacing(0.1);
|
OechslePricePlot.Plot.YAxis.ManualTickSpacing(0.1);
|
||||||
OechslePricePlot.Plot.SetAxisLimits(MinOechsle - 1, MaxOechsle + 1, -0.1, 2);
|
OechslePricePlot.Plot.SetAxisLimits(Math.Min(MinOechsle, MinOechsleGebunden) - 1, MaxOechsle + 1, -0.1, 2);
|
||||||
|
|
||||||
OechslePricePlot.Plot.Layout(padding: 0);
|
OechslePricePlot.Plot.Layout(padding: 0);
|
||||||
OechslePricePlot.Plot.XAxis2.Layout(padding: 0);
|
OechslePricePlot.Plot.XAxis2.Layout(padding: 0);
|
||||||
@ -291,15 +296,15 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ShowLegend() {
|
private void ShowLegend() {
|
||||||
OechslePricePlot.Plot.Legend(true, Alignment.UpperRight);
|
OechslePricePlot.Plot.Legend(true, Alignment.UpperLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HideLegend() {
|
private void HideLegend() {
|
||||||
OechslePricePlot.Plot.Legend(false, Alignment.UpperRight);
|
OechslePricePlot.Plot.Legend(false, Alignment.UpperLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OechsleInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
private void OechsleInput_TextChanged(object sender, TextChangedEventArgs evt) {
|
||||||
if (ActiveGraph == null) {
|
if (ActiveGraph == null || SelectedGraphEntry == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,9 +313,9 @@ namespace Elwig.Windows {
|
|||||||
SecondaryMarkedPoint = -1;
|
SecondaryMarkedPoint = -1;
|
||||||
ChangeMarker(SecondaryMarkedPointPlot, false);
|
ChangeMarker(SecondaryMarkedPointPlot, false);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
if (oechsle >= MinOechsle && oechsle <= MaxOechsle) {
|
if (oechsle >= ActiveGraph.MinX && oechsle <= ActiveGraph.MaxX) {
|
||||||
PrimaryMarkedPoint = oechsle - MinOechsle;
|
PrimaryMarkedPoint = oechsle - ActiveGraph.MinX;
|
||||||
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
||||||
|
|
||||||
PriceInput.Text = ActiveGraph.GetPriceAt(PrimaryMarkedPoint).ToString();
|
PriceInput.Text = ActiveGraph.GetPriceAt(PrimaryMarkedPoint).ToString();
|
||||||
@ -479,7 +484,7 @@ namespace Elwig.Windows {
|
|||||||
if (LastHighlighted != Highlighted || HoverChanged) {
|
if (LastHighlighted != Highlighted || HoverChanged) {
|
||||||
OechslePricePlot.Plot.Remove(TooltipPlot);
|
OechslePricePlot.Plot.Remove(TooltipPlot);
|
||||||
if (TooltipInput.IsChecked == true) {
|
if (TooltipInput.IsChecked == true) {
|
||||||
TooltipPlot = OechslePricePlot.Plot.AddTooltip($"Oechsle: {pointX:N2}, Preis: {Math.Round(pointY, 4)}€/kg)", pointX, pointY);
|
TooltipPlot = OechslePricePlot.Plot.AddTooltip($"Oechsle: {pointX:N2}, Preis: {Math.Round(pointY, Season.Precision)}€/kg)", pointX, pointY);
|
||||||
}
|
}
|
||||||
LastHighlighted = (g, pointIndex);
|
LastHighlighted = (g, pointIndex);
|
||||||
HoverChanged = false;
|
HoverChanged = false;
|
||||||
@ -492,7 +497,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void AddButton_Click(object sender, RoutedEventArgs e) {
|
private void AddButton_Click(object sender, RoutedEventArgs e) {
|
||||||
GraphEntry newGraphEntry = new(GetMaxGraphId() + 1, BillingData.CurveMode.Oe, MinOechsle, MaxOechsle);
|
GraphEntry newGraphEntry = new(GetMaxGraphId() + 1, Season, BillingData.CurveMode.Oe, MinOechsle, MinOechsleGebunden, MaxOechsle);
|
||||||
GraphEntries.Add(newGraphEntry);
|
GraphEntries.Add(newGraphEntry);
|
||||||
GraphList.Items.Refresh();
|
GraphList.Items.Refresh();
|
||||||
GraphList.SelectedItem = newGraphEntry;
|
GraphList.SelectedItem = newGraphEntry;
|
||||||
@ -545,6 +550,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
MessageBox.Show(data.ToJsonString());
|
MessageBox.Show(data.ToJsonString());
|
||||||
|
|
||||||
|
/*
|
||||||
EntityEntry<PaymentVar>? tr = null;
|
EntityEntry<PaymentVar>? tr = null;
|
||||||
try {
|
try {
|
||||||
PaymentVar.Data = data.ToJsonString();
|
PaymentVar.Data = data.ToJsonString();
|
||||||
@ -552,12 +558,14 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
await App.HintContextChange();
|
await App.HintContextChange();
|
||||||
|
await RefreshGraphList();
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
if (tr != null) await tr.ReloadAsync();
|
if (tr != null) await tr.ReloadAsync();
|
||||||
var str = "Der Eintrag konnte nicht in der Datenbank gespeichert werden!\n\n" + exc.Message;
|
var str = "Der Eintrag konnte nicht in der Datenbank gespeichert werden!\n\n" + exc.Message;
|
||||||
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) str += "\n\n" + exc.InnerException.Message;
|
||||||
MessageBox.Show(str, "Graph speichern", MessageBoxButton.OK, MessageBoxImage.Error);
|
MessageBox.Show(str, "Graph speichern", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnableUnitTextBox(UnitTextBox u) {
|
private void EnableUnitTextBox(UnitTextBox u) {
|
||||||
@ -618,13 +626,30 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContractInput_Changed(object sender, RoutedEventArgs e) {
|
private void ContractInput_Changed(object sender, ItemSelectionChangedEventArgs e) {
|
||||||
if (FillingInputs) return;
|
if (FillingInputs) return;
|
||||||
|
if (e.IsSelected == true) {
|
||||||
|
RemoveContractFromOtherGraphEntries(e.Item.ToString());
|
||||||
|
}
|
||||||
var r = ContractInput.SelectedItems.Cast<ContractSelection>();
|
var r = ContractInput.SelectedItems.Cast<ContractSelection>();
|
||||||
SelectedGraphEntry!.Contracts = r.ToList();
|
SelectedGraphEntry!.Contracts = r.ToList();
|
||||||
GraphList.Items.Refresh();
|
GraphList.Items.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RemoveContractFromOtherGraphEntries(string? contract) {
|
||||||
|
if (contract == null) return;
|
||||||
|
foreach (var ge in GraphEntries) {
|
||||||
|
if (ge != SelectedGraphEntry) {
|
||||||
|
ge.Contracts.RemoveAll(c => c.Listing.Equals(contract));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AbgewertetInput_Changed(object sender, RoutedEventArgs e) {
|
||||||
|
if (SelectedGraphEntry == null) return;
|
||||||
|
SelectedGraphEntry.Abgewertet = AbgewertetInput.IsChecked == true;
|
||||||
|
}
|
||||||
|
|
||||||
private void GebundenType_Checked(object sender, RoutedEventArgs e) {
|
private void GebundenType_Checked(object sender, RoutedEventArgs e) {
|
||||||
if (FillingInputs) return;
|
if (FillingInputs) return;
|
||||||
if (SelectedGraphEntry == null) {
|
if (SelectedGraphEntry == null) {
|
||||||
|
Reference in New Issue
Block a user