diff --git a/Elwig/Documents/BusinessDocument.cs b/Elwig/Documents/BusinessDocument.cs index 3399758..37d3de6 100644 --- a/Elwig/Documents/BusinessDocument.cs +++ b/Elwig/Documents/BusinessDocument.cs @@ -77,13 +77,13 @@ namespace Elwig.Documents { .AddCell(NewAsideCell("Betr.-Nr.:", 6, isName: true)).AddCell(NewAsideCell(Member.LfbisNr ?? "-", 6, right: true, center: Member.LfbisNr == null)) .AddCell(NewAsideCell("OOC-ID:", 6, isName: true)).AddCell(NewAsideCell(Member.OrganicOperatorId ?? "-", 8, right: true, center: Member.OrganicOperatorId == null)) .AddCell(NewAsideCell("UID:", 6, isName: true)).AddCell(NewAsideCell(Member.UstIdNr ?? "-", 10, right: true, center: Member.UstIdNr == null)) - .AddCell(NewAsideCell(new KernedParagraph("", 10).Add(Italic(Member.IsBuchführend ? "(buchführend)" : "(pauschaliert)")), 10, center: true)); + .AddCell(NewAsideCell(new KernedParagraph("", 10).Add(Italic(Member.IsAccounting ? "(buchführend)" : "(pauschaliert)")), 10, center: true)); } else { Aside .AddCell(NewAsideCell("Mitglieds-Nr.:", 12, isName: true)).AddCell(NewAsideCell($"{Member.MgNr}", 4, right: true)).AddCell(NewAsideCell("", 10)) .AddCell(NewAsideCell("Betriebs-Nr.:", 10, isName: true)).AddCell(NewAsideCell(Member.LfbisNr ?? "-", 6, right: true, center: Member.LfbisNr == null)).AddCell(NewAsideCell("", 10)) .AddCell(NewAsideCell("UID:", 6, isName: true)).AddCell(NewAsideCell(Member.UstIdNr ?? "-", 10, right: true, center: Member.UstIdNr == null)) - .AddCell(NewAsideCell(new KernedParagraph("", 10).Add(Italic(Member.IsBuchführend ? "(buchführend)" : "(pauschaliert)")), 10, center: true)); + .AddCell(NewAsideCell(new KernedParagraph("", 10).Add(Italic(Member.IsAccounting ? "(buchführend)" : "(pauschaliert)")), 10, center: true)); } } diff --git a/Elwig/Documents/MemberDataSheet.cs b/Elwig/Documents/MemberDataSheet.cs index be2b87a..0ec7d7d 100644 --- a/Elwig/Documents/MemberDataSheet.cs +++ b/Elwig/Documents/MemberDataSheet.cs @@ -158,8 +158,8 @@ namespace Elwig.Documents { .AddCell(NewDataTh("Betriebs-Nr.:")).AddCell(NewTd(Member.LfbisNr)) .AddCell(NewDataTh("UID:", colspan: 2)).AddCell(NewTd(Member.UstIdNr, colspan: 2)) .AddCell(NewDataTh("Stammgemeinde:")).AddCell(NewTd(Member.DefaultKg?.Name)) - .AddCell(NewDataTh("Buchführend:", colspan: 2)).AddCell(NewTd(new KernedParagraph(Member.IsBuchführend ? "Ja " : "Nein ", 10) - .Add(Normal($"({(Member.IsBuchführend ? season.VatNormal : season.VatFlatrate) * 100:N0}% USt.)", 8)), colspan: 2)) + .AddCell(NewDataTh("Buchführend:", colspan: 2)).AddCell(NewTd(new KernedParagraph(Member.IsAccounting ? "Ja " : "Nein ", 10) + .Add(Normal($"({(Member.IsAccounting ? season.VatNormal : season.VatFlatrate) * 100:N0}% USt.)", 8)), colspan: 2)) .AddCell(NewDataTh("(Katastralgemeinde mit dem größten Anteil an Weinbauflächen)", 8, colspan: 2)) .AddCell(NewDataTh("Bio:", colspan: 2)).AddCell(NewTd(new KernedParagraph(Member.IsOrganic ? "Ja" : "Nein", 10) .Add(Normal(Member.OrganicAuthorityCode != null || Member.OrganicOperatorId != null ? $" ({Member.OrganicAuthorityCode}{(Member.OrganicAuthorityCode != null && Member.OrganicOperatorId != null ? ", " : "")}{Member.OrganicOperatorId})" : "", 8)), colspan: 2)) @@ -168,11 +168,11 @@ namespace Elwig.Documents { .Add(Normal("(" + (Member.ExitDate != null ? $"{Member.EntryDate:dd.MM.yyyy}\u2013{Member.ExitDate:dd.MM.yyyy}" : $"seit {Member.EntryDate:dd.MM.yyyy}") + ")", 8)))) .AddCell(NewDataTh("Geschäftsanteile:", colspan: 2)).AddCell(NewTd(shares, colspan: 2)) .AddCell(NewDataTh("Stamm-Zweigstelle:")).AddCell(NewTd(Member.Branch?.Name)) - .AddCell(NewDataTh("Volllieferant:", colspan: 2)).AddCell(NewTd(Member.IsVollLieferant ? "Ja" : "Nein", colspan: 2)) + .AddCell(NewDataTh("Vollablieferer:", colspan: 2)).AddCell(NewTd(Member.IsFullDelivery ? "Ja" : "Nein", colspan: 2)) .AddCell(NewDataTh("Zusendungen per\u2026")).AddCell(NewTd(new KernedParagraph(10) .Add(Italic("Post:")).Add(Normal(Member.ContactViaPost ? " Ja \u2013 " : " Nein \u2013 ")) .Add(Italic("E-Mail:")).Add(Normal(Member.ContactViaEmail ? " Ja" : " Nein")))) - .AddCell(NewDataTh("Funktionär:", colspan: 2)).AddCell(NewTd(Member.IsFunktionär ? "Ja" : "Nein", colspan: 2)); + .AddCell(NewDataTh("Funktionär:", colspan: 2)).AddCell(NewTd(Member.IsOfficer ? "Ja" : "Nein", colspan: 2)); return tbl; } diff --git a/Elwig/Documents/PaymentVariantSummary.cs b/Elwig/Documents/PaymentVariantSummary.cs index 0fad8d9..3b87e41 100644 --- a/Elwig/Documents/PaymentVariantSummary.cs +++ b/Elwig/Documents/PaymentVariantSummary.cs @@ -108,16 +108,16 @@ namespace Elwig.Documents { var totalSum = _credits.Sum(p => p.Amount); var weiRows = data.Rows.Where(r => r.QualityLevel == "Wein"); - var minWei = weiRows.Min(r => r.Ungeb.MinPrice); - var maxWei = weiRows.Max(r => r.Ungeb.MaxPrice); + var minWei = weiRows.Min(r => r.UnCtrd.MinPrice); + var maxWei = weiRows.Max(r => r.UnCtrd.MaxPrice); var quwRows = data.Rows.Where(r => r.QualityLevel != "Wein"); - var minPrice = quwRows.Min(r => r.Ungeb.MinPrice); - var maxPrice = quwRows.Max(r => r.Ungeb.MaxPrice); - var gebRows = data.Rows - .Where(r => r.Geb.MaxPrice != null && r.Ungeb.MinPrice != null) - .Select(r => r.Geb.MaxPrice - r.Ungeb.MinPrice); - var minGeb = gebRows.Min(); - var maxGeb = gebRows.Max(); + var minPrice = quwRows.Min(r => r.UnCtrd.MinPrice); + var maxPrice = quwRows.Max(r => r.UnCtrd.MaxPrice); + var ctrdRows = data.Rows + .Where(r => r.Ctrd.MaxPrice != null && r.UnCtrd.MinPrice != null) + .Select(r => r.Ctrd.MaxPrice - r.UnCtrd.MinPrice); + var minCtrd = ctrdRows.Min(); + var maxCtrd = ctrdRows.Max(); tbl.AddCell(NewSectionHdr("Allgemein", colspan: 5)) .AddCell(NewSectionHdr("Berücksichtigt", colspan: 3, borderLeft: true)) @@ -197,7 +197,7 @@ namespace Elwig.Documents { .AddCell(NewTd(CurrencySymbol)) .AddCell(NewTd($"{Math.Abs(vat):N2}", right: true)) .AddCell(NewSectionTh("Gebunden-Zuschlag:", borderLeft: true)) - .AddCell(NewTd(minGeb == null && maxGeb == null ? "-" : minGeb != maxGeb ? $"{minGeb:N4}\u2013{maxGeb:N4} {CurrencySymbol}/kg" : minGeb == 0 ? "-" : $"{minGeb:N4} {CurrencySymbol}/kg", colspan: 2, center: true)) + .AddCell(NewTd(minCtrd == null && maxCtrd == null ? "-" : minCtrd != maxCtrd ? $"{minCtrd:N4}\u2013{maxCtrd:N4} {CurrencySymbol}/kg" : minCtrd == 0 ? "-" : $"{minCtrd:N4} {CurrencySymbol}/kg", colspan: 2, center: true)) .AddCell(NewSectionTh("Bruttosumme:", colspan: 2)) .AddCell(NewTd(borderTop: true)) @@ -211,21 +211,21 @@ namespace Elwig.Documents { .AddCell(NewTd(CurrencySymbol)) .AddCell(NewTd($"{Math.Abs(totalMods):N2}", right: true)) .AddCell(NewSectionTh("Menge (ungebunden):", borderLeft: true, borderTop: true)) - .AddCell(NewTd($"{data.Rows.Sum(r => r.Ungeb.Weight):N0} kg", colspan: 2, right: true, borderTop: true)) + .AddCell(NewTd($"{data.Rows.Sum(r => r.UnCtrd.Weight):N0} kg", colspan: 2, right: true, borderTop: true)) .AddCell(NewSectionTh("Bereits berücksichtigte Abzüge:", colspan: 2)) .AddCell(NewTd(Utils.GetSign(considered))) .AddCell(NewTd(CurrencySymbol)) .AddCell(NewTd($"{Math.Abs(considered):N2}", right: true)) .AddCell(NewSectionTh("Menge (gebunden):", borderLeft: true)) - .AddCell(NewTd($"{data.Rows.Sum(r => r.Geb.Weight + r.LowGeb.Weight):N0} kg", colspan: 2, right: true)) + .AddCell(NewTd($"{data.Rows.Sum(r => r.Ctrd.Weight + r.LowCtrd.Weight):N0} kg", colspan: 2, right: true)) .AddCell(NewSectionTh("Auszahlungsbetrag:", colspan: 2)) .AddCell(NewTd(borderTop: true)) .AddCell(NewTd(CurrencySymbol, borderTop: true)) .AddCell(NewTd($"{totalSum:N2}", right: true, borderTop: true)) .AddCell(NewSectionTh("Gesamtmenge:", borderLeft: true)) - .AddCell(NewTd($"{data.Rows.Sum(r => r.Ungeb.Weight + r.LowGeb.Weight + r.Geb.Weight):N0} kg", colspan: 2, right: true, borderTop: true)); + .AddCell(NewTd($"{data.Rows.Sum(r => r.UnCtrd.Weight + r.LowCtrd.Weight + r.Ctrd.Weight):N0} kg", colspan: 2, right: true, borderTop: true)); return tbl; } @@ -290,22 +290,22 @@ namespace Elwig.Documents { .ToList(); var border = lastHdr != null; tbl.AddCell(NewTd(hdr, colspan: 2, bold: true, italic: true, borderTop: border)) - .AddCell(NewTd($"{rows.Sum(r => r.Ungeb.Weight):N0}", right: true, bold: true, borderTop: border)) + .AddCell(NewTd($"{rows.Sum(r => r.UnCtrd.Weight):N0}", right: true, bold: true, borderTop: border)) .AddCell(NewTd(borderTop: border)) - .AddCell(NewTd($"{rows.Sum(r => r.LowGeb.Weight):N0}", right: true, bold: true, borderTop: border)) + .AddCell(NewTd($"{rows.Sum(r => r.LowCtrd.Weight):N0}", right: true, bold: true, borderTop: border)) .AddCell(NewTd(borderTop: border)) - .AddCell(NewTd($"{rows.Sum(r => r.Geb.Weight):N0}", right: true, bold: true, borderTop: border)) + .AddCell(NewTd($"{rows.Sum(r => r.Ctrd.Weight):N0}", right: true, bold: true, borderTop: border)) .AddCell(NewTd(borderTop: border)) .AddCell(NewTd($"{rows.Sum(r => r.Amount):N2}", right: true, bold: true, borderTop: border)); } tbl.AddCell(NewTd(row.QualityLevel)) .AddCell(NewTd($"{row.Oe:N0}", center: true)) - .AddCell(NewTd(row.Ungeb.Weight != 0 ? $"{row.Ungeb.Weight:N0}" : "-", right: true)) - .AddCell(NewTd(row.Ungeb.MaxPrice != null ? $"{row.Ungeb.MaxPrice:N4}" : "-", right: true)) - .AddCell(NewTd(row.LowGeb.Weight != 0 ? $"{row.LowGeb.Weight:N0}" : "-", right: true)) - .AddCell(NewTd(row.LowGeb.MaxPrice != null ? $"{row.LowGeb.MaxPrice:N4}" : "-", right: true)) - .AddCell(NewTd(row.Geb.Weight != 0 ? $"{row.Geb.Weight:N0}" : "-", right: true)) - .AddCell(NewTd(row.Geb.MaxPrice != null ? $"{row.Geb.MaxPrice:N4}" : "-", right: true)) + .AddCell(NewTd(row.UnCtrd.Weight != 0 ? $"{row.UnCtrd.Weight:N0}" : "-", right: true)) + .AddCell(NewTd(row.UnCtrd.MaxPrice != null ? $"{row.UnCtrd.MaxPrice:N4}" : "-", right: true)) + .AddCell(NewTd(row.LowCtrd.Weight != 0 ? $"{row.LowCtrd.Weight:N0}" : "-", right: true)) + .AddCell(NewTd(row.LowCtrd.MaxPrice != null ? $"{row.LowCtrd.MaxPrice:N4}" : "-", right: true)) + .AddCell(NewTd(row.Ctrd.Weight != 0 ? $"{row.Ctrd.Weight:N0}" : "-", right: true)) + .AddCell(NewTd(row.Ctrd.MaxPrice != null ? $"{row.Ctrd.MaxPrice:N4}" : "-", right: true)) .AddCell(NewTd($"{row.Amount:N2}", right: true)); lastHdr = hdr; } diff --git a/Elwig/Helpers/Billing/Billing.cs b/Elwig/Helpers/Billing/Billing.cs index 82cc891..e104730 100644 --- a/Elwig/Helpers/Billing/Billing.cs +++ b/Elwig/Helpers/Billing/Billing.cs @@ -77,13 +77,13 @@ namespace Elwig.Helpers.Billing { } public async Task CalculateBuckets( - bool? honorGebundenField = null, + bool? honorContractedField = null, bool? allowAttributesIntoLower = null, bool? avoidUnderDeliveries = null, SqliteConnection? cnx = null ) { using var ctx = new AppDbContext(); - var honorGebunden = honorGebundenField ?? Season.Billing_HonorGebunden; + var honorContracted = honorContractedField ?? Season.Billing_HonorContracted; var allowAttrsIntoLower = allowAttributesIntoLower ?? Season.Billing_AllowAttrsIntoLower; var avoidUnderDlvrs = avoidUnderDeliveries ?? Season.Billing_AvoidUnderDeliveries; var attrVals = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => (a.IsStrict, a.FillLower)); @@ -96,10 +96,10 @@ namespace Elwig.Helpers.Billing { var deliveries = new List<(int, int, int, string, int, double, string, string?, string[], bool?)>(); using (var cmd = cnx.CreateCommand()) { cmd.CommandText = $""" - SELECT mgnr, did, dpnr, sortid, weight, kmw, qualid, attrid, modifiers, gebunden + SELECT mgnr, did, dpnr, sortid, weight, kmw, qualid, attrid, modifiers, contracted FROM v_delivery WHERE year = {Year} - ORDER BY mgnr, sortid, abgewertet ASC, {(honorGebunden ? "gebunden IS NOT NULL DESC, gebunden DESC," : "")} + ORDER BY mgnr, sortid, abgewertet ASC, {(honorContracted ? "contracted IS NOT NULL DESC, contracted DESC," : "")} attribute_prio DESC, COALESCE(attrid, '~'), kmw DESC, lsnr, dpnr """; using var reader = await cmd.ExecuteReaderAsync(); @@ -117,12 +117,12 @@ namespace Elwig.Helpers.Billing { int lastMgNr = 0; Dictionary? rightsAndObligations = null; Dictionary used = []; - foreach (var (mgnr, did, dpnr, sortid, weight, kmw, qualid, attrid, modifiers, gebunden) in deliveries) { + foreach (var (mgnr, did, dpnr, sortid, weight, kmw, qualid, attrid, modifiers, contracted) in deliveries) { if (lastMgNr != mgnr) { rightsAndObligations = await ctx.GetMemberAreaCommitmentBuckets(Year, mgnr); used = []; } - if ((honorGebunden && gebunden == false) || + if ((honorContracted && contracted == false) || rightsAndObligations == null || rightsAndObligations.Count == 0 || qualid == "WEI" || qualid == "RSW" || qualid == "LDW") { diff --git a/Elwig/Helpers/Billing/BillingData.cs b/Elwig/Helpers/Billing/BillingData.cs index 072ef97..2288bdc 100644 --- a/Elwig/Helpers/Billing/BillingData.cs +++ b/Elwig/Helpers/Billing/BillingData.cs @@ -14,7 +14,7 @@ namespace Elwig.Helpers.Billing { public enum CalculationMode { Elwig, WgMaster } public enum CurveMode { Oe, Kmw } - public record struct Curve(CurveMode Mode, Dictionary Normal, Dictionary? Gebunden); + public record struct Curve(CurveMode Mode, Dictionary Normal, Dictionary? Contracted); public static JsonSchema? Schema { get; private set; } @@ -179,10 +179,10 @@ namespace Elwig.Helpers.Billing { } else { throw new InvalidOperationException(); } - var geb = obj["geb"]; - if (geb is JsonObject) { - c2 = GetCurveData(geb.AsObject(), cMode); - } else if (geb?.AsValue().TryGetValue(out decimal v) == true) { + var ctrd = obj["ctrd"] ?? obj["geb"]; + if (ctrd is JsonObject) { + c2 = GetCurveData(ctrd.AsObject(), cMode); + } else if (ctrd?.AsValue().TryGetValue(out decimal v) == true) { var splitVal = GetCurveValueAt(c1, quw); c2 = c1.ToDictionary(e => e.Key, e => e.Value + (e.Key >= quw ? v : 0)); c2[quw] = splitVal + v; @@ -274,7 +274,7 @@ namespace Elwig.Helpers.Billing { protected static JsonNode GraphEntryToJson(GraphEntry entry) { try { - if (entry.GebundenFlatBonus == null) { + if (entry.ContractedFlatBonus == null) { return JsonValue.Create((decimal)entry.DataGraph.DataY.Distinct().Single()); } } catch { } @@ -286,10 +286,10 @@ namespace Elwig.Helpers.Billing { curve["data"] = GraphToJson(entry.DataGraph, entry.Mode.ToString().ToLower()); - if (entry.GebundenFlatBonus != null) { - curve["geb"] = (decimal)entry.GebundenFlatBonus; - } else if (entry.GebundenGraph != null) { - curve["geb"] = GraphToJson(entry.GebundenGraph, entry.Mode.ToString().ToLower()); + if (entry.ContractedFlatBonus != null) { + curve["ctrd"] = (decimal)entry.ContractedFlatBonus; + } else if (entry.ContractedGraph != null) { + curve["ctrd"] = GraphToJson(entry.ContractedGraph, entry.Mode.ToString().ToLower()); } return curve; diff --git a/Elwig/Helpers/Billing/BillingVariant.cs b/Elwig/Helpers/Billing/BillingVariant.cs index 3ba69d6..2d6f586 100644 --- a/Elwig/Helpers/Billing/BillingVariant.cs +++ b/Elwig/Helpers/Billing/BillingVariant.cs @@ -37,11 +37,11 @@ namespace Elwig.Helpers.Billing { return new BillingVariant(year, avnr, season, attributes, modifiers, areaComTypes, paymentVar, data); } - public async Task Calculate(bool strictPrices = true, bool? honorGebunden = null, bool? allowAttrsIntoLower = null, bool? avoidUnderDeliveries = null) { + public async Task Calculate(bool strictPrices = true, bool? honorContracted = null, bool? allowAttrsIntoLower = null, bool? avoidUnderDeliveries = null) { if (PaymentVariant == null || Data == null) throw new Exception("Call Load before Calculate"); using var cnx = await AppDbContext.ConnectAsync(); using var tx = await cnx.BeginTransactionAsync(); - await CalculateBuckets(honorGebunden, allowAttrsIntoLower, avoidUnderDeliveries, cnx); + await CalculateBuckets(honorContracted, allowAttrsIntoLower, avoidUnderDeliveries, cnx); await DeleteInDb(cnx); await SetCalcTime(cnx); KeyNotFoundException? exception = null; @@ -73,7 +73,7 @@ namespace Elwig.Helpers.Billing { v.avnr, ROUND(p.amount / POW(10, s.precision - 2)) AS net_amount, IIF(lc.amount < 0, 0, ROUND(lp.amount / POW(10, s.precision - 2))) AS prev_net_amount, - IIF(m.buchführend, s.vat_normal, s.vat_flatrate) AS vat, + IIF(m.accounting, s.vat_normal, s.vat_flatrate) AS vat, ROUND(IIF({Data.ConsiderTotalPenalty}, COALESCE(b.total_penalty, 0), 0) / POW(10, s.precision - 2)) + ROUND(IIF({Data.ConsiderContractPenalties}, COALESCE(u.total_penalty, 0), 0) / POW(10, 4 - 2)) + ROUND(IIF({Data.ConsiderAutoBusinessShares}, -COALESCE(a.total_amount, 0), 0)) + @@ -195,13 +195,13 @@ namespace Elwig.Helpers.Billing { foreach (var part in parts) { if (part.Value == 0) continue; - var ungeb = part.Discr == "_"; + var unctrd = part.Discr == "_"; var payAttrId = (part.Discr is "" or "_") ? null : part.Discr; var attrId = part.AttrAreaCom ? payAttrId : part.AttrId; - var geb = !ungeb && (payAttrId == attrId || !part.AttrAreaCom); + var ctrd = !unctrd && (payAttrId == attrId || !part.AttrAreaCom); decimal price = 0; try { - price = Data.CalculatePrice(part.SortId, attrId, part.CultId, part.QualId, geb, part.Oe, part.Kmw); + price = Data.CalculatePrice(part.SortId, attrId, part.CultId, part.QualId, ctrd, part.Oe, part.Kmw); } catch (KeyNotFoundException e) { invalid.Add(e.Message.Split('\'')[1]); } diff --git a/Elwig/Helpers/Billing/GraphEntry.cs b/Elwig/Helpers/Billing/GraphEntry.cs index d8486f8..648f2a3 100644 --- a/Elwig/Helpers/Billing/GraphEntry.cs +++ b/Elwig/Helpers/Billing/GraphEntry.cs @@ -7,7 +7,7 @@ namespace Elwig.Helpers.Billing { public class GraphEntry { public const int MinX = 50; - public const int MinXGeb = 73; + public const int MinXCtrd = 73; public const int MaxX = 120; public int Id { get; set; } @@ -15,11 +15,11 @@ namespace Elwig.Helpers.Billing { public bool Abgewertet { get; set; } public Graph DataGraph { get; set; } - public Graph? GebundenGraph { get; set; } - public double? GebundenFlatBonus { + public Graph? ContractedGraph { get; set; } + public double? ContractedFlatBonus { get { try { - var val = GebundenGraph?.DataX.Zip(GebundenGraph.DataY) + var val = ContractedGraph?.DataX.Zip(ContractedGraph.DataY) .Select(e => Math.Round(e.Second - DataGraph.GetPriceAtOe(e.First), Precision)) .Distinct() .Single(); @@ -30,10 +30,10 @@ namespace Elwig.Helpers.Billing { } set { if (value is not double v) return; - var values = Enumerable.Range(MinXGeb, MaxX - MinXGeb + 1) + var values = Enumerable.Range(MinXCtrd, MaxX - MinXCtrd + 1) .Select(i => Math.Round(DataGraph.GetPriceAtOe(i) + v, Precision)) .ToArray(); - GebundenGraph = new Graph(values, Precision, MinXGeb, MaxX); + ContractedGraph = new Graph(values, Precision, MinXCtrd, MaxX); } } @@ -52,39 +52,39 @@ namespace Elwig.Helpers.Billing { Vaributes = []; } - public GraphEntry(int id, int precision, BillingData.CurveMode mode, Dictionary data, Dictionary? gebunden) : + public GraphEntry(int id, int precision, BillingData.CurveMode mode, Dictionary data, Dictionary? contracted) : this(id, precision, mode) { DataGraph = new Graph(data, precision, MinX, MaxX); - if (gebunden != null) GebundenGraph = new Graph(gebunden, precision, MinXGeb, MaxX); + if (contracted != null) ContractedGraph = new Graph(contracted, precision, MinXCtrd, MaxX); } public GraphEntry(int id, int precision, BillingData.Curve curve, List vaributes) : this(id, precision, curve.Mode) { DataGraph = new Graph(curve.Normal, precision, MinX, MaxX); - if (curve.Gebunden != null) - GebundenGraph = new Graph(curve.Gebunden, precision, MinXGeb, MaxX); + if (curve.Contracted != null) + ContractedGraph = new Graph(curve.Contracted, precision, MinXCtrd, MaxX); Vaributes = vaributes; } - private GraphEntry(int id, int precision, BillingData.CurveMode mode, Graph dataGraph, Graph? gebundenGraph, List vaributes) { + private GraphEntry(int id, int precision, BillingData.CurveMode mode, Graph dataGraph, Graph? contractedGraph, List vaributes) { Id = id; Precision = precision; Mode = mode; DataGraph = dataGraph; - GebundenGraph = gebundenGraph; + ContractedGraph = contractedGraph; Vaributes = vaributes; } - public void AddGebundenGraph() { - GebundenGraph ??= new Graph(Precision, MinXGeb, MaxX); + public void AddContractedGraph() { + ContractedGraph ??= new Graph(Precision, MinXCtrd, MaxX); } - public void RemoveGebundenGraph() { - GebundenGraph = null; + public void RemoveContractedGraph() { + ContractedGraph = null; } public GraphEntry Copy(int id) { - return new GraphEntry(id, Precision, Mode, (Graph)DataGraph.Clone(), (Graph?)GebundenGraph?.Clone(), []); + return new GraphEntry(id, Precision, Mode, (Graph)DataGraph.Clone(), (Graph?)ContractedGraph?.Clone(), []); } } } diff --git a/Elwig/Helpers/Billing/PaymentBillingData.cs b/Elwig/Helpers/Billing/PaymentBillingData.cs index de50196..14b14b4 100644 --- a/Elwig/Helpers/Billing/PaymentBillingData.cs +++ b/Elwig/Helpers/Billing/PaymentBillingData.cs @@ -45,9 +45,9 @@ namespace Elwig.Helpers.Billing { return dict; } - public decimal CalculatePrice(string sortid, string? attrid, string? cultid, string qualid, bool gebunden, double oe, double kmw) { + public decimal CalculatePrice(string sortid, string? attrid, string? cultid, string qualid, bool contracted, double oe, double kmw) { var curve = GetQualityCurve(qualid, sortid, attrid, cultid) ?? GetCurve(sortid, attrid, cultid); - return GetCurveValueAt((gebunden ? curve.Gebunden : null) ?? curve.Normal, curve.Mode == CurveMode.Oe ? oe : kmw); + return GetCurveValueAt((contracted ? curve.Contracted : null) ?? curve.Normal, curve.Mode == CurveMode.Oe ? oe : kmw); } private Curve LookupCurve(JsonValue val) { diff --git a/Elwig/Helpers/Export/ElwigData.cs b/Elwig/Helpers/Export/ElwigData.cs index 2c0ca1b..0da4559 100644 --- a/Elwig/Helpers/Export/ElwigData.cs +++ b/Elwig/Helpers/Export/ElwigData.cs @@ -641,10 +641,10 @@ namespace Elwig.Helpers.Export { ["ooc_id"] = m.OrganicOperatorId, ["org_auth_code"] = m.OrganicAuthorityCode, ["juridical_pers"] = m.IsJuridicalPerson, - ["volllieferant"] = m.IsVollLieferant, - ["buchführend"] = m.IsBuchführend, + ["full_delivery"] = m.IsFullDelivery, + ["accounting"] = m.IsAccounting, ["organic"] = m.IsOrganic, - ["funktionär"] = m.IsFunktionär, + ["officer"] = m.IsOfficer, ["active"] = m.IsActive, ["deceased"] = m.IsDeceased, ["iban"] = m.Iban, @@ -715,10 +715,10 @@ namespace Elwig.Helpers.Export { OrganicOperatorId = json["ooc_id"]?.AsValue().GetValue(), OrganicAuthorityCode = json["org_auth_code"]?.AsValue().GetValue(), IsJuridicalPerson = json["juridical_pers"]?.AsValue().GetValue() ?? false, - IsVollLieferant = json["volllieferant"]?.AsValue().GetValue() ?? false, - IsBuchführend = json["buchführend"]?.AsValue().GetValue() ?? false, + IsFullDelivery = json["full_delivery"]?.AsValue().GetValue() ?? json["volllieferant"]?.AsValue().GetValue() ?? false, + IsAccounting = json["accounting"]?.AsValue().GetValue() ?? json["buchführend"]?.AsValue().GetValue() ?? false, IsOrganic = json["organic"]?.AsValue().GetValue() ?? false, - IsFunktionär = json["funktionär"]?.AsValue().GetValue() ?? false, + IsOfficer = json["officer"]?.AsValue().GetValue() ?? json["funktionär"]?.AsValue().GetValue() ?? false, IsActive = json["active"]?.AsValue().GetValue() ?? false, IsDeceased = json["deceased"]?.AsValue().GetValue() ?? false, Iban = json["iban"]?.AsValue().GetValue(), @@ -961,7 +961,7 @@ namespace Elwig.Helpers.Export { }; if (p.IsSplCheck) obj["spl_check"] = p.IsSplCheck; if (p.IsHandPicked != null) obj["hand_picked"] = p.IsHandPicked; - if (p.IsGebunden != null) obj["gebunden"] = p.IsGebunden; + if (p.IsContracted != null) obj["contracted"] = p.IsContracted; if (p.Unloading != null) obj["unloading"] = p.Unloading; if (p.Temperature != null) obj["temperature"] = p.Temperature; if (p.Acid != null) obj["acid"] = p.Acid; @@ -1035,7 +1035,7 @@ namespace Elwig.Helpers.Export { Comment = p["comment"]?.AsValue().GetValue(), IsSplCheck = p["spl_check"]?.AsValue().GetValue() ?? false, IsHandPicked = p["hand_picked"]?.AsValue().GetValue(), - IsGebunden = p["gebunden"]?.AsValue().GetValue(), + IsContracted = p["contracted"]?.AsValue().GetValue() ?? p["gebunden"]?.AsValue().GetValue(), Unloading = p["unloading"]?.AsValue().GetValue() ?? ((p["lesewagen"]?.AsValue().GetValue() ?? false) ? DeliveryPart.Pumped : null), Temperature = p["temperature"]?.AsValue().GetValue(), Acid = p["acid"]?.AsValue().GetValue(), diff --git a/Elwig/Models/Dtos/MemberListData.cs b/Elwig/Models/Dtos/MemberListData.cs index 32b5496..3f88b9c 100644 --- a/Elwig/Models/Dtos/MemberListData.cs +++ b/Elwig/Models/Dtos/MemberListData.cs @@ -25,7 +25,7 @@ namespace Elwig.Models.Dtos { ("BillingPlz", "PLZ", null, 10), ("BillingLocality", "Ort", null, 60), ("LfbisNr", "Betr.-Nr.", null, 20), - ("IsBuchführend", "buchf.", null, 15), + ("IsAccounting", "buchf.", null, 15), ("IsOrganic", "Bio", null, 15), ("IsActive", "aktiv", null, 15), ("EntryDate", "Eintritt", null, 20), @@ -83,7 +83,7 @@ namespace Elwig.Models.Dtos { public string? Bic; public int? AreaCommitment; public (string VtrgId, int Area)[] AreaCommitmentsFiltered; - public bool IsBuchführend; + public bool IsAccounting; public bool IsOrganic; public bool IsActive; public DateOnly? EntryDate; @@ -118,7 +118,7 @@ namespace Elwig.Models.Dtos { UstIdNr = m.UstIdNr; Iban = m.Iban != null ? Utils.FormatIban(m.Iban) : null; Bic = m.Bic; - IsBuchführend = m.IsBuchführend; + IsAccounting = m.IsAccounting; IsOrganic = m.IsOrganic; IsActive = m.IsActive; EntryDate = m.EntryDate; diff --git a/Elwig/Models/Dtos/PaymentVariantSummaryData.cs b/Elwig/Models/Dtos/PaymentVariantSummaryData.cs index 5c54a5f..11716f5 100644 --- a/Elwig/Models/Dtos/PaymentVariantSummaryData.cs +++ b/Elwig/Models/Dtos/PaymentVariantSummaryData.cs @@ -18,9 +18,9 @@ namespace Elwig.Models.Dtos { ("Cultivation", "Bewirt.", null, 20), ("QualityLevel", "Qualitätsstufe", null, 30), ("Oe", "Gradation", "°Oe", 20), - ("Ungeb", "ungebunden", "kg|€/kg|€/kg", 60), - ("LowGeb", "attributlos gebunden", "kg|€/kg|€/kg", 60), - ("Geb", "gebunden", "kg|€/kg|€/kg", 60), + ("UnCtrd", "ungebunden", "kg|€/kg|€/kg", 60), + ("LowCtrd", "attributlos gebunden", "kg|€/kg|€/kg", 60), + ("Ctrd", "gebunden", "kg|€/kg|€/kg", 60), ("Amount", "Gesamt", "€", 25), ]; @@ -31,9 +31,9 @@ namespace Elwig.Models.Dtos { string? Cultivation, string QualityLevel, double Oe, - (int Weight, decimal? MinPrice, decimal? MaxPrice) Ungeb, - (int Weight, decimal? MinPrice, decimal? MaxPrice) LowGeb, - (int Weight, decimal? MinPrice, decimal? MaxPrice) Geb, + (int Weight, decimal? MinPrice, decimal? MaxPrice) UnCtrd, + (int Weight, decimal? MinPrice, decimal? MaxPrice) LowCtrd, + (int Weight, decimal? MinPrice, decimal? MaxPrice) Ctrd, decimal Amount ); @@ -44,9 +44,9 @@ namespace Elwig.Models.Dtos { public static async Task ForPaymentVariant(PaymentVar v, DbSet table) { return new(v, (await FromDbSet(table, v.Year, v.AvNr)) .Select(r => new PaymentRow(r.Type, r.Variety, r.Attribute, r.Cultivation, r.QualityLevel, r.Oe, - (r.WeightUngeb, r.MinPriceUngeb != null ? Utils.DecFromDb(r.MinPriceUngeb.Value, v.Season.Precision) : null, r.MaxPriceUngeb != null ? Utils.DecFromDb(r.MaxPriceUngeb.Value, v.Season.Precision) : null), - (r.WeightLowGeb, r.MinPriceLowGeb != null ? Utils.DecFromDb(r.MinPriceLowGeb.Value, v.Season.Precision) : null, r.MaxPriceLowGeb != null ? Utils.DecFromDb(r.MaxPriceLowGeb.Value, v.Season.Precision) : null), - (r.WeightGeb, r.MinPriceGeb != null ? Utils.DecFromDb(r.MinPriceGeb.Value, v.Season.Precision) : null, r.MaxPriceGeb != null ? Utils.DecFromDb(r.MaxPriceGeb.Value, v.Season.Precision) : null), + (r.WeightUnCtrd, r.MinPriceUnCtrd != null ? Utils.DecFromDb(r.MinPriceUnCtrd.Value, v.Season.Precision) : null, r.MaxPriceUnCtrd != null ? Utils.DecFromDb(r.MaxPriceUnCtrd.Value, v.Season.Precision) : null), + (r.WeightLowCtrd, r.MinPriceLowCtrd != null ? Utils.DecFromDb(r.MinPriceLowCtrd.Value, v.Season.Precision) : null, r.MaxPriceLowCtrd != null ? Utils.DecFromDb(r.MaxPriceLowCtrd.Value, v.Season.Precision) : null), + (r.WeightCtrd, r.MinPriceCtrd != null ? Utils.DecFromDb(r.MinPriceCtrd.Value, v.Season.Precision) : null, r.MaxPriceCtrd != null ? Utils.DecFromDb(r.MaxPriceCtrd.Value, v.Season.Precision) : null), Utils.DecFromDb(r.Amount, v.Season.Precision))) .ToArray()); } @@ -59,15 +59,15 @@ namespace Elwig.Models.Dtos { c.name AS cultivation, q.name AS quality_level, ROUND(kmw * (4.54 + 0.022 * kmw)) AS oe, - SUM(IIF(w.discr = '_', w.value, 0)) AS weight_ungeb, - MIN(IIF(w.discr = '_', b.price, NULL)) AS min_price_ungeb, - MAX(IIF(w.discr = '_', b.price, NULL)) AS max_price_ungeb, - SUM(IIF(w.discr NOT IN (COALESCE(p.attrid, ''), '_'), w.value, 0)) AS weight_lowgeb, - MIN(IIF(w.discr NOT IN (COALESCE(p.attrid, ''), '_'), b.price, NULL)) AS min_price_lowgeb, - MAX(IIF(w.discr NOT IN (COALESCE(p.attrid, ''), '_'), b.price, NULL)) AS max_price_lowgeb, - SUM(IIF(w.discr = COALESCE(p.attrid, ''), w.value, 0)) AS weight_geb, - MIN(IIF(w.discr = COALESCE(p.attrid, ''), b.price, NULL)) AS min_price_geb, - MAX(IIF(w.discr = COALESCE(p.attrid, ''), b.price, NULL)) AS max_price_geb, + SUM(IIF(w.discr = '_', w.value, 0)) AS weight_unctrd, + MIN(IIF(w.discr = '_', b.price, NULL)) AS min_price_unctrd, + MAX(IIF(w.discr = '_', b.price, NULL)) AS max_price_unctrd, + SUM(IIF(w.discr NOT IN (COALESCE(p.attrid, ''), '_'), w.value, 0)) AS weight_lowctrd, + MIN(IIF(w.discr NOT IN (COALESCE(p.attrid, ''), '_'), b.price, NULL)) AS min_price_lowctrd, + MAX(IIF(w.discr NOT IN (COALESCE(p.attrid, ''), '_'), b.price, NULL)) AS max_price_lowctrd, + SUM(IIF(w.discr = COALESCE(p.attrid, ''), w.value, 0)) AS weight_ctrd, + MIN(IIF(w.discr = COALESCE(p.attrid, ''), b.price, NULL)) AS min_price_ctrd, + MAX(IIF(w.discr = COALESCE(p.attrid, ''), b.price, NULL)) AS max_price_ctrd, SUM(b.amount) AS amount FROM payment_delivery_part_bucket b LEFT JOIN delivery_part_bucket w ON (w.year, w.did, w.dpnr, w.bktnr) = (b.year, b.did, b.dpnr, b.bktnr) @@ -97,24 +97,24 @@ namespace Elwig.Models.Dtos { public required string QualityLevel { get; set; } [Column("oe")] public double Oe { get; set; } - [Column("weight_ungeb")] - public int WeightUngeb { get; set; } - [Column("min_price_ungeb")] - public long? MinPriceUngeb { get; set; } - [Column("max_price_ungeb")] - public long? MaxPriceUngeb { get; set; } - [Column("weight_lowgeb")] - public int WeightLowGeb { get; set; } - [Column("min_price_lowgeb")] - public long? MinPriceLowGeb { get; set; } - [Column("max_price_lowgeb")] - public long? MaxPriceLowGeb { get; set; } - [Column("weight_geb")] - public int WeightGeb { get; set; } - [Column("min_price_geb")] - public long? MinPriceGeb { get; set; } - [Column("max_price_geb")] - public long? MaxPriceGeb { get; set; } + [Column("weight_unctrd")] + public int WeightUnCtrd { get; set; } + [Column("min_price_unctrd")] + public long? MinPriceUnCtrd { get; set; } + [Column("max_price_unctrd")] + public long? MaxPriceUnCtrd { get; set; } + [Column("weight_lowctrd")] + public int WeightLowCtrd { get; set; } + [Column("min_price_lowctrd")] + public long? MinPriceLowCtrd { get; set; } + [Column("max_price_lowctrd")] + public long? MaxPriceLowCtrd { get; set; } + [Column("weight_ctrd")] + public int WeightCtrd { get; set; } + [Column("min_price_ctrd")] + public long? MinPriceCtrd { get; set; } + [Column("max_price_ctrd")] + public long? MaxPriceCtrd { get; set; } [Column("amount")] public long Amount { get; set; } } diff --git a/Elwig/Models/Dtos/WeightBreakdownData.cs b/Elwig/Models/Dtos/WeightBreakdownData.cs index 4d2bb0d..6f86d9f 100644 --- a/Elwig/Models/Dtos/WeightBreakdownData.cs +++ b/Elwig/Models/Dtos/WeightBreakdownData.cs @@ -13,7 +13,7 @@ namespace Elwig.Models.Dtos { ("AttrId", "Attr.", null, 10), ("CultId", "Bewirt.", null, 15), ("QualId", "Qual.", null, 15), - ("Geb", "gebunden", null, 20), + ("Contracted", "gebunden", null, 20), ("Weight", "Menge", "kg", 20), ]; @@ -28,12 +28,12 @@ namespace Elwig.Models.Dtos { private static async Task> FromDbSet(DbSet table, int year, string? zwstid) { zwstid = zwstid == null ? "NULL" : $"'{zwstid}'"; return await table.FromSqlRaw($""" - SELECT type, sortid, attrid, cultid, v.qualid, geb, SUM(weight) AS weight + SELECT type, sortid, attrid, cultid, v.qualid, contracted, SUM(weight) AS weight FROM v_stat_total v LEFT JOIN wine_quality_level q ON q.qualid = v.qualid WHERE year = {year} AND ({zwstid} IS NULL OR zwstid = {zwstid}) - GROUP BY type, sortid, attrid, cultid, v.qualid, geb - ORDER BY type DESC, sortid, attrid, cultid, q.min_kmw, geb + GROUP BY type, sortid, attrid, cultid, v.qualid, contracted + ORDER BY type DESC, sortid, attrid, cultid, q.min_kmw, contracted """).ToListAsync(); } } @@ -50,8 +50,8 @@ namespace Elwig.Models.Dtos { public string? CultId { get; set; } [Column("qualid")] public required string QualId { get; set; } - [Column("geb")] - public required string Geb { get; set; } + [Column("contracted")] + public required string Contracted { get; set; } [Column("weight")] public int Weight { get; set; } } diff --git a/Elwig/Models/Entities/DeliveryPart.cs b/Elwig/Models/Entities/DeliveryPart.cs index 7febef1..4a2659f 100644 --- a/Elwig/Models/Entities/DeliveryPart.cs +++ b/Elwig/Models/Entities/DeliveryPart.cs @@ -91,8 +91,8 @@ namespace Elwig.Models.Entities { [Column("hand_picked")] public bool? IsHandPicked { get; set; } - [Column("gebunden")] - public bool? IsGebunden { get; set; } + [Column("contracted")] + public bool? IsContracted { get; set; } [Column("unloading")] public string? Unloading { get; set; } diff --git a/Elwig/Models/Entities/Member.cs b/Elwig/Models/Entities/Member.cs index 8eda41f..7fb9782 100644 --- a/Elwig/Models/Entities/Member.cs +++ b/Elwig/Models/Entities/Member.cs @@ -105,17 +105,17 @@ namespace Elwig.Models.Entities { [Column("juridical_pers")] public bool IsJuridicalPerson { get; set; } - [Column("volllieferant")] - public bool IsVollLieferant { get; set; } + [Column("full_delivery")] + public bool IsFullDelivery { get; set; } - [Column("buchführend")] - public bool IsBuchführend { get; set; } + [Column("accounting")] + public bool IsAccounting { get; set; } [Column("organic")] public bool IsOrganic { get; set; } - [Column("funktionär")] - public bool IsFunktionär { get; set; } + [Column("officer")] + public bool IsOfficer { get; set; } [Column("active")] public bool IsActive { get; set; } diff --git a/Elwig/Models/Entities/Season.cs b/Elwig/Models/Entities/Season.cs index 6f11369..7946e83 100644 --- a/Elwig/Models/Entities/Season.cs +++ b/Elwig/Models/Entities/Season.cs @@ -107,7 +107,7 @@ namespace Elwig.Models.Entities { [Column("calc_mode")] public int CalcMode { get; set; } [NotMapped] - public bool Billing_HonorGebunden { + public bool Billing_HonorContracted { get => (CalcMode & 0x1) != 0; set => CalcMode = value ? CalcMode | 0x1 : CalcMode & ~0x1; } diff --git a/Elwig/Resources/Schemas/PaymentVariantData.json b/Elwig/Resources/Schemas/PaymentVariantData.json index 20feecd..2b88fe4 100644 --- a/Elwig/Resources/Schemas/PaymentVariantData.json +++ b/Elwig/Resources/Schemas/PaymentVariantData.json @@ -92,6 +92,12 @@ {"$ref": "#/definitions/curve_data"} ] }, + "ctrd": { + "anyOf": [ + {"type": "number"}, + {"$ref": "#/definitions/curve_data"} + ] + }, "geb": { "anyOf": [ {"type": "number"}, diff --git a/Elwig/Resources/Sql/41-42.sql b/Elwig/Resources/Sql/41-42.sql index f061c60..bf0613f 100644 --- a/Elwig/Resources/Sql/41-42.sql +++ b/Elwig/Resources/Sql/41-42.sql @@ -9,6 +9,30 @@ ALTER TABLE member_history RENAME COLUMN signed TO signed_member; ALTER TABLE member_history ADD COLUMN signed_company INTEGER NOT NULL CHECK (signed_company IN (TRUE, FALSE)) DEFAULT FALSE; +PRAGMA writable_schema = ON; + +UPDATE sqlite_schema SET sql = REPLACE(REPLACE(REPLACE(sql, 'funktionär', 'officer '), 'buchführend', 'accounting '), 'volllieferant', 'full_delivery') +WHERE type = 'table' AND name = 'member'; + +UPDATE sqlite_schema SET sql = REPLACE(sql, 'gebunden', 'contracted') +WHERE type = 'table' AND name = 'delivery_part'; + +UPDATE sqlite_schema SET sql = REPLACE(sql, 'gebunden', 'contracted') +WHERE type = 'view' AND name = 'v_delivery'; + +UPDATE sqlite_schema SET sql = REPLACE(sql, 'volllieferant', 'full_delivery') +WHERE type = 'view' AND name = 'v_bki_member'; + +UPDATE sqlite_schema SET sql = REPLACE(sql, ' geb', ' contracted') +WHERE type = 'view' AND name = 'v_stat_total'; + +UPDATE sqlite_schema SET sql = REPLACE(sql, 'gebunden', 'contracted') +WHERE type = 'view' AND (name = 'v_payment_bucket_strict' OR name = 'v_payment_bucket' OR name = 'v_under_delivery_bucket'); + +PRAGMA schema_version = 4101; +PRAGMA writable_schema = OFF; + + UPDATE client_parameter SET value = '0' WHERE param = 'ENABLE_TIME_TRIGGERS'; UPDATE member SET org_auth_code = UPPER(SUBSTR(a.name, -11, 10)) diff --git a/Elwig/Services/DeliveryService.cs b/Elwig/Services/DeliveryService.cs index 8ba4138..64feb66 100644 --- a/Elwig/Services/DeliveryService.cs +++ b/Elwig/Services/DeliveryService.cs @@ -75,7 +75,7 @@ namespace Elwig.Services { vm.TemperatureString = (p.Temperature != null) ? $"{p.Temperature:N1}" : ""; vm.AcidString = (p.Acid != null) ? $"{p.Acid:N1}" : ""; vm.IsHandPicked = p.IsHandPicked; - vm.IsGebunden = p.IsGebunden; + vm.IsContracted = p.IsContracted; vm.Unloading = p.Unloading; vm.ScaleTerminalId = p.ScaleTerminalId; @@ -181,19 +181,19 @@ namespace Elwig.Services { filter.RemoveAt(i--); filterNames.Add("Weißweinsorten"); } else if (e.Length >= 3 && e.Length <= 8 && "gebunden".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - prd = prd.And(p => p.IsGebunden == true); + prd = prd.And(p => p.IsContracted == true); filter.RemoveAt(i--); filterNames.Add("gebunden"); } else if (e.Length >= 4 && e.Length <= 9 && "!gebunden".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - prd = prd.And(p => p.IsGebunden != true); + prd = prd.And(p => p.IsContracted != true); filter.RemoveAt(i--); filterNames.Add("nicht gebunden"); } else if (e.Length >= 5 && e.Length <= 10 && "ungebunden".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - prd = prd.And(p => p.IsGebunden == false); + prd = prd.And(p => p.IsContracted == false); filter.RemoveAt(i--); filterNames.Add("ungebunden"); } else if (e.Length >= 6 && e.Length <= 11 && "!ungebunden".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - prd = prd.And(p => p.IsGebunden != false); + prd = prd.And(p => p.IsContracted != false); filter.RemoveAt(i--); filterNames.Add("nicht ungebunden"); } else if (e.Length >= 5 && e.Length <= 8 && "handlese".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { @@ -556,7 +556,7 @@ namespace Elwig.Services { IsNetWeight = vm.IsNetWeight, IsHandPicked = vm.IsHandPicked, - IsGebunden = vm.IsGebunden, + IsContracted = vm.IsContracted, Unloading = vm.Unloading, Temperature = vm.Temperature, Acid = vm.Acid, diff --git a/Elwig/Services/MemberService.cs b/Elwig/Services/MemberService.cs index 7aacf0e..c2dbff8 100644 --- a/Elwig/Services/MemberService.cs +++ b/Elwig/Services/MemberService.cs @@ -116,7 +116,7 @@ namespace Elwig.Services { vm.LfbisNr = m.LfbisNr; vm.OrganicOperatorId = m.OrganicOperatorId; vm.OrganicAuthorityCode = m.OrganicAuthorityCode; - vm.IsBuchführend = m.IsBuchführend; + vm.IsAccounting = m.IsAccounting; vm.IsOrganic = m.IsOrganic; var billingAddr = m.BillingAddress; @@ -150,8 +150,8 @@ namespace Elwig.Services { vm.DefaultKg = (AT_Kg?)ControlUtils.GetItemFromSourceWithPk(vm.DefaultKgSource, m.DefaultKgNr); vm.Comment = m.Comment; vm.IsActive = m.IsActive; - vm.IsVollLieferant = m.IsVollLieferant; - vm.IsFunktionär = m.IsFunktionär; + vm.IsFullDelivery = m.IsFullDelivery; + vm.IsOfficer = m.IsOfficer; vm.ContactViaPost = m.ContactViaPost; vm.ContactViaEmail = m.ContactViaEmail; @@ -319,11 +319,11 @@ namespace Elwig.Services { filter.RemoveAt(i--); filterNames.Add("inaktive Mitglieder"); } else if (e.Length >= 5 && e.Length <= 10 && "funktionär".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => m.IsFunktionär); + memberQuery = memberQuery.Where(m => m.IsOfficer); filter.RemoveAt(i--); filterNames.Add("Funktionäre"); } else if (e.Length >= 6 && e.Length <= 11 && e[0] == '!' && "funktionär".StartsWith(e[1..], StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => !m.IsFunktionär); + memberQuery = memberQuery.Where(m => !m.IsOfficer); filter.RemoveAt(i--); filterNames.Add("Nicht-Funktionäre"); } else if (e.Equals("bio", StringComparison.CurrentCultureIgnoreCase)) { @@ -334,28 +334,36 @@ namespace Elwig.Services { memberQuery = memberQuery.Where(m => !m.IsOrganic); filter.RemoveAt(i--); filterNames.Add("Nicht-Bio-Betriebe"); + } else if (e.Length >= 4 && e.Length <= 14 && "vollablieferer".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { + memberQuery = memberQuery.Where(m => m.IsFullDelivery); + filter.RemoveAt(i--); + filterNames.Add("Vollablieferer"); } else if (e.Length >= 4 && e.Length <= 13 && "volllieferant".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => m.IsVollLieferant); + memberQuery = memberQuery.Where(m => m.IsFullDelivery); filter.RemoveAt(i--); - filterNames.Add("Volllieferanten"); + filterNames.Add("Vollablieferer"); + } else if (e.Length >= 5 && e.Length <= 15 && e[0] == '!' && "vollablieferer".StartsWith(e[1..], StringComparison.CurrentCultureIgnoreCase)) { + memberQuery = memberQuery.Where(m => !m.IsFullDelivery); + filter.RemoveAt(i--); + filterNames.Add("Nicht-Vollablieferer"); } else if (e.Length >= 5 && e.Length <= 14 && e[0] == '!' && "volllieferant".StartsWith(e[1..], StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => !m.IsVollLieferant); + memberQuery = memberQuery.Where(m => !m.IsFullDelivery); filter.RemoveAt(i--); - filterNames.Add("Nicht-Vollieferanten"); + filterNames.Add("Nicht-Vollablieferer"); } else if (e.Length >= 5 && e.Length <= 11 && "buchführend".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => m.IsBuchführend); + memberQuery = memberQuery.Where(m => m.IsAccounting); filter.RemoveAt(i--); filterNames.Add("buchführend"); } else if (e.Length >= 6 && e.Length <= 12 && e[0] == '!' && "buchführend".StartsWith(e[1..], StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => !m.IsBuchführend); + memberQuery = memberQuery.Where(m => !m.IsAccounting); filter.RemoveAt(i--); filterNames.Add("pauschaliert"); } else if (e.Length >= 8 && e.Length <= 12 && "pauschaliert".StartsWith(e, StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => !m.IsBuchführend); + memberQuery = memberQuery.Where(m => !m.IsAccounting); filter.RemoveAt(i--); filterNames.Add("pauschaliert"); } else if (e.Length >= 9 && e.Length <= 13 && e[0] == '!' && "pauschaliert".StartsWith(e[1..], StringComparison.CurrentCultureIgnoreCase)) { - memberQuery = memberQuery.Where(m => m.IsBuchführend); + memberQuery = memberQuery.Where(m => m.IsAccounting); filter.RemoveAt(i--); filterNames.Add("buchführend"); } else if (e.Equals("email", StringComparison.CurrentCultureIgnoreCase)) { @@ -629,7 +637,7 @@ namespace Elwig.Services { LfbisNr = string.IsNullOrWhiteSpace(vm.LfbisNr) ? null : vm.LfbisNr, OrganicOperatorId = string.IsNullOrWhiteSpace(vm.OrganicOperatorId) ? null : vm.OrganicOperatorId, OrganicAuthorityCode = string.IsNullOrWhiteSpace(vm.OrganicAuthorityCode) ? null : vm.OrganicAuthorityCode, - IsBuchführend = vm.IsBuchführend, + IsAccounting = vm.IsAccounting, IsOrganic = vm.IsOrganic, EntryDateString = string.IsNullOrWhiteSpace(vm.EntryDate) ? null : string.Join("-", vm.EntryDate.Split(".").Reverse()), @@ -640,8 +648,8 @@ namespace Elwig.Services { SharesDormant = App.Client.HasRedWhite ? vm.BusinessShares3 ?? 0 : vm.BusinessShares2 ?? 0, AccountingNr = string.IsNullOrWhiteSpace(vm.AccountingNr) ? null : vm.AccountingNr, IsActive = vm.IsActive, - IsVollLieferant = vm.IsVollLieferant, - IsFunktionär = vm.IsFunktionär, + IsFullDelivery = vm.IsFullDelivery, + IsOfficer = vm.IsOfficer, ZwstId = vm.Branch?.ZwstId, DefaultKgNr = vm.DefaultKg?.KgNr, Comment = string.IsNullOrWhiteSpace(vm.Comment) ? null : vm.Comment, diff --git a/Elwig/Services/PaymentVariantService.cs b/Elwig/Services/PaymentVariantService.cs index 92d6113..a53d24c 100644 --- a/Elwig/Services/PaymentVariantService.cs +++ b/Elwig/Services/PaymentVariantService.cs @@ -159,10 +159,10 @@ namespace Elwig.Services { foreach (int mgnr in currentPayments.Keys) { var c = currentPayments[mgnr]; var l = lastPayments.GetValueOrDefault(mgnr); - vatSum += (c.Amount - (l?.Amount ?? 0)) * (decimal)(c.Member.IsBuchführend ? v.Season.VatNormal : v.Season.VatFlatrate); + vatSum += (c.Amount - (l?.Amount ?? 0)) * (decimal)(c.Member.IsAccounting ? v.Season.VatNormal : v.Season.VatFlatrate); } } else { - vatSum = currentPayments.Sum(e => e.Value.Amount * (decimal)(e.Value.Member.IsBuchführend ? v.Season.VatNormal : v.Season.VatFlatrate)); + vatSum = currentPayments.Sum(e => e.Value.Amount * (decimal)(e.Value.Member.IsAccounting ? v.Season.VatNormal : v.Season.VatFlatrate)); } vatText = $"~{vatSum:N2} {sym}"; deductionText = $"- {sym}"; diff --git a/Elwig/ViewModels/DeliveryAdminViewModel.cs b/Elwig/ViewModels/DeliveryAdminViewModel.cs index f3c4640..4ebc99f 100644 --- a/Elwig/ViewModels/DeliveryAdminViewModel.cs +++ b/Elwig/ViewModels/DeliveryAdminViewModel.cs @@ -157,7 +157,7 @@ namespace Elwig.ViewModels { [ObservableProperty] public partial IEnumerable WineRdSource { get; set; } = []; [ObservableProperty] - public partial bool? IsGebunden { get; set; } + public partial bool? IsContracted { get; set; } public ObservableCollection Modifiers { get; set; } = []; [ObservableProperty] diff --git a/Elwig/ViewModels/MemberAdminViewModel.cs b/Elwig/ViewModels/MemberAdminViewModel.cs index d45b490..26f1d00 100644 --- a/Elwig/ViewModels/MemberAdminViewModel.cs +++ b/Elwig/ViewModels/MemberAdminViewModel.cs @@ -125,7 +125,7 @@ namespace Elwig.ViewModels { [ObservableProperty] public partial string? OrganicAuthorityCode { get; set; } [ObservableProperty] - public partial bool IsBuchführend { get; set; } + public partial bool IsAccounting { get; set; } [ObservableProperty] public partial bool IsOrganic { get; set; } @@ -165,9 +165,9 @@ namespace Elwig.ViewModels { [ObservableProperty] public partial bool IsActive { get; set; } [ObservableProperty] - public partial bool IsVollLieferant { get; set; } + public partial bool IsFullDelivery { get; set; } [ObservableProperty] - public partial bool IsFunktionär { get; set; } + public partial bool IsOfficer { get; set; } [ObservableProperty] public partial Branch? Branch { get; set; } [ObservableProperty] diff --git a/Elwig/Windows/BaseDataWindow.xaml b/Elwig/Windows/BaseDataWindow.xaml index f63d626..41da24e 100644 --- a/Elwig/Windows/BaseDataWindow.xaml +++ b/Elwig/Windows/BaseDataWindow.xaml @@ -574,7 +574,7 @@ - Bei Lieferungen das Feld Gebunden berücksichtigen diff --git a/Elwig/Windows/BaseDataWindow.xaml.cs b/Elwig/Windows/BaseDataWindow.xaml.cs index a5d9b3c..01dbc1f 100644 --- a/Elwig/Windows/BaseDataWindow.xaml.cs +++ b/Elwig/Windows/BaseDataWindow.xaml.cs @@ -352,7 +352,7 @@ namespace Elwig.Windows { ParameterBusinessShareHistoryInput.IsChecked = p.EnableMemberHistory; ParameterAllowAttrIntoLowerInput.IsChecked = s?.Billing_AllowAttrsIntoLower ?? false; ParameterAvoidUnderDeliveriesInput.IsChecked = s?.Billing_AvoidUnderDeliveries ?? false; - ParameterHonorGebundenInput.IsChecked = s?.Billing_HonorGebunden ?? false; + ParameterHonorContractedInput.IsChecked = s?.Billing_HonorContracted ?? false; ParameterExportEbicsVersion.SelectedIndex = p.ExportEbicsVersion - 3; ParameterExportEbicsAddress.SelectedIndex = p.ExportEbicsAddress; @@ -406,7 +406,7 @@ namespace Elwig.Windows { s.Billing_AllowAttrsIntoLower = ParameterAllowAttrIntoLowerInput.IsChecked ?? false; s.Billing_AvoidUnderDeliveries = ParameterAvoidUnderDeliveriesInput.IsChecked ?? false; - s.Billing_HonorGebunden = ParameterHonorGebundenInput.IsChecked ?? false; + s.Billing_HonorContracted = ParameterHonorContractedInput.IsChecked ?? false; ctx.Update(s); await ctx.SaveChangesAsync(); } catch { } diff --git a/Elwig/Windows/ChartWindow.xaml b/Elwig/Windows/ChartWindow.xaml index 8acff56..a69504f 100644 --- a/Elwig/Windows/ChartWindow.xaml +++ b/Elwig/Windows/ChartWindow.xaml @@ -138,9 +138,9 @@