Compare commits
10 Commits
v0.6.1
..
255953a658
| Author | SHA1 | Date | |
|---|---|---|---|
| 255953a658 | |||
| 9470b26aec | |||
| 3a2bf81bd9 | |||
| d3aca196dd | |||
| 519e903d1c | |||
| dd568b81e8 | |||
| 31b0ae245d | |||
| 46498ce337 | |||
| 0fff698a5d | |||
| a71c6685f0 |
@@ -55,13 +55,13 @@ namespace Elwig.Documents {
|
|||||||
CurrencySymbol = season.Currency.Symbol ?? season.Currency.Code;
|
CurrencySymbol = season.Currency.Symbol ?? season.Currency.Code;
|
||||||
Precision = season.Precision;
|
Precision = season.Precision;
|
||||||
|
|
||||||
var variants = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
|
var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
|
||||||
var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
||||||
var comTypes = ctx.AreaCommitmentTypes.ToDictionary(t => t.VtrgId, t => t);
|
var comTypes = ctx.AreaCommitmentTypes.ToDictionary(t => t.VtrgId, t => t);
|
||||||
MemberUnderDeliveries = underDeliveries?
|
MemberUnderDeliveries = underDeliveries?
|
||||||
.OrderBy(u => u.Key)
|
.OrderBy(u => u.Key)
|
||||||
.Select(u => (
|
.Select(u => (
|
||||||
variants[u.Key[..2]].Name + (u.Key.Length > 2 ? " " + attributes[u.Key[2..]].Name : ""),
|
varieties[u.Key[..2]].Name + (u.Key.Length > 2 ? " " + attributes[u.Key[2..]].Name : ""),
|
||||||
u.Value.Diff,
|
u.Value.Diff,
|
||||||
u.Value.Diff * (comTypes[u.Key].PenaltyPerKg ?? 0)
|
u.Value.Diff * (comTypes[u.Key].PenaltyPerKg ?? 0)
|
||||||
- (comTypes[u.Key].PenaltyAmount ?? 0)
|
- (comTypes[u.Key].PenaltyAmount ?? 0)
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
@if (i == 0) {
|
@if (i == 0) {
|
||||||
<td rowspan="@rows">@p.LsNr</td>
|
<td rowspan="@rows">@p.LsNr</td>
|
||||||
<td rowspan="@rows">@p.DPNr</td>
|
<td rowspan="@rows">@p.DPNr</td>
|
||||||
<td class="small">@p.Variant</td>
|
<td class="small">@p.Variety</td>
|
||||||
<td class="small">@p.Attribute</td>
|
<td class="small">@p.Attribute</td>
|
||||||
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
|
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
|
||||||
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>
|
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>
|
||||||
|
|||||||
@@ -42,17 +42,17 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@{
|
@{
|
||||||
var lastVariant = "";
|
var lastVariety = "";
|
||||||
}
|
}
|
||||||
@foreach (var p in Model.Data.Rows) {
|
@foreach (var p in Model.Data.Rows) {
|
||||||
var rows = Math.Max(p.Buckets.Length, p.Modifiers.Length + 1);
|
var rows = Math.Max(p.Buckets.Length, p.Modifiers.Length + 1);
|
||||||
var first = true;
|
var first = true;
|
||||||
@for (int i = 0; i < rows; i++) {
|
@for (int i = 0; i < rows; i++) {
|
||||||
<tr class="@(first ? "first" : "") @(p.Variant != lastVariant && lastVariant != "" ? "new": "") @(rows > i + 1 ? "last" : "")">
|
<tr class="@(first ? "first" : "") @(p.Variety != lastVariety && lastVariety != "" ? "new": "") @(rows > i + 1 ? "last" : "")">
|
||||||
@if (first) {
|
@if (first) {
|
||||||
<td rowspan="@rows">@p.LsNr</td>
|
<td rowspan="@rows">@p.LsNr</td>
|
||||||
<td rowspan="@rows">@p.DPNr</td>
|
<td rowspan="@rows">@p.DPNr</td>
|
||||||
<td class="small">@p.Variant</td>
|
<td class="small">@p.Variety</td>
|
||||||
<td class="small">@p.Attribute</td>
|
<td class="small">@p.Attribute</td>
|
||||||
<td class="small">@p.QualityLevel</td>
|
<td class="small">@p.QualityLevel</td>
|
||||||
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
|
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
lastVariant = p.Variant;
|
lastVariety = p.Variety;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<tr class="sum bold">
|
<tr class="sum bold">
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Elwig.Documents {
|
|||||||
public DeliveryJournal(string filter, IQueryable<DeliveryPart> deliveries) :
|
public DeliveryJournal(string filter, IQueryable<DeliveryPart> deliveries) :
|
||||||
this(filter, deliveries
|
this(filter, deliveries
|
||||||
.Include(p => p.Delivery).ThenInclude(d => d.Member)
|
.Include(p => p.Delivery).ThenInclude(d => d.Member)
|
||||||
.Include(p => p.Variant)
|
.Include(p => p.Variety)
|
||||||
.ToList()) { }
|
.ToList()) { }
|
||||||
|
|
||||||
public DeliveryJournal(AppDbContext ctx, DateOnly date) :
|
public DeliveryJournal(AppDbContext ctx, DateOnly date) :
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
<td class="small">@($"{p.Delivery.Time:HH:mm}")</td>
|
<td class="small">@($"{p.Delivery.Time:HH:mm}")</td>
|
||||||
<td class="number">@p.Delivery.Member.MgNr</td>
|
<td class="number">@p.Delivery.Member.MgNr</td>
|
||||||
<td class="small">@p.Delivery.Member.AdministrativeName</td>
|
<td class="small">@p.Delivery.Member.AdministrativeName</td>
|
||||||
<td class="small">@p.Variant.Name</td>
|
<td class="small">@p.Variety.Name</td>
|
||||||
<td class="center">@($"{p.Oe:N0}")</td>
|
<td class="center">@($"{p.Oe:N0}")</td>
|
||||||
<td class="center">@($"{p.Kmw:N1}")</td>
|
<td class="center">@($"{p.Kmw:N1}")</td>
|
||||||
<td class="number">@($"{p.Weight:N0}")</td>
|
<td class="number">@($"{p.Weight:N0}")</td>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
@foreach (var part in Model.Delivery.Parts.OrderBy(p => p.DPNr)) {
|
@foreach (var part in Model.Delivery.Parts.OrderBy(p => p.DPNr)) {
|
||||||
<tr class="main">
|
<tr class="main">
|
||||||
<td class="center">@part.DPNr</td>
|
<td class="center">@part.DPNr</td>
|
||||||
<td colspan="2">@part.Variant.Name</td>
|
<td colspan="2">@part.Variety.Name</td>
|
||||||
<td colspan="2">@part.Attribute?.Name</td>
|
<td colspan="2">@part.Attribute?.Name</td>
|
||||||
<td>@part.Quality.Name</td>
|
<td>@part.Quality.Name</td>
|
||||||
<td class="center">@($"{part.Oe:N0}")</td>
|
<td class="center">@($"{part.Oe:N0}")</td>
|
||||||
|
|||||||
@@ -150,31 +150,31 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Dictionary<string, JsonValue> GetSelection(JsonNode value, IEnumerable<string> attributeVariants) {
|
protected static Dictionary<string, JsonValue> GetSelection(JsonNode value, IEnumerable<string> vaributes) {
|
||||||
if (value is JsonValue flatRate) {
|
if (value is JsonValue flatRate) {
|
||||||
return attributeVariants.ToDictionary(e => e, _ => flatRate);
|
return vaributes.ToDictionary(e => e, _ => flatRate);
|
||||||
} if (value is not JsonObject data) {
|
} if (value is not JsonObject data) {
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
Dictionary<string, JsonValue> dict;
|
Dictionary<string, JsonValue> dict;
|
||||||
if (data["default"] is JsonValue def) {
|
if (data["default"] is JsonValue def) {
|
||||||
dict = attributeVariants.ToDictionary(e => e, _ => def);
|
dict = vaributes.ToDictionary(e => e, _ => def);
|
||||||
} else {
|
} else {
|
||||||
dict = [];
|
dict = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var variants = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length == 2);
|
var varieties = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length == 2);
|
||||||
var attributes = data.Where(p => p.Key.StartsWith('/'));
|
var attributes = data.Where(p => p.Key.StartsWith('/'));
|
||||||
var others = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length > 2 && p.Key != "default");
|
var others = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length > 2 && p.Key != "default");
|
||||||
foreach (var (idx, v) in variants) {
|
foreach (var (idx, v) in varieties) {
|
||||||
var curve = v?.AsValue() ?? throw new InvalidOperationException();
|
var curve = v?.AsValue() ?? throw new InvalidOperationException();
|
||||||
foreach (var i in attributeVariants.Where(e => e.StartsWith(idx[..^1]))) {
|
foreach (var i in vaributes.Where(e => e.StartsWith(idx[..^1]))) {
|
||||||
dict[i] = curve;
|
dict[i] = curve;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var (idx, v) in attributes) {
|
foreach (var (idx, v) in attributes) {
|
||||||
var curve = v?.AsValue() ?? throw new InvalidOperationException();
|
var curve = v?.AsValue() ?? throw new InvalidOperationException();
|
||||||
foreach (var i in attributeVariants.Where(e => e[2..] == idx[1..])) {
|
foreach (var i in vaributes.Where(e => e[2..] == idx[1..])) {
|
||||||
dict[i] = curve;
|
dict[i] = curve;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return curve;
|
return curve;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void CollapsePaymentData(JsonObject data, IEnumerable<string> attributeVariants) {
|
protected static void CollapsePaymentData(JsonObject data, IEnumerable<string> vaributes, bool useDefault = true) {
|
||||||
Dictionary<string, List<string>> rev1 = [];
|
Dictionary<string, List<string>> rev1 = [];
|
||||||
Dictionary<decimal, List<string>> rev2 = [];
|
Dictionary<decimal, List<string>> rev2 = [];
|
||||||
foreach (var (k, v) in data) {
|
foreach (var (k, v) in data) {
|
||||||
@@ -273,18 +273,18 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
if (!data.ContainsKey("default")) {
|
if (!data.ContainsKey("default")) {
|
||||||
foreach (var (v, ks) in rev1) {
|
foreach (var (v, ks) in rev1) {
|
||||||
if (ks.Count >= attributeVariants.Count() / 2.0) {
|
if ((ks.Count >= vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
|
||||||
foreach (var k in ks) data.Remove(k);
|
foreach (var k in ks) data.Remove(k);
|
||||||
data["default"] = v;
|
data["default"] = v;
|
||||||
CollapsePaymentData(data, attributeVariants);
|
CollapsePaymentData(data, vaributes, useDefault);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var (v, ks) in rev2) {
|
foreach (var (v, ks) in rev2) {
|
||||||
if (ks.Count >= attributeVariants.Count() / 2.0) {
|
if ((ks.Count >= vaributes.Count() * 0.5 && useDefault) || ks.Count == vaributes.Count()) {
|
||||||
foreach (var k in ks) data.Remove(k);
|
foreach (var k in ks) data.Remove(k);
|
||||||
data["default"] = v;
|
data["default"] = v;
|
||||||
CollapsePaymentData(data, attributeVariants);
|
CollapsePaymentData(data, vaributes, useDefault);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,17 +296,17 @@ namespace Elwig.Helpers.Billing {
|
|||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList();
|
.ToList();
|
||||||
foreach (var idx in attributes) {
|
foreach (var idx in attributes) {
|
||||||
var len = attributeVariants.Count(e => e.EndsWith(idx));
|
var len = vaributes.Count(e => e.EndsWith(idx));
|
||||||
foreach (var (v, ks) in rev1) {
|
foreach (var (v, ks) in rev1) {
|
||||||
var myKs = ks.Where(k => k.EndsWith(idx)).ToList();
|
var myKs = ks.Where(k => k.EndsWith(idx)).ToList();
|
||||||
if (myKs.Count > 1 && myKs.Count >= len / 2.0) {
|
if (myKs.Count > 1 && ((myKs.Count >= len * 0.5 && useDefault) || myKs.Count == len)) {
|
||||||
foreach (var k in myKs) data.Remove(k);
|
foreach (var k in myKs) data.Remove(k);
|
||||||
data[idx] = v;
|
data[idx] = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (var (v, ks) in rev2) {
|
foreach (var (v, ks) in rev2) {
|
||||||
var myKs = ks.Where(k => k.EndsWith(idx)).ToList();
|
var myKs = ks.Where(k => k.EndsWith(idx)).ToList();
|
||||||
if (myKs.Count > 1 && myKs.Count >= len / 2.0) {
|
if (myKs.Count > 1 && ((myKs.Count >= len * 0.5 && useDefault) || myKs.Count == len)) {
|
||||||
foreach (var k in myKs) data.Remove(k);
|
foreach (var k in myKs) data.Remove(k);
|
||||||
data[idx] = v;
|
data[idx] = v;
|
||||||
}
|
}
|
||||||
@@ -314,7 +314,13 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonObject FromGraphEntries(IEnumerable<GraphEntry> graphEntries, BillingData? origData = null, IEnumerable<string>? attributeVariants = null) {
|
public static JsonObject FromGraphEntries(
|
||||||
|
IEnumerable<GraphEntry> graphEntries,
|
||||||
|
BillingData? origData = null,
|
||||||
|
IEnumerable<string>? vaributes = null,
|
||||||
|
bool useDefaultPayment = true,
|
||||||
|
bool useDefaultQuality = true
|
||||||
|
) {
|
||||||
var payment = new JsonObject();
|
var payment = new JsonObject();
|
||||||
var qualityWei = new JsonObject();
|
var qualityWei = new JsonObject();
|
||||||
var curves = new JsonArray();
|
var curves = new JsonArray();
|
||||||
@@ -331,7 +337,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach (var c in entry.Contracts) {
|
foreach (var c in entry.Vaributes) {
|
||||||
if (entry.Abgewertet) {
|
if (entry.Abgewertet) {
|
||||||
qualityWei[$"{c.Variety?.SortId}/{c.Attribute?.AttrId}"] = node.DeepClone();
|
qualityWei[$"{c.Variety?.SortId}/{c.Attribute?.AttrId}"] = node.DeepClone();
|
||||||
} else {
|
} else {
|
||||||
@@ -340,8 +346,8 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CollapsePaymentData(payment, attributeVariants ?? payment.Select(e => e.Key).ToList());
|
CollapsePaymentData(payment, vaributes ?? payment.Select(e => e.Key).ToList(), useDefaultPayment);
|
||||||
CollapsePaymentData(qualityWei, attributeVariants ?? qualityWei.Select(e => e.Key).ToList());
|
CollapsePaymentData(qualityWei, vaributes ?? qualityWei.Select(e => e.Key).ToList(), useDefaultQuality);
|
||||||
|
|
||||||
var data = new JsonObject {
|
var data = new JsonObject {
|
||||||
["mode"] = "elwig",
|
["mode"] = "elwig",
|
||||||
@@ -359,16 +365,16 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
if (payment.Count == 0) {
|
if (payment.Count == 0) {
|
||||||
data["payment"] = 0;
|
data["payment"] = 0;
|
||||||
} else if (payment.Count == 1) {
|
} else if (payment.Count == 1 && payment.First().Key == "default") {
|
||||||
data["payment"] = payment.Single().Value?.DeepClone();
|
data["payment"] = payment.Single().Value?.DeepClone();
|
||||||
} else {
|
} else {
|
||||||
data["payment"] = payment;
|
data["payment"] = payment;
|
||||||
}
|
}
|
||||||
if (qualityWei.Count == 1) {
|
if (qualityWei.Count == 1 && qualityWei.First().Key == "default") {
|
||||||
data["quality"] = new JsonObject() {
|
data["quality"] = new JsonObject() {
|
||||||
["WEI"] = qualityWei.Single().Value?.DeepClone()
|
["WEI"] = qualityWei.Single().Value?.DeepClone()
|
||||||
};
|
};
|
||||||
} else if (qualityWei.Count > 1) {
|
} else if (qualityWei.Count >= 1) {
|
||||||
data["quality"] = new JsonObject() {
|
data["quality"] = new JsonObject() {
|
||||||
["WEI"] = qualityWei
|
["WEI"] = qualityWei
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
public BillingVariant(int year, int avnr) : base(year) {
|
public BillingVariant(int year, int avnr) : base(year) {
|
||||||
AvNr = avnr;
|
AvNr = avnr;
|
||||||
PaymentVariant = Context.PaymentVariants.Find(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
|
PaymentVariant = Context.PaymentVariants.Find(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
|
||||||
Data = PaymentBillingData.FromJson(PaymentVariant.Data, Utils.GetAttributeVarieties(Context, Year));
|
Data = PaymentBillingData.FromJson(PaymentVariant.Data, Utils.GetVaributes(Context, Year, onlyDelivered: false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Calculate() {
|
public async Task Calculate() {
|
||||||
@@ -24,9 +24,10 @@ namespace Elwig.Helpers.Billing {
|
|||||||
await DeleteInDb(cnx);
|
await DeleteInDb(cnx);
|
||||||
await SetCalcTime(cnx);
|
await SetCalcTime(cnx);
|
||||||
await CalculatePrices(cnx);
|
await CalculatePrices(cnx);
|
||||||
if (Data.ConsiderDelieryModifiers)
|
if (Data.ConsiderDelieryModifiers) {
|
||||||
await CalculateDeliveryModifiers(cnx);
|
await CalculateDeliveryModifiers(cnx);
|
||||||
await CalculateMemberModifiers(cnx);
|
await CalculateMemberModifiers(cnx);
|
||||||
|
}
|
||||||
await tx.CommitAsync();
|
await tx.CommitAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,15 +7,15 @@ using System.Text.Json.Nodes;
|
|||||||
namespace Elwig.Helpers.Billing {
|
namespace Elwig.Helpers.Billing {
|
||||||
public class EditBillingData : BillingData {
|
public class EditBillingData : BillingData {
|
||||||
|
|
||||||
protected readonly IEnumerable<string> AttributeVariants;
|
protected readonly IEnumerable<string> Vaributes;
|
||||||
|
|
||||||
public EditBillingData(JsonObject data, IEnumerable<string> attributeVariants) :
|
public EditBillingData(JsonObject data, IEnumerable<string> vaributes) :
|
||||||
base(data) {
|
base(data) {
|
||||||
AttributeVariants = attributeVariants;
|
Vaributes = vaributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EditBillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
public static EditBillingData FromJson(string json, IEnumerable<string> vaributes) {
|
||||||
return new(ParseJson(json), attributeVariants);
|
return new(ParseJson(json), vaributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private (Dictionary<int, Curve>, Dictionary<int, List<string>>) GetGraphEntries(JsonNode root) {
|
private (Dictionary<int, Curve>, Dictionary<int, List<string>>) GetGraphEntries(JsonNode root) {
|
||||||
@@ -56,7 +56,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<int, List<string>> dict3 = curves.ToDictionary(c => c.Key, _ => new List<string>());
|
Dictionary<int, List<string>> dict3 = curves.ToDictionary(c => c.Key, _ => new List<string>());
|
||||||
foreach (var (selector, value) in GetSelection(root, AttributeVariants)) {
|
foreach (var (selector, value) in GetSelection(root, Vaributes)) {
|
||||||
int? idx = null;
|
int? idx = null;
|
||||||
if (value.TryGetValue<decimal>(out var val)) {
|
if (value.TryGetValue<decimal>(out var val)) {
|
||||||
idx = Array.IndexOf(virtCurves, val) + virtOffset;
|
idx = Array.IndexOf(virtCurves, val) + virtOffset;
|
||||||
@@ -70,12 +70,16 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return (curves, dict3);
|
return (curves, dict3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<GraphEntry> CreateGraphEntries(AppDbContext ctx, int precision, Dictionary<int, Curve> curves, Dictionary<int, List<string>> entries) {
|
private static List<GraphEntry> CreateGraphEntries(
|
||||||
|
AppDbContext ctx, int precision,
|
||||||
|
Dictionary<int, Curve> curves,
|
||||||
|
Dictionary<int, List<string>> entries
|
||||||
|
) {
|
||||||
var vars = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
|
var vars = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
|
||||||
var attrs = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
var attrs = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
||||||
return entries
|
return entries
|
||||||
.Select(e => new GraphEntry(e.Key, precision, curves[e.Key], e.Value
|
.Select(e => new GraphEntry(e.Key, precision, curves[e.Key], e.Value
|
||||||
.Select(s => new ContractSelection(vars[s[..2]], s.Length > 2 ? attrs[s[2..]] : null))
|
.Select(s => new Varibute(vars[s[..2]], s.Length > 2 ? attrs[s[2..]] : null))
|
||||||
.ToList()))
|
.ToList()))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
@@ -83,7 +87,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
public IEnumerable<GraphEntry> GetPaymentGraphEntries(AppDbContext ctx, Season season) {
|
public IEnumerable<GraphEntry> GetPaymentGraphEntries(AppDbContext ctx, Season season) {
|
||||||
var root = GetPaymentEntry();
|
var root = GetPaymentEntry();
|
||||||
var (curves, entries) = GetGraphEntries(root);
|
var (curves, entries) = GetGraphEntries(root);
|
||||||
return CreateGraphEntries(ctx, season.Precision, curves, entries).Where(e => e.Contracts.Count > 0);
|
return CreateGraphEntries(ctx, season.Precision, curves, entries).Where(e => e.Vaributes.Count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<GraphEntry> GetQualityGraphEntries(AppDbContext ctx, Season season, int idOffset = 0) {
|
public IEnumerable<GraphEntry> GetQualityGraphEntries(AppDbContext ctx, Season season, int idOffset = 0) {
|
||||||
@@ -91,7 +95,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
if (root == null || root["WEI"] is not JsonNode qualityWei)
|
if (root == null || root["WEI"] is not JsonNode qualityWei)
|
||||||
return [];
|
return [];
|
||||||
var (curves, entries) = GetGraphEntries(qualityWei);
|
var (curves, entries) = GetGraphEntries(qualityWei);
|
||||||
var list = CreateGraphEntries(ctx, season.Precision, curves, entries).Where(e => e.Contracts.Count > 0);
|
var list = CreateGraphEntries(ctx, season.Precision, curves, entries).Where(e => e.Vaributes.Count > 0);
|
||||||
foreach (var e in list) {
|
foreach (var e in list) {
|
||||||
e.Id += idOffset;
|
e.Id += idOffset;
|
||||||
e.Abgewertet = true;
|
e.Abgewertet = true;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
public const int MinX = 50;
|
public const int MinX = 50;
|
||||||
public const int MinXGeb = 73;
|
public const int MinXGeb = 73;
|
||||||
public const int MaxX = 140;
|
public const int MaxX = 120;
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public BillingData.CurveMode Mode { get; set; }
|
public BillingData.CurveMode Mode { get; set; }
|
||||||
@@ -36,10 +36,10 @@ namespace Elwig.Helpers.Billing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ContractSelection> Contracts { get; set; }
|
public List<Varibute> Vaributes { get; set; }
|
||||||
public string ContractsStringSimple => (Abgewertet ? "Abgew.: " : "") + (Contracts.Count != 0 ? (Contracts.Count >= 25 ? "Restliche Sorten" : string.Join(", ", Contracts.Select(c => c.Listing))) : "-");
|
public string VaributeStringSimple => (Abgewertet ? "Abgew.: " : "") + (Vaributes.Count != 0 ? (Vaributes.Count >= 25 ? "Restliche Sorten" : string.Join(", ", Vaributes.Select(c => c.Listing))) : "-");
|
||||||
public string ContractsString => Contracts.Count != 0 ? string.Join("\n", Contracts.Select(c => c.FullName)) : "-";
|
public string VaributeString => Vaributes.Count != 0 ? string.Join("\n", Vaributes.Select(c => c.FullName)) : "-";
|
||||||
public string ContractsStringChange => (Abgewertet ? "A." : "") + string.Join(",", Contracts.Select(c => c.Listing));
|
public string VaributeStringChange => (Abgewertet ? "A." : "") + string.Join(",", Vaributes.Select(c => c.Listing));
|
||||||
private readonly int Precision;
|
private readonly int Precision;
|
||||||
|
|
||||||
public GraphEntry(int id, int precision, BillingData.CurveMode mode) {
|
public GraphEntry(int id, int precision, BillingData.CurveMode mode) {
|
||||||
@@ -47,7 +47,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
Precision = precision;
|
Precision = precision;
|
||||||
Mode = mode;
|
Mode = mode;
|
||||||
DataGraph = new Graph(precision, MinX, MaxX); ;
|
DataGraph = new Graph(precision, MinX, MaxX); ;
|
||||||
Contracts = [];
|
Vaributes = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphEntry(int id, int precision, BillingData.CurveMode mode, Dictionary<double, decimal> data, Dictionary<double, decimal>? gebunden) :
|
public GraphEntry(int id, int precision, BillingData.CurveMode mode, Dictionary<double, decimal> data, Dictionary<double, decimal>? gebunden) :
|
||||||
@@ -56,21 +56,21 @@ namespace Elwig.Helpers.Billing {
|
|||||||
if (gebunden != null) GebundenGraph = new Graph(gebunden, precision, MinXGeb, MaxX);
|
if (gebunden != null) GebundenGraph = new Graph(gebunden, precision, MinXGeb, MaxX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphEntry(int id, int precision, BillingData.Curve curve, List<ContractSelection> contracts) :
|
public GraphEntry(int id, int precision, BillingData.Curve curve, List<Varibute> vaributes) :
|
||||||
this(id, precision, curve.Mode) {
|
this(id, precision, curve.Mode) {
|
||||||
DataGraph = new Graph(curve.Normal, precision, MinX, MaxX);
|
DataGraph = new Graph(curve.Normal, precision, MinX, MaxX);
|
||||||
if (curve.Gebunden != null)
|
if (curve.Gebunden != null)
|
||||||
GebundenGraph = new Graph(curve.Gebunden, precision, MinXGeb, MaxX);
|
GebundenGraph = new Graph(curve.Gebunden, precision, MinXGeb, MaxX);
|
||||||
Contracts = contracts;
|
Vaributes = vaributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GraphEntry(int id, int precision, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph, List<ContractSelection> contracts) {
|
private GraphEntry(int id, int precision, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph, List<Varibute> vaributes) {
|
||||||
Id = id;
|
Id = id;
|
||||||
Precision = precision;
|
Precision = precision;
|
||||||
Mode = mode;
|
Mode = mode;
|
||||||
DataGraph = dataGraph;
|
DataGraph = dataGraph;
|
||||||
GebundenGraph = gebundenGraph;
|
GebundenGraph = gebundenGraph;
|
||||||
Contracts = contracts;
|
Vaributes = vaributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddGebundenGraph() {
|
public void AddGebundenGraph() {
|
||||||
|
|||||||
@@ -9,24 +9,24 @@ namespace Elwig.Helpers.Billing {
|
|||||||
protected readonly Dictionary<int, Curve> Curves;
|
protected readonly Dictionary<int, Curve> Curves;
|
||||||
protected readonly Dictionary<string, Curve> PaymentData;
|
protected readonly Dictionary<string, Curve> PaymentData;
|
||||||
protected readonly Dictionary<string, Curve> QualityData;
|
protected readonly Dictionary<string, Curve> QualityData;
|
||||||
protected readonly IEnumerable<string> AttributeVariants;
|
protected readonly IEnumerable<string> Vaributes;
|
||||||
|
|
||||||
public PaymentBillingData(JsonObject data, IEnumerable<string> attributeVariants) :
|
public PaymentBillingData(JsonObject data, IEnumerable<string> vaributes) :
|
||||||
base(data) {
|
base(data) {
|
||||||
if (attributeVariants.Any(e => e.Any(c => c < 'A' || c > 'Z')))
|
if (vaributes.Any(e => e.Any(c => c < 'A' || c > 'Z')))
|
||||||
throw new ArgumentException("Invalid attributeVariants");
|
throw new ArgumentException("Invalid vaributes");
|
||||||
AttributeVariants = attributeVariants;
|
Vaributes = vaributes;
|
||||||
Curves = GetCurves();
|
Curves = GetCurves();
|
||||||
PaymentData = GetPaymentData();
|
PaymentData = GetPaymentData();
|
||||||
QualityData = GetQualityData();
|
QualityData = GetQualityData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PaymentBillingData FromJson(string json, IEnumerable<string> attributeVariants) {
|
public static PaymentBillingData FromJson(string json, IEnumerable<string> vaributes) {
|
||||||
return new(ParseJson(json), attributeVariants);
|
return new(ParseJson(json), vaributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<string, Curve> GetData(JsonNode data) {
|
private Dictionary<string, Curve> GetData(JsonNode data) {
|
||||||
return GetSelection(data, AttributeVariants).ToDictionary(e => e.Key, e => LookupCurve(e.Value));
|
return GetSelection(data, Vaributes).ToDictionary(e => e.Key, e => LookupCurve(e.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dictionary<string, Curve> GetPaymentData() {
|
protected Dictionary<string, Curve> GetPaymentData() {
|
||||||
|
|||||||
@@ -2,14 +2,17 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Elwig.Helpers.Billing {
|
namespace Elwig.Helpers.Billing {
|
||||||
public class ContractSelection : IComparable<ContractSelection> {
|
public class Varibute : IComparable<Varibute> {
|
||||||
|
|
||||||
public WineVar? Variety { get; }
|
public WineVar? Variety { get; }
|
||||||
public WineAttr? Attribute { get; }
|
public WineAttr? Attribute { get; }
|
||||||
|
public int? AssignedGraphId { get; set; }
|
||||||
|
public int? AssignedAbgewGraphId { get; set; }
|
||||||
|
|
||||||
public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}";
|
public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}";
|
||||||
public string FullName => $"{Variety?.Name}" + (Variety != null && Attribute != null ? " " : "") + $"{Attribute?.Name}";
|
public string FullName => $"{Variety?.Name}" + (Variety != null && Attribute != null ? " " : "") + $"{Attribute?.Name}";
|
||||||
|
|
||||||
public ContractSelection(WineVar? var, WineAttr? attr) {
|
public Varibute(WineVar? var, WineAttr? attr) {
|
||||||
Variety = var;
|
Variety = var;
|
||||||
Attribute = attr;
|
Attribute = attr;
|
||||||
}
|
}
|
||||||
@@ -18,7 +21,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
return Listing;
|
return Listing;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CompareTo(ContractSelection? other) {
|
public int CompareTo(Varibute? other) {
|
||||||
return Listing.CompareTo(other?.Listing);
|
return Listing.CompareTo(other?.Listing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,12 +74,16 @@ namespace Elwig.Helpers.Printing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async Task Print(string path, int copies = 1) {
|
public static async Task Print(string path, int copies = 1) {
|
||||||
var p = new Process() { StartInfo = new() { FileName = PdfToPrinter } };
|
try {
|
||||||
p.StartInfo.ArgumentList.Add(path);
|
var p = new Process() { StartInfo = new() { FileName = PdfToPrinter } };
|
||||||
p.StartInfo.ArgumentList.Add("/s");
|
p.StartInfo.ArgumentList.Add(path);
|
||||||
p.StartInfo.ArgumentList.Add($"copies={copies}");
|
p.StartInfo.ArgumentList.Add("/s");
|
||||||
p.Start();
|
p.StartInfo.ArgumentList.Add($"copies={copies}");
|
||||||
await p.WaitForExitAsync();
|
p.Start();
|
||||||
|
await p.WaitForExitAsync();
|
||||||
|
} catch (Exception e) {
|
||||||
|
MessageBox.Show("Beim Drucken ist ein Fehler aufgetreten:\n\n" + e.Message, "Fehler beim Drucken");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-13
@@ -362,25 +362,21 @@ namespace Elwig.Helpers {
|
|||||||
return output.OrderByDescending(l => l.Count());
|
return output.OrderByDescending(l => l.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<string> GetAttributeVarieties(AppDbContext ctx, int year, bool withSlash = false) {
|
public static List<string> GetVaributes(AppDbContext ctx, int year, bool withSlash = false, bool onlyDelivered = true) {
|
||||||
return ctx.DeliveryParts
|
var varieties = ctx.WineVarieties.Select(v => v.SortId).ToList();
|
||||||
|
var delivered = ctx.DeliveryParts
|
||||||
.Where(d => d.Year == year)
|
.Where(d => d.Year == year)
|
||||||
.Select(d => $"{d.SortId}{(withSlash ? "/" : "")}{d.AttrId}")
|
.Select(d => $"{d.SortId}{(withSlash ? "/" : "")}{d.AttrId}")
|
||||||
.Distinct()
|
.Distinct()
|
||||||
.ToList()
|
|
||||||
.Union(ctx.WineVarieties.Select(v => v.SortId))
|
|
||||||
.ToList();
|
.ToList();
|
||||||
|
return [.. (onlyDelivered ? delivered : delivered.Union(varieties)).Order()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ContractSelection> GetContractsForYear(AppDbContext ctx, int year) {
|
public static List<Varibute> GetVaributeList(AppDbContext ctx, int year, bool onlyDelivered = true) {
|
||||||
return ctx.DeliveryParts
|
var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
|
||||||
.Where(p => p.Year == year)
|
var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
|
||||||
.Select(d => new ContractSelection(d.Variant, d.Attribute))
|
return GetVaributes(ctx, year, false, onlyDelivered)
|
||||||
.Distinct()
|
.Select(s => new Varibute(varieties[s[..2]], s.Length > 2 ? attributes[s[2..]] : null))
|
||||||
.ToList()
|
|
||||||
.Union(ctx.WineVarieties.Select(v => new ContractSelection(v, null)))
|
|
||||||
.DistinctBy(c => c.Listing)
|
|
||||||
.Order()
|
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using Elwig.Helpers;
|
using Elwig.Models.Entities;
|
||||||
using Elwig.Helpers.Billing;
|
|
||||||
using Elwig.Models.Entities;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -46,7 +43,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
return await table.FromSqlRaw($"""
|
return await table.FromSqlRaw($"""
|
||||||
SELECT d.year, c.tgnr, v.avnr, d.mgnr, d.did, d.lsnr, d.dpnr, d.weight, d.modifiers,
|
SELECT d.year, c.tgnr, v.avnr, d.mgnr, d.did, d.lsnr, d.dpnr, d.weight, d.modifiers,
|
||||||
b.bktnr, d.sortid, b.discr, b.value, pb.price, pb.amount, p.net_amount, p.amount AS total_amount,
|
b.bktnr, d.sortid, b.discr, b.value, pb.price, pb.amount, p.net_amount, p.amount AS total_amount,
|
||||||
s.name AS variant, a.name AS attribute, q.name AS quality_level, d.oe, d.kmw
|
s.name AS variety, a.name AS attribute, q.name AS quality_level, d.oe, d.kmw
|
||||||
FROM v_delivery d
|
FROM v_delivery d
|
||||||
JOIN wine_variety s ON s.sortid = d.sortid
|
JOIN wine_variety s ON s.sortid = d.sortid
|
||||||
LEFT JOIN wine_attribute a ON a.attrid = d.attrid
|
LEFT JOIN wine_attribute a ON a.attrid = d.attrid
|
||||||
@@ -71,7 +68,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
|
|
||||||
public string LsNr;
|
public string LsNr;
|
||||||
public int DPNr;
|
public int DPNr;
|
||||||
public string Variant;
|
public string Variety;
|
||||||
public string? Attribute;
|
public string? Attribute;
|
||||||
public string[] Modifiers;
|
public string[] Modifiers;
|
||||||
public string QualityLevel;
|
public string QualityLevel;
|
||||||
@@ -89,7 +86,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
|
|
||||||
LsNr = f.LsNr;
|
LsNr = f.LsNr;
|
||||||
DPNr = f.DPNr;
|
DPNr = f.DPNr;
|
||||||
Variant = f.Variant;
|
Variety = f.Variety;
|
||||||
Attribute = f.Attribute;
|
Attribute = f.Attribute;
|
||||||
var modifiers = (IEnumerable<Modifier>)(f.Modifiers ?? "").Split(',')
|
var modifiers = (IEnumerable<Modifier>)(f.Modifiers ?? "").Split(',')
|
||||||
.Select(m => season?.Modifiers.FirstOrDefault(s => s.ModId == m))
|
.Select(m => season?.Modifiers.FirstOrDefault(s => s.ModId == m))
|
||||||
@@ -148,8 +145,8 @@ namespace Elwig.Models.Dtos {
|
|||||||
public long? NetAmount { get; set; }
|
public long? NetAmount { get; set; }
|
||||||
[Column("total_amount")]
|
[Column("total_amount")]
|
||||||
public long? TotalAmount { get; set; }
|
public long? TotalAmount { get; set; }
|
||||||
[Column("variant")]
|
[Column("variety")]
|
||||||
public string Variant { get; set; }
|
public string Variety { get; set; }
|
||||||
[Column("attribute")]
|
[Column("attribute")]
|
||||||
public string? Attribute { get; set; }
|
public string? Attribute { get; set; }
|
||||||
[Column("quality_level")]
|
[Column("quality_level")]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
private static readonly (string, string, string?, int)[] FieldNames = new[] {
|
private static readonly (string, string, string?, int)[] FieldNames = new[] {
|
||||||
("LsNr", "LsNr.", null, 26),
|
("LsNr", "LsNr.", null, 26),
|
||||||
("DPNr", "Pos.", null, 8),
|
("DPNr", "Pos.", null, 8),
|
||||||
("Variant", "Sorte", null, 40),
|
("Variety", "Sorte", null, 40),
|
||||||
("Attribute", "Attribut", null, 20),
|
("Attribute", "Attribut", null, 20),
|
||||||
("Modifiers", "Zu-/Abschläge", null, 30),
|
("Modifiers", "Zu-/Abschläge", null, 30),
|
||||||
("QualityLevel", "Qualitätsstufe", null, 25),
|
("QualityLevel", "Qualitätsstufe", null, 25),
|
||||||
@@ -51,7 +51,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
if (mgnr != null) q = q.Where(p => p.Delivery.MgNr == mgnr);
|
if (mgnr != null) q = q.Where(p => p.Delivery.MgNr == mgnr);
|
||||||
await q
|
await q
|
||||||
.Include(p => p.Delivery)
|
.Include(p => p.Delivery)
|
||||||
.Include(p => p.Variant)
|
.Include(p => p.Variety)
|
||||||
.Include(p => p.Attribute)
|
.Include(p => p.Attribute)
|
||||||
.Include(p => p.Quality)
|
.Include(p => p.Quality)
|
||||||
.Include(p => p.Buckets)
|
.Include(p => p.Buckets)
|
||||||
@@ -71,7 +71,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
public class DeliveryConfirmationRow {
|
public class DeliveryConfirmationRow {
|
||||||
public string LsNr;
|
public string LsNr;
|
||||||
public int DPNr;
|
public int DPNr;
|
||||||
public string Variant;
|
public string Variety;
|
||||||
public string? Attribute;
|
public string? Attribute;
|
||||||
public string QualityLevel;
|
public string QualityLevel;
|
||||||
public (double Oe, double Kmw) Gradation;
|
public (double Oe, double Kmw) Gradation;
|
||||||
@@ -83,7 +83,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
var d = p.Delivery;
|
var d = p.Delivery;
|
||||||
LsNr = d.LsNr;
|
LsNr = d.LsNr;
|
||||||
DPNr = p.DPNr;
|
DPNr = p.DPNr;
|
||||||
Variant = p.Variant.Name;
|
Variety = p.Variety.Name;
|
||||||
Attribute = p.Attribute?.Name;
|
Attribute = p.Attribute?.Name;
|
||||||
QualityLevel = p.Quality.Name;
|
QualityLevel = p.Quality.Name;
|
||||||
Gradation = (p.Oe, p.Kmw);
|
Gradation = (p.Oe, p.Kmw);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace Elwig.Models.Entities {
|
|||||||
public string SortId { get; set; }
|
public string SortId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("SortId")]
|
||||||
public virtual WineVar Variant { get; private set; }
|
public virtual WineVar Variety { get; private set; }
|
||||||
|
|
||||||
[Column("attrid")]
|
[Column("attrid")]
|
||||||
public string? AttrId { get; set; }
|
public string? AttrId { get; set; }
|
||||||
|
|||||||
@@ -61,14 +61,17 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="Für:" Margin="10,-2,0,0" FontSize="14" Grid.Column="0" VerticalAlignment="Center"/>
|
<Label Content="Für:" Margin="10,-2,0,0" FontSize="14" Grid.Column="0" VerticalAlignment="Center"/>
|
||||||
<xctk:CheckComboBox x:Name="ContractInput" Margin="50,0,0,0" Grid.Column="0"
|
<xctk:CheckComboBox x:Name="VaributeInput" Margin="50,0,0,0" Grid.Column="0" Width="500" Height="25" HorizontalAlignment="Left"
|
||||||
Delimiter=", " AllItemsSelectedContent="Alle" IsEnabled="False" ItemSelectionChanged="ContractInput_Changed"
|
IsSelectAllActive="True" SelectAllContent="Alle Sorten" Delimiter=", " AllItemsSelectedContent="Alle Sorten"
|
||||||
Width="500" Height="25" HorizontalAlignment="Left">
|
IsEnabled="False" ItemSelectionChanged="VaributeInput_Changed">
|
||||||
<xctk:CheckComboBox.ItemTemplate>
|
<xctk:CheckComboBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Variety.Name}" Width="150"/>
|
<TextBlock Text="{Binding Variety.Name}" Width="150"/>
|
||||||
<TextBlock Text="{Binding Attribute.Name}"/>
|
<TextBlock Text="{Binding Variety.Type}" Width="30"/>
|
||||||
|
<TextBlock Text="{Binding Attribute.Name}" Width="120"/>
|
||||||
|
<TextBlock Text="{Binding AssignedGraphId}" Width="30"/>
|
||||||
|
<TextBlock Text="{Binding AssignedAbgewGraphId}" Width="30"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</xctk:CheckComboBox.ItemTemplate>
|
</xctk:CheckComboBox.ItemTemplate>
|
||||||
@@ -83,7 +86,7 @@
|
|||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Id}" Width="30"/>
|
<TextBlock Text="{Binding Id}" Width="30"/>
|
||||||
<TextBlock Text="{Binding ContractsStringSimple}" ToolTip="{Binding ContractsString}"/>
|
<TextBlock Text="{Binding VaributeStringSimple}" ToolTip="{Binding VaributeString}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
|||||||
@@ -33,14 +33,28 @@ namespace Elwig.Windows {
|
|||||||
private Marker PrimaryMarkedPointPlot;
|
private Marker PrimaryMarkedPointPlot;
|
||||||
private Marker SecondaryMarkedPointPlot;
|
private Marker SecondaryMarkedPointPlot;
|
||||||
private Text TooltipPlot;
|
private Text TooltipPlot;
|
||||||
private LegendItem UngebundenLegend;
|
|
||||||
private LegendItem GebundenLegend;
|
|
||||||
private LegendItem LDWLegend;
|
|
||||||
private LegendItem QUWLegend;
|
|
||||||
private LegendItem KABLegend;
|
|
||||||
|
|
||||||
private (Graph? graph, int index) LastHighlighted = (null, -1);
|
private static readonly LegendItem
|
||||||
private (Graph? graph, int index) Highlighted = (null, -1);
|
UngebundenLegend = new() {
|
||||||
|
Label = "Ungebunden", LineWidth = 1, LineColor = ColorUngebunden,
|
||||||
|
Marker = new(MarkerShape.FilledCircle, 5, ColorUngebunden)
|
||||||
|
},
|
||||||
|
GebundenLegend = new() {
|
||||||
|
Label = "Gebunden", LineWidth = 1, LineColor = ColorGebunden,
|
||||||
|
Marker = new(MarkerShape.FilledCircle, 5, ColorGebunden)
|
||||||
|
},
|
||||||
|
LdwLegend = new() {
|
||||||
|
Label = "68 °Oe (LDW)", LineWidth = 2, LineColor = Colors.Red, Marker = MarkerStyle.None
|
||||||
|
},
|
||||||
|
QuwLegend = new() {
|
||||||
|
Label = "73 °Oe (QUW)", LineWidth = 2, LineColor = Colors.Orange, Marker = MarkerStyle.None
|
||||||
|
},
|
||||||
|
KabLegend = new() {
|
||||||
|
Label = "84 °Oe (KAB)", LineWidth = 2, LineColor = Colors.Green, Marker = MarkerStyle.None
|
||||||
|
};
|
||||||
|
|
||||||
|
private (Graph? Graph, int Index) LastHighlighted = (null, -1);
|
||||||
|
private (Graph? Graph, int Index) Highlighted = (null, -1);
|
||||||
private Graph? ActiveGraph = null;
|
private Graph? ActiveGraph = null;
|
||||||
private int PrimaryMarkedPoint = -1;
|
private int PrimaryMarkedPoint = -1;
|
||||||
private int SecondaryMarkedPoint = -1;
|
private int SecondaryMarkedPoint = -1;
|
||||||
@@ -50,6 +64,9 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private List<GraphEntry> GraphEntries = [];
|
private List<GraphEntry> GraphEntries = [];
|
||||||
private GraphEntry? SelectedGraphEntry => (GraphEntry)GraphList.SelectedItem;
|
private GraphEntry? SelectedGraphEntry => (GraphEntry)GraphList.SelectedItem;
|
||||||
|
private List<Varibute> Vaributes = [];
|
||||||
|
private bool AllVaributesAssigned => Vaributes.All(v => v.AssignedGraphId != null);
|
||||||
|
private bool AllVaributesAssignedAbgew => Vaributes.All(v => v.AssignedAbgewGraphId != null);
|
||||||
|
|
||||||
public ChartWindow(int year, int avnr) {
|
public ChartWindow(int year, int avnr) {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -84,18 +101,29 @@ namespace Elwig.Windows {
|
|||||||
PaymentVar = await Context.PaymentVariants.FindAsync(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
|
PaymentVar = await Context.PaymentVariants.FindAsync(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
|
||||||
Season = await Context.Seasons.FindAsync(Year) ?? throw new ArgumentException("Season not found");
|
Season = await Context.Seasons.FindAsync(Year) ?? throw new ArgumentException("Season not found");
|
||||||
|
|
||||||
var data = EditBillingData.FromJson(PaymentVar.Data, Utils.GetAttributeVarieties(Context, Year));
|
var data = EditBillingData.FromJson(PaymentVar.Data, Utils.GetVaributes(Context, Year));
|
||||||
var paymentEntries = data.GetPaymentGraphEntries(Context, Season);
|
var paymentEntries = data.GetPaymentGraphEntries(Context, Season);
|
||||||
GraphEntries = [
|
GraphEntries = [
|
||||||
..paymentEntries,
|
..paymentEntries,
|
||||||
..data.GetQualityGraphEntries(Context, Season, paymentEntries.Max(e => e.Id))
|
..data.GetQualityGraphEntries(Context, Season, paymentEntries.Any() ? paymentEntries.Max(e => e.Id) : 0)
|
||||||
];
|
];
|
||||||
|
Vaributes = Utils.GetVaributeList(Context, Year);
|
||||||
|
GraphEntries.ForEach(e => {
|
||||||
|
e.Vaributes.ForEach(v => {
|
||||||
|
var found = Vaributes.Find(a => a.Attribute?.AttrId == v.Attribute?.AttrId && a.Variety?.SortId == v.Variety?.SortId);
|
||||||
|
if (found == null) return;
|
||||||
|
if (e.Abgewertet) {
|
||||||
|
found.AssignedAbgewGraphId = e.Id;
|
||||||
|
} else {
|
||||||
|
found.AssignedGraphId = e.Id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var contracts = Utils.GetContractsForYear(Context, Year);
|
|
||||||
FillingInputs = true;
|
FillingInputs = true;
|
||||||
ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.Listing);
|
ControlUtils.RenewItemsSource(VaributeInput, Vaributes, v => (v as Varibute)?.Listing);
|
||||||
FillingInputs = false;
|
FillingInputs = false;
|
||||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.ContractsStringChange, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.VaributeStringChange, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||||
|
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
}
|
}
|
||||||
@@ -108,7 +136,7 @@ namespace Elwig.Windows {
|
|||||||
GebundenTypeFixed.IsEnabled = true;
|
GebundenTypeFixed.IsEnabled = true;
|
||||||
GebundenTypeGraph.IsEnabled = true;
|
GebundenTypeGraph.IsEnabled = true;
|
||||||
GebundenTypeNone.IsEnabled = true;
|
GebundenTypeNone.IsEnabled = true;
|
||||||
ContractInput.IsEnabled = true;
|
VaributeInput.IsEnabled = true;
|
||||||
AbgewertetInput.IsEnabled = true;
|
AbgewertetInput.IsEnabled = true;
|
||||||
EnableOptionButtons();
|
EnableOptionButtons();
|
||||||
FillInputs();
|
FillInputs();
|
||||||
@@ -127,7 +155,7 @@ namespace Elwig.Windows {
|
|||||||
GebundenTypeFixed.IsEnabled = false;
|
GebundenTypeFixed.IsEnabled = false;
|
||||||
GebundenTypeGraph.IsEnabled = false;
|
GebundenTypeGraph.IsEnabled = false;
|
||||||
GebundenTypeNone.IsEnabled = false;
|
GebundenTypeNone.IsEnabled = false;
|
||||||
ContractInput.IsEnabled = false;
|
VaributeInput.IsEnabled = false;
|
||||||
AbgewertetInput.IsEnabled = false;
|
AbgewertetInput.IsEnabled = false;
|
||||||
}
|
}
|
||||||
GC.Collect();
|
GC.Collect();
|
||||||
@@ -148,7 +176,7 @@ namespace Elwig.Windows {
|
|||||||
GebundenFlatBonus.Text = "";
|
GebundenFlatBonus.Text = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlUtils.SelectCheckComboBoxItems(ContractInput, SelectedGraphEntry?.Contracts ?? [], i => (i as ContractSelection)?.Listing);
|
ControlUtils.SelectCheckComboBoxItems(VaributeInput, SelectedGraphEntry?.Vaributes ?? [], i => (i as Varibute)?.Listing);
|
||||||
|
|
||||||
InitPlot();
|
InitPlot();
|
||||||
OechslePricePlot.IsEnabled = true;
|
OechslePricePlot.IsEnabled = true;
|
||||||
@@ -160,41 +188,6 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void InitPlot() {
|
private void InitPlot() {
|
||||||
UngebundenLegend = new LegendItem() {
|
|
||||||
Label = "Ungebunden",
|
|
||||||
LineWidth = 1,
|
|
||||||
LineColor = ColorUngebunden,
|
|
||||||
Marker = new MarkerStyle(MarkerShape.FilledCircle, 5, ColorUngebunden)
|
|
||||||
};
|
|
||||||
|
|
||||||
GebundenLegend = new LegendItem() {
|
|
||||||
Label = "Gebunden",
|
|
||||||
LineWidth = 1,
|
|
||||||
LineColor = ColorGebunden,
|
|
||||||
Marker = new MarkerStyle(MarkerShape.FilledCircle, 5, ColorGebunden)
|
|
||||||
};
|
|
||||||
|
|
||||||
LDWLegend = new LegendItem() {
|
|
||||||
Label = "68 °Oe (LDW)",
|
|
||||||
LineWidth = 2,
|
|
||||||
LineColor = Colors.Red,
|
|
||||||
Marker = MarkerStyle.None
|
|
||||||
};
|
|
||||||
|
|
||||||
QUWLegend = new LegendItem() {
|
|
||||||
Label = "73 °Oe (QUW)",
|
|
||||||
LineWidth = 2,
|
|
||||||
LineColor = Colors.Orange,
|
|
||||||
Marker = MarkerStyle.None
|
|
||||||
};
|
|
||||||
|
|
||||||
KABLegend = new LegendItem() {
|
|
||||||
Label = "84 °Oe (KAB)",
|
|
||||||
LineWidth = 2,
|
|
||||||
LineColor = Colors.Green,
|
|
||||||
Marker = MarkerStyle.None
|
|
||||||
};
|
|
||||||
|
|
||||||
RefreshGradationLines();
|
RefreshGradationLines();
|
||||||
|
|
||||||
if (SelectedGraphEntry?.GebundenGraph != null) {
|
if (SelectedGraphEntry?.GebundenGraph != null) {
|
||||||
@@ -230,7 +223,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
//OechslePricePlot.Plot.XAxis.ManualTickSpacing(1);
|
//OechslePricePlot.Plot.XAxis.ManualTickSpacing(1);
|
||||||
//OechslePricePlot.Plot.YAxis.ManualTickSpacing(0.1);
|
//OechslePricePlot.Plot.YAxis.ManualTickSpacing(0.1);
|
||||||
OechslePricePlot.Plot.Axes.SetLimits(Math.Min(GraphEntry.MinX, GraphEntry.MinXGeb) - 1, GraphEntry.MaxX + 1, -0.1, 2);
|
OechslePricePlot.Plot.Axes.SetLimits(Math.Min(GraphEntry.MinX, GraphEntry.MinXGeb) - 1, GraphEntry.MaxX + 1, -0.1, 1.5);
|
||||||
|
|
||||||
//OechslePricePlot.Plot.Layout(padding: 0);
|
//OechslePricePlot.Plot.Layout(padding: 0);
|
||||||
//OechslePricePlot.Plot.XAxis2.Layout(padding: 0);
|
//OechslePricePlot.Plot.XAxis2.Layout(padding: 0);
|
||||||
@@ -317,7 +310,7 @@ namespace Elwig.Windows {
|
|||||||
OechslePricePlot.Plot.Axes.Rules.Clear();
|
OechslePricePlot.Plot.Axes.Rules.Clear();
|
||||||
OechslePricePlot.Plot.Axes.Rules.Add(BoundaryRule);
|
OechslePricePlot.Plot.Axes.Rules.Add(BoundaryRule);
|
||||||
OechslePricePlot.Plot.Axes.Rules.Add(SpanRule);
|
OechslePricePlot.Plot.Axes.Rules.Add(SpanRule);
|
||||||
OechslePricePlot.Plot.Axes.SetLimits(GraphEntry.MinX - 1, GraphEntry.MaxX + 1, -0.1, 2);
|
OechslePricePlot.Plot.Axes.SetLimits(GraphEntry.MinX - 1, GraphEntry.MaxX + 1, -0.1, 1.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UnlockZoom() {
|
private void UnlockZoom() {
|
||||||
@@ -372,9 +365,9 @@ namespace Elwig.Windows {
|
|||||||
OechslePricePlot.Plot.Legend.Location = Alignment.UpperLeft;
|
OechslePricePlot.Plot.Legend.Location = Alignment.UpperLeft;
|
||||||
OechslePricePlot.Plot.Legend.IsVisible = true;
|
OechslePricePlot.Plot.Legend.IsVisible = true;
|
||||||
|
|
||||||
OechslePricePlot.Plot.Legend.ManualItems.Add(LDWLegend);
|
OechslePricePlot.Plot.Legend.ManualItems.Add(LdwLegend);
|
||||||
OechslePricePlot.Plot.Legend.ManualItems.Add(QUWLegend);
|
OechslePricePlot.Plot.Legend.ManualItems.Add(QuwLegend);
|
||||||
OechslePricePlot.Plot.Legend.ManualItems.Add(KABLegend);
|
OechslePricePlot.Plot.Legend.ManualItems.Add(KabLegend);
|
||||||
OechslePricePlot.Plot.Legend.ManualItems.Add(UngebundenLegend);
|
OechslePricePlot.Plot.Legend.ManualItems.Add(UngebundenLegend);
|
||||||
if (SelectedGraphEntry?.GebundenGraph != null) OechslePricePlot.Plot.Legend.ManualItems.Add(GebundenLegend);
|
if (SelectedGraphEntry?.GebundenGraph != null) OechslePricePlot.Plot.Legend.ManualItems.Add(GebundenLegend);
|
||||||
}
|
}
|
||||||
@@ -481,10 +474,10 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
if (HoverActive) {
|
if (HoverActive) {
|
||||||
if (PaymentVar.TestVariant && Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl)) {
|
if (PaymentVar.TestVariant && Keyboard.IsKeyDown(System.Windows.Input.Key.LeftCtrl)) {
|
||||||
if (PrimaryMarkedPoint == -1 || ActiveGraph == null || ActiveGraph != Highlighted.graph) {
|
if (PrimaryMarkedPoint == -1 || ActiveGraph == null || ActiveGraph != Highlighted.Graph) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SecondaryMarkedPoint = Highlighted.index;
|
SecondaryMarkedPoint = Highlighted.Index;
|
||||||
|
|
||||||
ChangeMarker(SecondaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(SecondaryMarkedPoint), ActiveGraph.GetPriceAt(SecondaryMarkedPoint));
|
ChangeMarker(SecondaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(SecondaryMarkedPoint), ActiveGraph.GetPriceAt(SecondaryMarkedPoint));
|
||||||
|
|
||||||
@@ -493,13 +486,13 @@ namespace Elwig.Windows {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrimaryMarkedPoint = Highlighted.index;
|
PrimaryMarkedPoint = Highlighted.Index;
|
||||||
if (ActiveGraph != Highlighted.graph) ChangeActiveGraph(Highlighted.graph);
|
if (ActiveGraph != Highlighted.Graph) ChangeActiveGraph(Highlighted.Graph);
|
||||||
|
|
||||||
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
ChangeMarker(PrimaryMarkedPointPlot, true, ActiveGraph.GetOechsleAt(PrimaryMarkedPoint), ActiveGraph.GetPriceAt(PrimaryMarkedPoint));
|
||||||
|
|
||||||
OechsleInput.Text = Highlighted.graph.GetOechsleAt(Highlighted.index).ToString();
|
OechsleInput.Text = Highlighted.Graph.GetOechsleAt(Highlighted.Index).ToString();
|
||||||
PriceInput.Text = Highlighted.graph.GetPriceAt(Highlighted.index).ToString();
|
PriceInput.Text = Highlighted.Graph.GetPriceAt(Highlighted.Index).ToString();
|
||||||
|
|
||||||
EnableActionButtons();
|
EnableActionButtons();
|
||||||
} else {
|
} else {
|
||||||
@@ -622,8 +615,8 @@ namespace Elwig.Windows {
|
|||||||
if (SelectedGraphEntry == null) return;
|
if (SelectedGraphEntry == null) return;
|
||||||
|
|
||||||
var r = MessageBox.Show(
|
var r = MessageBox.Show(
|
||||||
$"Soll der Graph {SelectedGraphEntry.Id} (verwendet in folgenden Verträgen: {SelectedGraphEntry.ContractsStringSimple}) wirklich gelöscht werden?",
|
$"Soll die Kurve {SelectedGraphEntry.Id} (verwendet in folgenden Verträgen: {SelectedGraphEntry.VaributeStringSimple}) wirklich gelöscht werden?",
|
||||||
"Graph löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
"Kurve löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
|
|
||||||
if (r == MessageBoxResult.Yes) {
|
if (r == MessageBoxResult.Yes) {
|
||||||
GraphEntries.Remove(SelectedGraphEntry);
|
GraphEntries.Remove(SelectedGraphEntry);
|
||||||
@@ -635,7 +628,8 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private async void SaveButton_Click(object sender, RoutedEventArgs e) {
|
private async void SaveButton_Click(object sender, RoutedEventArgs e) {
|
||||||
var origData = BillingData.FromJson(PaymentVar.Data);
|
var origData = BillingData.FromJson(PaymentVar.Data);
|
||||||
var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetAttributeVarieties(Context, Year, true));
|
var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetVaributes(Context, Year, withSlash: true),
|
||||||
|
AllVaributesAssigned, AllVaributesAssignedAbgew);
|
||||||
|
|
||||||
EntityEntry<PaymentVar>? tr = null;
|
EntityEntry<PaymentVar>? tr = null;
|
||||||
try {
|
try {
|
||||||
@@ -715,32 +709,45 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContractInput_Changed(object sender, ItemSelectionChangedEventArgs e) {
|
private void VaributeInput_Changed(object sender, ItemSelectionChangedEventArgs e) {
|
||||||
if (FillingInputs) return;
|
if (FillingInputs || e.Item is not Varibute v) return;
|
||||||
if (e.IsSelected == true) {
|
var isOpen = VaributeInput.IsDropDownOpen;
|
||||||
bool success = RemoveContractFromOtherGraphEntries(e.Item.ToString());
|
if (e.IsSelected) {
|
||||||
if (!success) {
|
if (RemoveVaributeFromOthers(e.Item.ToString())) {
|
||||||
ContractInput.SelectedItems.Remove(e.Item);
|
if (AbgewertetInput.IsChecked == true) {
|
||||||
|
v.AssignedAbgewGraphId = SelectedGraphEntry?.Id;
|
||||||
|
} else {
|
||||||
|
v.AssignedGraphId = SelectedGraphEntry?.Id;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
VaributeInput.SelectedItems.Remove(e.Item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (AbgewertetInput.IsChecked == true) {
|
||||||
|
v.AssignedAbgewGraphId = null;
|
||||||
|
} else {
|
||||||
|
v.AssignedGraphId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var r = ContractInput.SelectedItems.Cast<ContractSelection>();
|
SelectedGraphEntry!.Vaributes = VaributeInput.SelectedItems.Cast<Varibute>().ToList();
|
||||||
SelectedGraphEntry!.Contracts = r.ToList();
|
|
||||||
SetHasChanged();
|
SetHasChanged();
|
||||||
GraphList.Items.Refresh();
|
GraphList.Items.Refresh();
|
||||||
|
VaributeInput.Items.Refresh();
|
||||||
|
VaributeInput.IsDropDownOpen = isOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool RemoveContractFromOtherGraphEntries(string? contract) {
|
private bool RemoveVaributeFromOthers(string? varibute) {
|
||||||
if (contract == null) return true;
|
if (varibute == null) return true;
|
||||||
foreach (var ge in GraphEntries) {
|
foreach (var ge in GraphEntries) {
|
||||||
if (ge != SelectedGraphEntry && ge.Abgewertet == SelectedGraphEntry?.Abgewertet) {
|
if (ge != SelectedGraphEntry && ge.Abgewertet == SelectedGraphEntry?.Abgewertet) {
|
||||||
var toRemove = ge.Contracts.Where(c => c.Listing.Equals(contract)).ToList();
|
var toRemove = ge.Vaributes.Where(c => c.Listing.Equals(varibute)).ToList();
|
||||||
if (toRemove.Count == 0) continue;
|
if (toRemove.Count == 0) continue;
|
||||||
var r = MessageBox.Show($"Achtung: {string.Join(", ", toRemove)} ist bereits in Graph {ge.Id} in Verwendung!\nSoll die Zuweisung dort entfernt werden?", "Entfernen bestätigen",
|
var r = MessageBox.Show($"Achtung: {string.Join(", ", toRemove)} ist bereits in Kurve {ge.Id} in Verwendung!\nSoll die Zuweisung dort entfernt werden?", "Entfernen bestätigen",
|
||||||
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||||
if (r != MessageBoxResult.Yes) {
|
if (r != MessageBoxResult.Yes) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ge.Contracts.RemoveAll(c => c.Listing.Equals(contract));
|
ge.Vaributes.RemoveAll(c => c.Listing.Equals(varibute));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ namespace Elwig.Windows {
|
|||||||
v.Name = "Neue Auszahlungsvariante";
|
v.Name = "Neue Auszahlungsvariante";
|
||||||
v.TestVariant = true;
|
v.TestVariant = true;
|
||||||
v.DateString = $"{DateTime.Today:yyyy-MM-dd}";
|
v.DateString = $"{DateTime.Today:yyyy-MM-dd}";
|
||||||
v.Data = "{\"mode\": \"elwig\", \"version\": 1, \"payment\": 1.0, \"quality\": {\"WEI\": 0}, \"curves\": []}";
|
v.Data = "{\"mode\": \"elwig\", \"version\": 1, \"payment\": {}, \"curves\": []}";
|
||||||
|
|
||||||
await Context.AddAsync(v);
|
await Context.AddAsync(v);
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
::mkdir "C:\Program Files\Elwig"
|
::mkdir "C:\Program Files\Elwig"
|
||||||
::curl -s "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "C:\Program Files\Elwig\PDFtoPrinter.exe" -o "C:\Program Files\Elwig\PDFtoPrinter.exe"
|
::curl -s -L "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "C:\Program Files\Elwig\PDFtoPrinter.exe" -o "C:\Program Files\Elwig\PDFtoPrinter.exe"
|
||||||
mkdir "C:\ProgramData\Elwig\resources"
|
mkdir "C:\ProgramData\Elwig\resources"
|
||||||
copy /b /y Documents\*.css "C:\ProgramData\Elwig\resources"
|
copy /b /y Documents\*.css "C:\ProgramData\Elwig\resources"
|
||||||
copy /b /y Documents\*.cshtml "C:\ProgramData\Elwig\resources"
|
copy /b /y Documents\*.cshtml "C:\ProgramData\Elwig\resources"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
</Task>
|
</Task>
|
||||||
</UsingTask>
|
</UsingTask>
|
||||||
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
|
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
|
||||||
<Exec Command="curl -s "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "$(TargetDir)PDFtoPrinter.exe" -o "$(TargetDir)PDFtoPrinter.exe"" />
|
<Exec Command="curl -s -L "http://www.columbia.edu/~em36/PDFtoPrinter.exe" -z "$(TargetDir)PDFtoPrinter.exe" -o "$(TargetDir)PDFtoPrinter.exe"" />
|
||||||
<Exec Command="dotnet publish "$(SolutionDir)Elwig\Elwig.csproj" "/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml"" />
|
<Exec Command="dotnet publish "$(SolutionDir)Elwig\Elwig.csproj" "/p:PublishProfile=$(SolutionDir)\Elwig\Properties\PublishProfiles\FolderProfile.pubxml"" />
|
||||||
<GetFileVersion AssemblyPath="..\Elwig\bin\Publish\Elwig.exe">
|
<GetFileVersion AssemblyPath="..\Elwig\bin\Publish\Elwig.exe">
|
||||||
<Output TaskParameter="Version" PropertyName="ElwigFileVersion" />
|
<Output TaskParameter="Version" PropertyName="ElwigFileVersion" />
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@
|
|||||||
<Cultures>de-AT</Cultures>
|
<Cultures>de-AT</Cultures>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
|
<Target Name="CustomBeforeBuild" BeforeTargets="BeforeBuild">
|
||||||
<Exec Command='curl -L -s "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(TargetDir)MicrosoftEdgeWebview2Setup.exe" -o "$(TargetDir)MicrosoftEdgeWebview2Setup.exe"' />
|
<Exec Command='curl -s -L "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -z "$(TargetDir)MicrosoftEdgeWebview2Setup.exe" -o "$(TargetDir)MicrosoftEdgeWebview2Setup.exe"' />
|
||||||
<Exec Command='curl -L -s "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(TargetDir)VC_redist.x86.exe" -o "$(TargetDir)VC_redist.x86.exe"' />
|
<Exec Command='curl -s -L "https://aka.ms/vs/17/release/vc_redist.x86.exe" -z "$(TargetDir)VC_redist.x86.exe" -o "$(TargetDir)VC_redist.x86.exe"' />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DefineConstants>ElwigProjectDir=..\Elwig</DefineConstants>
|
<DefineConstants>ElwigProjectDir=..\Elwig</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Tests.HelperTests {
|
|||||||
public class BillingDataTest {
|
public class BillingDataTest {
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||||
private static readonly string[] AttributeVariants = ["GV", "GVD", "GVK", "GVS", "GVZ", "WR", "WRS", "ZW", "ZWS", "ZWZ"];
|
private static readonly string[] Vaributes = ["GV", "GVD", "GVK", "GVS", "GVZ", "WR", "WRS", "ZW", "ZWS", "ZWZ"];
|
||||||
|
|
||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
public async Task SetupBilling() {
|
public async Task SetupBilling() {
|
||||||
@@ -52,7 +52,7 @@ namespace Tests.HelperTests {
|
|||||||
"payment": 0.5,
|
"payment": 0.5,
|
||||||
"curves": []
|
"curves": []
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcOe(data, "GV", 73, 0.5m);
|
TestCalcOe(data, "GV", 73, 0.5m);
|
||||||
TestCalcOe(data, "WRS", 74, 0.5m);
|
TestCalcOe(data, "WRS", 74, 0.5m);
|
||||||
@@ -77,7 +77,7 @@ namespace Tests.HelperTests {
|
|||||||
"geb": 0.10
|
"geb": 0.10
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcOe(data, "GV", 70, 0.25m);
|
TestCalcOe(data, "GV", 70, 0.25m);
|
||||||
TestCalcOe(data, "GV", 72, 0.25m);
|
TestCalcOe(data, "GV", 72, 0.25m);
|
||||||
@@ -114,7 +114,7 @@ namespace Tests.HelperTests {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcKmw(data, "GV", 13.00, 0.10m);
|
TestCalcKmw(data, "GV", 13.00, 0.10m);
|
||||||
TestCalcKmw(data, "GV", 13.50, 0.10m);
|
TestCalcKmw(data, "GV", 13.50, 0.10m);
|
||||||
@@ -148,7 +148,7 @@ namespace Tests.HelperTests {
|
|||||||
},
|
},
|
||||||
"curves": []
|
"curves": []
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcOe(data, "WR", 73, 0.10m);
|
TestCalcOe(data, "WR", 73, 0.10m);
|
||||||
TestCalcOe(data, "WRS", 73, 0.15m);
|
TestCalcOe(data, "WRS", 73, 0.15m);
|
||||||
@@ -179,7 +179,7 @@ namespace Tests.HelperTests {
|
|||||||
},
|
},
|
||||||
"curves": []
|
"curves": []
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcOe(data, "GV", 75, 0.30m, qualid: "WEI");
|
TestCalcOe(data, "GV", 75, 0.30m, qualid: "WEI");
|
||||||
TestCalcOe(data, "ZW", 76, 0.25m, qualid: "WEI");
|
TestCalcOe(data, "ZW", 76, 0.25m, qualid: "WEI");
|
||||||
@@ -221,7 +221,7 @@ namespace Tests.HelperTests {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcKmw(data, "GV", 15.0, 2.0m);
|
TestCalcKmw(data, "GV", 15.0, 2.0m);
|
||||||
TestCalcKmw(data, "GV", 15.5, 2.272727m);
|
TestCalcKmw(data, "GV", 15.5, 2.272727m);
|
||||||
@@ -281,7 +281,7 @@ namespace Tests.HelperTests {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcKmw(data, "GV", 15.0, 0.75m);
|
TestCalcKmw(data, "GV", 15.0, 0.75m);
|
||||||
TestCalcKmw(data, "GVS", 15.0, 0.50m);
|
TestCalcKmw(data, "GVS", 15.0, 0.50m);
|
||||||
@@ -340,7 +340,7 @@ namespace Tests.HelperTests {
|
|||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
""", AttributeVariants);
|
""", Vaributes);
|
||||||
Assert.Multiple(() => {
|
Assert.Multiple(() => {
|
||||||
TestCalcOe(data, "GVK", 73, 0.032m);
|
TestCalcOe(data, "GVK", 73, 0.032m);
|
||||||
TestCalcOe(data, "ZWS", 74, 0.033m);
|
TestCalcOe(data, "ZWS", 74, 0.033m);
|
||||||
@@ -349,11 +349,11 @@ namespace Tests.HelperTests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ContractSelection> GetSelection(IEnumerable<string> attVars) {
|
private static List<Varibute> GetSelection(IEnumerable<string> attVars) {
|
||||||
return attVars.Select(s => {
|
return attVars.Select(s => {
|
||||||
var sortid = s[..2];
|
var sortid = s[..2];
|
||||||
var attrid = s.Length > 2 ? s[2..] : null;
|
var attrid = s.Length > 2 ? s[2..] : null;
|
||||||
return new ContractSelection(
|
return new Varibute(
|
||||||
new WineVar(sortid, sortid),
|
new WineVar(sortid, sortid),
|
||||||
attrid == null ? null : new WineAttr(attrid, attrid)
|
attrid == null ? null : new WineAttr(attrid, attrid)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
curl -s "https://www.necronda.net/elwig/files/create.sql?v=13" -u "elwig:ganzGeheim123!" -o "Resources\Create.sql"
|
curl -s -L "https://www.necronda.net/elwig/files/create.sql?v=13" -u "elwig:ganzGeheim123!" -o "Resources\Create.sql"
|
||||||
|
|||||||
Reference in New Issue
Block a user