diff --git a/Elwig/Helpers/Billing/BillingData.cs b/Elwig/Helpers/Billing/BillingData.cs index 45396e7..b5bb84c 100644 --- a/Elwig/Helpers/Billing/BillingData.cs +++ b/Elwig/Helpers/Billing/BillingData.cs @@ -284,26 +284,27 @@ namespace Elwig.Helpers.Billing { } } } + var attributes = data .Select(e => e.Key) - .Where(k => k.Length > 3 && k.Contains('/')) + .Where(k => !k.StartsWith('/') && k.Contains('/')) .Select(k => k.Split('/')[1]) .Distinct() .ToList(); foreach (var idx in attributes) { var len = vaributes.Count(e => e.AttrId == idx); 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 * 0.5 && useDefault) || myKs.Count == len)) { foreach (var k in myKs) data.Remove(k); - data[$"/{idx}"] = v; + data[(idx.StartsWith('-') ? "" : "/") + idx] = v; } } 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 * 0.5 && useDefault) || myKs.Count == len)) { foreach (var k in myKs) data.Remove(k); - data[$"/{idx}"] = v; + data[(idx.StartsWith('-') ? "" : "/") + idx] = v; } } } @@ -333,10 +334,12 @@ namespace Elwig.Helpers.Billing { continue; } foreach (var c in entry.Vaributes) { + var v = new RawVaribute(c.Variety!.SortId, c.Attribute?.AttrId ?? "", c.Cultivation?.CultId); + if (v.CultId == "") v.CultId = null; if (entry.Abgewertet) {; - qualityWei[c.ToString()] = node.DeepClone(); + qualityWei[v.ToString()] = node.DeepClone(); } else { - payment[c.ToString()] = node.DeepClone(); + payment[v.ToString()] = node.DeepClone(); } } } diff --git a/Elwig/Helpers/Billing/BillingVariant.cs b/Elwig/Helpers/Billing/BillingVariant.cs index 249ae47..3b20341 100644 --- a/Elwig/Helpers/Billing/BillingVariant.cs +++ b/Elwig/Helpers/Billing/BillingVariant.cs @@ -123,10 +123,10 @@ namespace Elwig.Helpers.Billing { } protected async Task CalculatePrices(SqliteConnection cnx) { - var parts = new List<(int Year, int DId, int DPNr, int BktNr, string SortId, string? AttrId, string Discr, int Value, double Oe, double Kmw, string QualId)>(); + var parts = new List<(int Year, int DId, int DPNr, int BktNr, string SortId, string? AttrId, string? CultId, string Discr, int Value, double Oe, double Kmw, string QualId)>(); using (var cmd = cnx.CreateCommand()) { cmd.CommandText = $""" - SELECT d.year, d.did, d.dpnr, b.bktnr, d.sortid, d.attrid, b.discr, b.value, d.oe, d.kmw, d.qualid + SELECT d.year, d.did, d.dpnr, b.bktnr, d.sortid, d.attrid, d.cultid, b.discr, b.value, d.oe, d.kmw, d.qualid FROM delivery_part_bucket b JOIN v_delivery d ON (d.year, d.did, d.dpnr) = (b.year, b.did, b.dpnr) WHERE b.year = {Year} @@ -135,8 +135,9 @@ namespace Elwig.Helpers.Billing { while (await reader.ReadAsync()) { parts.Add(( reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3), - reader.GetString(4), reader.IsDBNull(5) ? null : reader.GetString(5), reader.GetString(6), - reader.GetInt32(7), reader.GetDouble(8), reader.GetDouble(9), reader.GetString(10) + reader.GetString(4), reader.IsDBNull(5) ? null : reader.GetString(5), + reader.IsDBNull(6) ? null : reader.GetString(6), reader.GetString(7), + reader.GetInt32(8), reader.GetDouble(9), reader.GetDouble(10), reader.GetString(11) )); } } @@ -145,9 +146,9 @@ namespace Elwig.Helpers.Billing { foreach (var part in parts) { var ungeb = part.Discr == "_"; var payAttrId = (part.Discr is "" or "_") ? null : part.Discr; - var attrId = part.AttrId == "B" ? "B" : payAttrId; // FIXME + var attrId = payAttrId; // FIXME var geb = !ungeb; // FIXME && payAttrId == part.AttrId; - var price = Data.CalculatePrice(part.SortId, attrId, part.QualId, geb, part.Oe, part.Kmw); + var price = Data.CalculatePrice(part.SortId, attrId, part.CultId, part.QualId, geb, part.Oe, part.Kmw); var priceL = PaymentVariant.Season.DecToDb(price); inserts.Add((part.Year, part.DId, part.DPNr, part.BktNr, priceL, priceL * part.Value)); } diff --git a/Elwig/Helpers/Billing/PaymentBillingData.cs b/Elwig/Helpers/Billing/PaymentBillingData.cs index e5a75ff..ce02f36 100644 --- a/Elwig/Helpers/Billing/PaymentBillingData.cs +++ b/Elwig/Helpers/Billing/PaymentBillingData.cs @@ -45,8 +45,8 @@ namespace Elwig.Helpers.Billing { return dict; } - public decimal CalculatePrice(string sortid, string? attrid, string qualid, bool gebunden, double oe, double kmw) { - var curve = GetQualityCurve(qualid, sortid, attrid) ?? GetCurve(sortid, attrid); + public decimal CalculatePrice(string sortid, string? attrid, string? cultid, string qualid, bool gebunden, 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); } @@ -60,12 +60,12 @@ namespace Elwig.Helpers.Billing { throw new InvalidOperationException(); } - protected Curve GetCurve(string sortid, string? attrid) { - return PaymentData[new(sortid, attrid ?? "", null)]; + protected Curve GetCurve(string sortid, string? attrid, string? cultid) { + return PaymentData[new(sortid, attrid ?? "", cultid ?? "")]; } - protected Curve? GetQualityCurve(string qualid, string sortid, string? attrid) { - return QualityData.TryGetValue(new(qualid, sortid, attrid ?? "", null), out var curve) ? curve : null; + protected Curve? GetQualityCurve(string qualid, string sortid, string? attrid, string? cultid) { + return QualityData.TryGetValue(new(qualid, sortid, attrid ?? "", cultid ?? ""), out var curve) ? curve : null; } } } diff --git a/Elwig/Helpers/Utils.cs b/Elwig/Helpers/Utils.cs index becf9cf..66a9231 100644 --- a/Elwig/Helpers/Utils.cs +++ b/Elwig/Helpers/Utils.cs @@ -364,7 +364,7 @@ namespace Elwig.Helpers { var varieties = ctx.WineVarieties.Select(v => new RawVaribute(v.SortId, "", null)).ToList(); var delivered = ctx.DeliveryParts .Where(d => d.Year == year) - .Select(d => new RawVaribute(d.SortId, d.AttrId ?? "", d.CultId)) + .Select(d => new RawVaribute(d.SortId, d.AttrId ?? "", d.CultId ?? "")) .Distinct() .ToList(); return [.. (onlyDelivered ? delivered : delivered.Union(varieties)).Order()]; diff --git a/Tests/HelperTests/BillingDataTest.cs b/Tests/HelperTests/BillingDataTest.cs index 4689ec0..c13eba4 100644 --- a/Tests/HelperTests/BillingDataTest.cs +++ b/Tests/HelperTests/BillingDataTest.cs @@ -9,11 +9,13 @@ namespace Tests.HelperTests { private static readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true }; private static readonly RawVaribute[] Vaributes = [ - new("GV/"), new("GV/D"), new("GV/K"), new("GV/S"), new("GV/Z"), - new("WR/"), new("WR/S"), new("ZW/"), new("ZW/S"), new("ZW/Z")]; + new("GV/-"), new("GV/D-"), new("GV/K-"), new("GV/S-"), new("GV/Z-"), + new("WR/-"), new("WR/S-"), new("ZW/-"), new("ZW/S-"), new("ZW/Z-"), + new("GV/-B"), new("WR/-B"), new("ZW/-B"), new("ZW/S-B"), new("GV/S-B"), new("GV/K-B")]; - private static (string, string?) GetSortIdAttrId(string bucket) { - return (bucket[..2], bucket.Length > 2 ? bucket[2..] : null); + private static (string, string?, string?) GetSortIdAttrId(string bucket) { + var v = bucket.Split('-'); + return (v[0][..2], v[0].Length > 2 ? v[0][2..] : null, v.Length > 1 ? v[1] : null); } private static string GetQualId(double kmw) { @@ -27,16 +29,16 @@ namespace Tests.HelperTests { } private static void TestCalcOe(PaymentBillingData data, string bucket, double oe, decimal expected, string? qualid = null, bool geb = false) { - var (sortid, attrid) = GetSortIdAttrId(bucket); + var (sortid, attrid, cultid) = GetSortIdAttrId(bucket); var kmw = Utils.OeToKmw(oe); - var v = data.CalculatePrice(sortid, attrid, qualid ?? GetQualId(kmw), geb, oe, kmw); + var v = data.CalculatePrice(sortid, attrid, cultid, qualid ?? GetQualId(kmw), geb, oe, kmw); Assert.That(Math.Round(v, 6), Is.EqualTo(expected)); } private static void TestCalcKmw(PaymentBillingData data, string bucket, double kmw, decimal expected, string? qualid = null, bool geb = false) { - var (sortid, attrid) = GetSortIdAttrId(bucket); + var (sortid, attrid, cultid) = GetSortIdAttrId(bucket); var oe = Utils.KmwToOe(kmw); - var v = data.CalculatePrice(sortid, attrid, qualid ?? GetQualId(kmw), geb, oe, kmw); + var v = data.CalculatePrice(sortid, attrid, cultid, qualid ?? GetQualId(kmw), geb, oe, kmw); Assert.That(Math.Round(v, 6), Is.EqualTo(expected)); } @@ -161,7 +163,40 @@ namespace Tests.HelperTests { } [Test] - public void TestRead_05_QualityLevel() { + public void TestRead_05_Cultivations() { + var data = PaymentBillingData.FromJson(""" + { + "mode": "elwig", + "version": 1, + "payment": { + "default": 0.10, + "-B": 0.20, + "/S": 0.30 + }, + "curves": [] + } + """, Vaributes); + Assert.Multiple(() => { + TestCalcOe(data, "WR", 73, 0.10m); + TestCalcOe(data, "WR-B", 73, 0.20m); + TestCalcOe(data, "WRS", 73, 0.30m); + TestCalcOe(data, "GV", 73, 0.10m); + TestCalcOe(data, "GV-B", 73, 0.20m); + TestCalcOe(data, "GVD", 73, 0.10m); + TestCalcOe(data, "GVK", 73, 0.10m); + TestCalcOe(data, "GVK-B", 73, 0.20m); + TestCalcOe(data, "GVS", 73, 0.30m); + TestCalcOe(data, "GVS-B", 73, 0.30m); + TestCalcOe(data, "GVZ", 73, 0.10m); + TestCalcOe(data, "ZW", 73, 0.10m); + TestCalcOe(data, "ZW-B", 73, 0.20m); + TestCalcOe(data, "ZWS", 73, 0.30m); + TestCalcOe(data, "ZWZ", 73, 0.10m); + }); + } + + [Test] + public void TestRead_06_QualityLevel() { var data = PaymentBillingData.FromJson(""" { "mode": "elwig", @@ -192,7 +227,7 @@ namespace Tests.HelperTests { } [Test] - public void TestRead_06_ModeOeAndKmw() { + public void TestRead_07_ModeOeAndKmw() { var data = PaymentBillingData.FromJson(""" { "mode": "elwig", @@ -234,7 +269,7 @@ namespace Tests.HelperTests { } [Test] - public void TestRead_07_MultipleCurves() { + public void TestRead_08_MultipleCurves() { var data = PaymentBillingData.FromJson(""" { "mode": "elwig", @@ -303,7 +338,7 @@ namespace Tests.HelperTests { } [Test] - public void TestRead_08_WgMaster() { + public void TestRead_09_WgMaster() { var data = PaymentBillingData.FromJson(""" { "mode": "wgmaster", @@ -346,6 +381,30 @@ namespace Tests.HelperTests { }); } + [Test] + public void TestRead_10_AttrubteAndCultivation() { + var data = PaymentBillingData.FromJson(""" + { + "mode": "elwig", + "version": 1, + "payment": { + "default": 0.10, + "/S": 0.20, + "-B": 0.30, + "GV/S-B": 0.40 + }, + "curves": [] + } + """, Vaributes); + Assert.Multiple(() => { + TestCalcOe(data, "GV", 73, 0.10m); + TestCalcOe(data, "GVS", 73, 0.20m); + TestCalcOe(data, "GV-B", 73, 0.30m); + TestCalcOe(data, "GVS-B", 73, 0.40m); + TestCalcOe(data, "ZWS-B", 73, 0.20m); + }); + } + private static List GetSelection(IEnumerable attVars) { return attVars.Select(s => new Varibute(new RawVaribute(s))).ToList(); } @@ -373,7 +432,7 @@ namespace Tests.HelperTests { List entries = [ new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.5m - }, null), GetSelection(["GV/"])) + }, null), GetSelection(["GV/-"])) ]; var data = BillingData.FromGraphEntries(entries); Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo(""" @@ -392,7 +451,7 @@ namespace Tests.HelperTests { new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.5m, [83] = 1.0m - }, null), GetSelection(["GV/"])) + }, null), GetSelection(["GV/-"])) ]; var data = BillingData.FromGraphEntries(entries); Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo(""" @@ -420,10 +479,10 @@ namespace Tests.HelperTests { new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.5m, [84] = 1.0m - }, null), GetSelection(["GV/", "ZW/"])), + }, null), GetSelection(["GV/-", "ZW/-"])), new GraphEntry(10, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.75m, - }, null), GetSelection(["WR/"])) + }, null), GetSelection(["WR/-"])) ]; var data = BillingData.FromGraphEntries(entries); Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo(""" @@ -454,14 +513,14 @@ namespace Tests.HelperTests { new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.5m, [84] = 1.0m - }, null), GetSelection(["GV/B", "ZW/B"])), + }, null), GetSelection(["GV/K-", "ZW/K-"])), new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.75m, - }, null), GetSelection(["WR/", "BL/", "RR/", "FV/"])), + }, null), GetSelection(["WR/-", "BL/-", "RR/-", "FV/-"])), new GraphEntry(4, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { [73] = 0.65m, [84] = 1.2m - }, null), GetSelection(["BP/", "SA/"])) + }, null), GetSelection(["BP/-", "SA/-"])) ]; var data = BillingData.FromGraphEntries(entries); Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo(""" @@ -472,7 +531,7 @@ namespace Tests.HelperTests { "BP/": "curve:2", "SA/": "curve:2", "default": 0.75, - "/B": "curve:1" + "/K": "curve:1" }, "curves": [ { @@ -495,5 +554,85 @@ namespace Tests.HelperTests { } """)); } + + [Test] + public void TestWrite_06_Cultivation() { + List entries = [ + new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.5m, + [84] = 1.0m + }, null), GetSelection(["GV/-B", "ZW/-B"])), + new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.75m, + }, null), GetSelection(["WR/-", "BL/-", "RR/-", "FV/-"])), + new GraphEntry(4, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.65m, + [84] = 1.2m + }, null), GetSelection(["BP/-", "SA/-"])) + ]; + var data = BillingData.FromGraphEntries(entries); + Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo(""" + { + "mode": "elwig", + "version": 1, + "payment": { + "BP/": "curve:2", + "SA/": "curve:2", + "default": 0.75, + "-B": "curve:1" + }, + "curves": [ + { + "id": 1, + "mode": "oe", + "data": { + "73oe": 0.5, + "84oe": 1 + } + }, + { + "id": 2, + "mode": "oe", + "data": { + "73oe": 0.65, + "84oe": 1.2 + } + } + ] + } + """)); + } + + [Test] + public void TestWrite_07_AttributeAndCultivation() { + List entries = [ + new GraphEntry(0, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.75m, + }, null), GetSelection(["GV/-", "ZW/-", "WR/-", "RR/-", "BL/-", "BP/-", "FV/-"])), + new GraphEntry(2, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.3m, + }, null), GetSelection(["GV/S-", "ZW/S-"])), + new GraphEntry(4, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.2m, + }, null), GetSelection(["GV/-B", "ZW/-B"])), + new GraphEntry(4, 4, new BillingData.Curve(BillingData.CurveMode.Oe, new() { + [73] = 0.4m, + }, null), GetSelection(["GV/S-B", "ZW/S-B"])) + ]; + var data = BillingData.FromGraphEntries(entries); + Assert.That(data.ToJsonString(JsonOpts), Is.EqualTo(""" + { + "mode": "elwig", + "version": 1, + "payment": { + "default": 0.75, + "/S": 0.3, + "-B": 0.2, + "/S-B": 0.4 + }, + "curves": [] + } + """)); + } } } diff --git a/Tests/HelperTests/BillingTest.cs b/Tests/HelperTests/BillingTest.cs index 526df46..81e85e9 100644 --- a/Tests/HelperTests/BillingTest.cs +++ b/Tests/HelperTests/BillingTest.cs @@ -42,8 +42,8 @@ namespace Tests.HelperTests { "mode": "elwig", "version": 1, "payment": { - "GV/": "curve:0", - "GV/B": "curve:1", + "GV": "curve:0", + "GV-B": "curve:1", "GV/K": "curve:2" }, "quality": {"WEI": 0.1}, @@ -129,10 +129,9 @@ namespace Tests.HelperTests { Assert.That(areaCom, Is.Empty); var delivery = await GetMemberDeliveryBuckets(year, mgnr); Assert.Multiple(() => { - Assert.That(delivery, Has.Count.EqualTo(4)); + Assert.That(delivery, Has.Count.EqualTo(3)); Assert.That(delivery["GV"], Is.EqualTo(16_000)); Assert.That(delivery["GV_"], Is.EqualTo( 1_000)); - Assert.That(delivery["GVB"], Is.EqualTo( 8_000)); Assert.That(delivery["GVK"], Is.EqualTo( 4_000)); }); @@ -174,10 +173,9 @@ namespace Tests.HelperTests { }); var delivery = await GetMemberDeliveryBuckets(year, mgnr); Assert.Multiple(() => { - Assert.That(delivery, Has.Count.EqualTo(4)); + Assert.That(delivery, Has.Count.EqualTo(3)); Assert.That(delivery["GV"], Is.EqualTo(16_000)); Assert.That(delivery["GV_"], Is.EqualTo( 1_000)); - Assert.That(delivery["GVB"], Is.EqualTo( 8_000)); Assert.That(delivery["GVK"], Is.EqualTo( 4_000)); }); @@ -195,17 +193,17 @@ namespace Tests.HelperTests { Assert.Multiple(() => { Assert.That(prices, Has.Count.EqualTo(10)); // Kabinett - Assert.That(prices[("20211001X001/1", "GV_")], Is.EqualTo((2_000, GV_ungeb))); - Assert.That(prices[("20211001X001/1", "GV")] , Is.EqualTo((2_000, GV_geb))); + Assert.That(prices[("20211001X001/1", "GV_")], Is.EqualTo(( 0, GV_ungeb))); + Assert.That(prices[("20211001X001/1", "GV")] , Is.EqualTo((4_000, GV_geb))); // ohne Attribut - Assert.That(prices[("20211001X001/2", "GV_")], Is.EqualTo((4_000, GV_ungeb))); - Assert.That(prices[("20211001X001/2", "GV")], Is.EqualTo(( 0, GV_geb))); + Assert.That(prices[("20211001X001/2", "GV_")], Is.EqualTo(( 0, GV_ungeb))); + Assert.That(prices[("20211001X001/2", "GV")], Is.EqualTo((4_000, GV_geb))); // Bio - Assert.That(prices[("20211001X002/1", "GV_")], Is.EqualTo(( 0, GVB_ungeb))); - Assert.That(prices[("20211001X002/1", "GV")], Is.EqualTo((4_000, GVB_geb))); + Assert.That(prices[("20211001X002/1", "GV_")], Is.EqualTo((4_000, GVB_ungeb))); + Assert.That(prices[("20211001X002/1", "GV")], Is.EqualTo(( 0, GVB_geb))); // Bio - Assert.That(prices[("20211001X002/2", "GV_")], Is.EqualTo(( 0, GVB_ungeb))); - Assert.That(prices[("20211001X002/2", "GV")], Is.EqualTo((4_000, GVB_geb))); + Assert.That(prices[("20211001X002/2", "GV_")], Is.EqualTo((2_000, GVB_ungeb))); + Assert.That(prices[("20211001X002/2", "GV")], Is.EqualTo((2_000, GVB_geb))); // ohne Attribut Assert.That(prices[("20211001X003/1", "GV_")], Is.EqualTo(( 500, WEI))); // ohne Attribut @@ -224,10 +222,9 @@ namespace Tests.HelperTests { }); var delivery = await GetMemberDeliveryBuckets(year, mgnr); Assert.Multiple(() => { - Assert.That(delivery, Has.Count.EqualTo(4)); + Assert.That(delivery, Has.Count.EqualTo(3)); Assert.That(delivery["GV"], Is.EqualTo(16_000)); Assert.That(delivery["GV_"], Is.EqualTo( 1_000)); - Assert.That(delivery["GVB"], Is.EqualTo( 8_000)); Assert.That(delivery["GVK"], Is.EqualTo( 4_000)); }); diff --git a/Tests/Resources/Sql/BillingInsert.sql b/Tests/Resources/Sql/BillingInsert.sql index f63d055..ce82769 100644 --- a/Tests/Resources/Sql/BillingInsert.sql +++ b/Tests/Resources/Sql/BillingInsert.sql @@ -1,12 +1,10 @@ -- inserts for HelperTests.BillingTest INSERT INTO wine_cultivation (cultid, name, description) VALUES -('N', 'Normal', NULL), -('K', 'KIP', 'Kontrollierte Integrierte Produktion'), -('B', 'Org. Biologisch', 'Organisch Biologisch'); +('KIP', 'KIP', 'Kontrollierte Integrierte Produktion'), +('B', 'Bio', 'AT-BIO-302'); INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES -('B', 'Bio', TRUE, NULL, FALSE, 0), ('K', 'Kabinett', TRUE, NULL, FALSE, 0), ('D', 'DAC', TRUE, 7500, FALSE, 0), ('S', 'Saft', TRUE, NULL, FALSE, 0), @@ -25,9 +23,9 @@ INSERT INTO area_commitment_type (vtrgid, sortid, attrid, disc, min_kg_per_ha, p ('GVR', 'GV', 'R', NULL, 5000, 1000, 1000000, NULL); INSERT INTO area_commitment (fbnr, mgnr, vtrgid, cultid, area, kgnr, gstnr, rdnr, year_from, year_to) VALUES -( 1, 101, 'GV', 'K', 10000, 06109, '123/4', NULL, 2000, 2019), -( 2, 101, 'GV', 'K', 10000, 06109, '123/5', NULL, 2025, 2030), -( 3, 101, 'GV', 'K', 10000, 06109, '123/6', NULL, 2021, 2031); +( 1, 101, 'GV', 'KIP', 10000, 06109, '123/4', NULL, 2000, 2019), +( 2, 101, 'GV', 'KIP', 10000, 06109, '123/5', NULL, 2025, 2030), +( 3, 101, 'GV', 'KIP', 10000, 06109, '123/6', NULL, 2021, 2031); INSERT INTO season (year, currency, min_kg_per_bs, max_kg_per_bs, penalty_per_kg, penalty_amount, penalty_none, start_date, end_date) VALUES (2020, 'EUR', 1000, 2000, NULL, NULL, NULL, NULL, NULL), @@ -42,13 +40,13 @@ INSERT INTO delivery (mgnr, year, did, date, time, zwstid, lnr) VALUES (101, 2020, 1, '2020-10-01', NULL, 'X', 1), (101, 2020, 2, '2020-10-01', NULL, 'X', 2), (101, 2020, 3, '2020-10-01', NULL, 'X', 3); -INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, weight, kmw, qualid, hkid, kgnr, net_weight, manual_weighing, spl_check, scale_id, weighing_id, weighing_reason) VALUES -(2020, 1, 1, 'GV', 'K', 4000, 17, 'KAB', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2020, 1, 2, 'GV', NULL, 4000, 16, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2020, 2, 1, 'GV', 'B', 4000, 15, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2020, 2, 2, 'GV', 'B', 4000, 16, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2020, 3, 1, 'GV', NULL, 500, 15, 'WEI', 'OEST', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2020, 3, 2, 'GV', NULL, 500, 14, 'LDW', 'WLXX', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL); +INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, cultid, weight, kmw, qualid, hkid, kgnr, net_weight, manual_weighing, spl_check, scale_id, weighing_id, weighing_reason) VALUES +(2020, 1, 1, 'GV', 'K', NULL, 4000, 17, 'KAB', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2020, 1, 2, 'GV', NULL, NULL, 4000, 16, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2020, 2, 1, 'GV', NULL, 'B', 4000, 15, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2020, 2, 2, 'GV', NULL, 'B', 4000, 16, 'QUW', 'WLNO', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2020, 3, 1, 'GV', NULL, NULL, 500, 15, 'WEI', 'OEST', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2020, 3, 2, 'GV', NULL, NULL, 500, 14, 'LDW', 'WLXX', 06109, TRUE, FALSE, FALSE, NULL, NULL, NULL); INSERT INTO delivery_part_modifier (year, did, dpnr, modid) VALUES (2020, 1, 2, 'S'); @@ -57,10 +55,10 @@ INSERT INTO delivery (mgnr, year, did, date, time, zwstid, lnr) VALUES (101, 2021, 1, '2021-10-01', NULL, 'X', 1), (101, 2021, 2, '2021-10-01', NULL, 'X', 2), (101, 2021, 3, '2021-10-01', NULL, 'X', 3); -INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, weight, kmw, qualid, hkid, kgnr, gebunden, net_weight, manual_weighing, spl_check, scale_id, weighing_id, weighing_reason) VALUES -(2021, 1, 1, 'GV', 'K', 4000, 17, 'KAB', 'WLNO', 06109, TRUE, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2021, 1, 2, 'GV', NULL, 4000, 16, 'QUW', 'WLNO', 06109, FALSE, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2021, 2, 1, 'GV', 'B', 4000, 15, 'QUW', 'WLNO', 06109, TRUE, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2021, 2, 2, 'GV', 'B', 4000, 16, 'QUW', 'WLNO', 06109, FALSE, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2021, 3, 1, 'GV', NULL, 500, 15, 'WEI', 'OEST', 06109, NULL, TRUE, FALSE, FALSE, NULL, NULL, NULL), -(2021, 3, 2, 'GV', NULL, 500, 14, 'LDW', 'WLXX', 06109, NULL, TRUE, FALSE, FALSE, NULL, NULL, NULL); +INSERT INTO delivery_part (year, did, dpnr, sortid, attrid, cultid, weight, kmw, qualid, hkid, kgnr, gebunden, net_weight, manual_weighing, spl_check, scale_id, weighing_id, weighing_reason) VALUES +(2021, 1, 1, 'GV', 'K', NULL, 4000, 17, 'KAB', 'WLNO', 06109, TRUE, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2021, 1, 2, 'GV', NULL, NULL, 4000, 16, 'QUW', 'WLNO', 06109, FALSE, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2021, 2, 1, 'GV', NULL, 'B', 4000, 15, 'QUW', 'WLNO', 06109, TRUE, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2021, 2, 2, 'GV', NULL, 'B', 4000, 16, 'QUW', 'WLNO', 06109, FALSE, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2021, 3, 1, 'GV', NULL, NULL, 500, 15, 'WEI', 'OEST', 06109, NULL, TRUE, FALSE, FALSE, NULL, NULL, NULL), +(2021, 3, 2, 'GV', NULL, NULL, 500, 14, 'LDW', 'WLXX', 06109, NULL, TRUE, FALSE, FALSE, NULL, NULL, NULL);