diff --git a/Elwig/Documents/CreditNote.cshtml b/Elwig/Documents/CreditNote.cshtml
index c8be8e3..d83fb1d 100644
--- a/Elwig/Documents/CreditNote.cshtml
+++ b/Elwig/Documents/CreditNote.cshtml
@@ -70,12 +70,14 @@
@($"{part.Kmw:N1}") |
@abs |
@rel |
- @Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(0), pmt?.Prices?.ElementAtOrDefault(0)))
+
+ @Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(0)?.Value, 0))
@($"{pmt?.Amount:N2}") |
@for (int i = 1; i < binNum; i++) {
- @Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(i), pmt?.Prices?.ElementAtOrDefault(i)))
+
+ @Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(i)?.Value, 0))
}
last = part.SortId;
diff --git a/Elwig/Documents/CreditNote.cshtml.cs b/Elwig/Documents/CreditNote.cshtml.cs
index d324d62..fa278c1 100644
--- a/Elwig/Documents/CreditNote.cshtml.cs
+++ b/Elwig/Documents/CreditNote.cshtml.cs
@@ -27,7 +27,7 @@ namespace Elwig.Documents {
Text = App.Client.TextDeliveryNote;
DocumentId = $"Tr.-Gutschr. {c.TgId}";
CurrencySymbol = c.Payment.Variant.Season.Currency.Symbol ?? c.Payment.Variant.Season.Currency.Code;
- BinNames = c.Payment.Variant.Season.BinNames;
+ BinNames = new string[0]; // FIXME
Precision = c.Payment.Variant.Season.Precision;
Parts = ctx.DeliveryParts.FromSql($"""
SELECT p.*
diff --git a/Elwig/Documents/DeliveryConfirmation.cshtml b/Elwig/Documents/DeliveryConfirmation.cshtml
index e35460e..243ee82 100644
--- a/Elwig/Documents/DeliveryConfirmation.cshtml
+++ b/Elwig/Documents/DeliveryConfirmation.cshtml
@@ -44,7 +44,7 @@
var lastSortId = "";
}
@foreach (var p in Model.Deliveries) {
- var bins = p.Bins.Select((b, n) => (b, n + 1)).Where(b => b.Item1 > 0).ToArray();
+ var bins = p.Bins.Where(b => b.Value > 0).OrderByDescending(b => b.BinNr).ToArray();
var rowsBins = bins.Length;
var mods = p.Modifiers.Select(m => m.Name).ToArray();
var rowsMod = mods.Length + 1;
@@ -67,17 +67,9 @@
|
}
@if (i < bins.Length) {
- var (b, n) = bins[i];
- string name = "";
- switch (n) {
- case 1: name = $"geb. {p.SortId}{string.Join("", p.Attributes.Order().Select(a => a.AttrId).Take(2))}"; break;
- case 2: name = $"geb. {p.SortId}{p.Attributes.Select(a => a.AttrId).Order().FirstOrDefault()}"; break;
- case 3: name = $"geb. {p.SortId}{p.Attributes.Select(a => a.AttrId).Order().Skip(1).FirstOrDefault()}"; break;
- case 4: name = $"geb. {p.SortId}"; break;
- case 5: name = "ungeb."; break;
- }
- @name: |
- @($"{b:N0}") |
+ var bin = bins[i];
+ @(bin.Discr == "_" ? "ungeb." : $"geb. {p.SortId}{bin.Discr}"): |
+ @($"{bin.Value:N0}") |
} else {
|
}
@@ -97,4 +89,6 @@
+
+
diff --git a/Elwig/Helpers/AppDbUpdater.cs b/Elwig/Helpers/AppDbUpdater.cs
index 8ffc35f..f493fe8 100644
--- a/Elwig/Helpers/AppDbUpdater.cs
+++ b/Elwig/Helpers/AppDbUpdater.cs
@@ -81,60 +81,37 @@ namespace Elwig.Helpers {
}
private static void UpdateDbSchema_2_To_3(SqliteConnection cnx) {
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_1_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_2_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_3_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_4_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_5_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_6_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_7_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_8_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, "ALTER TABLE season ADD COLUMN bin_9_name TEXT DEFAULT NULL");
- ExecuteNonQuery(cnx, """
- UPDATE season
- SET bin_1_name = n.bucket_1_name,
- bin_2_name = n.bucket_2_name,
- bin_3_name = n.bucket_3_name,
- bin_4_name = n.bucket_4_name,
- bin_5_name = n.bucket_5_name,
- bin_6_name = n.bucket_6_name,
- bin_7_name = n.bucket_7_name,
- bin_8_name = n.bucket_8_name,
- bin_9_name = n.bucket_9_name
- FROM (SELECT year, bucket_1_name, bucket_2_name, bucket_3_name, bucket_4_name, bucket_5_name, bucket_6_name, bucket_7_name, bucket_8_name, bucket_9_name
- FROM payment_variant GROUP BY year HAVING avnr = MAX(avnr)) AS n
- WHERE season.year = n.year
- """);
ExecuteNonQuery(cnx, """
CREATE TABLE delivery_part_bin (
year INTEGER NOT NULL,
did INTEGER NOT NULL,
dpnr INTEGER NOT NULL,
+ binnr INTEGER NOT NULL,
- bin_1 INTEGER DEFAULT NULL,
- bin_2 INTEGER DEFAULT NULL,
- bin_3 INTEGER DEFAULT NULL,
- bin_4 INTEGER DEFAULT NULL,
- bin_5 INTEGER DEFAULT NULL,
- bin_6 INTEGER DEFAULT NULL,
- bin_7 INTEGER DEFAULT NULL,
- bin_8 INTEGER DEFAULT NULL,
- bin_9 INTEGER DEFAULT NULL,
+ discr TEXT NOT NULL,
+ value INTEGER NOT NULL,
- CONSTRAINT pk_delivery_part_bin PRIMARY KEY (year, did, dpnr),
+ CONSTRAINT pk_delivery_part_bin PRIMARY KEY (year, did, dpnr, binnr),
CONSTRAINT fk_delivery_part_bin_delivery_part FOREIGN KEY (year, did, dpnr) REFERENCES delivery_part (year, did, dpnr)
ON UPDATE CASCADE
ON DELETE CASCADE
) STRICT;
""");
ExecuteNonQuery(cnx, """
- INSERT INTO delivery_part_bin
- (year, did, dpnr, bin_1, bin_2, bin_3, bin_4, bin_5, bin_6, bin_7, bin_8, bin_9)
- SELECT year, did, dpnr, bucket_1, bucket_2, bucket_3, bucket_4, bucket_5, bucket_6, bucket_7, bucket_8, bucket_9
+ INSERT INTO delivery_part_bin (year, did, dpnr, binnr, discr, value)
+ SELECT year, did, dpnr, 0, '_', bucket_2 + bucket_3
FROM payment_delivery_part
WHERE COALESCE(bucket_1, bucket_2, bucket_3, bucket_4, bucket_5, bucket_6, bucket_7, bucket_8, bucket_9) IS NOT NULL
ON CONFLICT DO NOTHING;
""");
+ ExecuteNonQuery(cnx, """
+ INSERT INTO delivery_part_bin (year, did, dpnr, binnr, discr, value)
+ SELECT d.year, d.did, d.dpnr, 1, COALESCE(attributes, ''), bucket_1
+ FROM payment_delivery_part p
+ JOIN v_delivery d ON (d.year, d.did, d.dpnr) = (p.year, p.did, p.dpnr)
+ WHERE COALESCE(bucket_1, bucket_2, bucket_3, bucket_4, bucket_5, bucket_6, bucket_7, bucket_8, bucket_9) IS NOT NULL
+ ON CONFLICT DO NOTHING;
+ """);
ExecuteNonQuery(cnx, "ALTER TABLE payment_delivery_part DROP COLUMN bucket_1");
ExecuteNonQuery(cnx, "ALTER TABLE payment_delivery_part DROP COLUMN bucket_2");
ExecuteNonQuery(cnx, "ALTER TABLE payment_delivery_part DROP COLUMN bucket_3");
@@ -175,10 +152,11 @@ namespace Elwig.Helpers {
JOIN member m ON m.mgnr = d.mgnr
LEFT JOIN delivery_part_attribute pa ON (pa.year, pa.did, pa.dpnr) = (p.year, p.did, p.dpnr)
LEFT JOIN wine_attribute a ON a.attrid = pa.attrid
- GROUP BY p.year, p.did, p.dpnr) s
+ GROUP BY p.year, p.did, p.dpnr
+ ORDER BY p.year, p.did, p.dpnr, a.attrid) s
LEFT JOIN delivery_part_modifier o ON (o.year, o.did, o.dpnr) = (s.year, s.did, s.dpnr)
GROUP BY s.year, s.lsnr, s.dpnr
- ORDER BY s.year, s.lsnr, s.dpnr;
+ ORDER BY s.year, s.lsnr, s.dpnr, o.modid;
""");
ExecuteNonQuery(cnx, "DROP VIEW v_bucket");
@@ -192,9 +170,19 @@ namespace Elwig.Helpers {
ORDER BY year, mgnr, LENGTH(bin) DESC, bin;
""");
- ExecuteNonQuery(cnx, "ALTER TABLE wine_attribute ADD COLUMN fill_lower_bins INTEGER NOT NULL CHECK (fill_lower_bins IN (0, 1, 2)) DEFAULT 0");
+ ExecuteNonQuery(cnx, """
+ CREATE VIEW v_payment_bin AS
+ SELECT d.year, d.mgnr,
+ sortid || discr AS bin,
+ SUM(value) AS weight
+ FROM v_delivery d
+ JOIN delivery_part_bin b ON (b.year, b.did, b.dpnr) = (d.year, d.did, d.dpnr)
+ GROUP BY d.year, d.mgnr, bin
+ HAVING SUM(value) > 0
+ ORDER BY d.year, d.mgnr, bin;
+ """);
- ExecuteNonQuery(cnx, "UPDATE delivery_part_bin SET bin_2 = bin_2 + bin_3, bin_3 = NULL WHERE bin_4 IS NULL");
+ ExecuteNonQuery(cnx, "ALTER TABLE wine_attribute ADD COLUMN fill_lower_bins INTEGER NOT NULL CHECK (fill_lower_bins IN (0, 1, 2)) DEFAULT 0");
}
}
}
diff --git a/Elwig/Helpers/Billing/Billing.cs b/Elwig/Helpers/Billing/Billing.cs
index e14c30a..e006d81 100644
--- a/Elwig/Helpers/Billing/Billing.cs
+++ b/Elwig/Helpers/Billing/Billing.cs
@@ -26,20 +26,16 @@ namespace Elwig.Helpers.Billing {
using (var cmd = cnx.CreateCommand()) {
cmd.CommandText = $"""
UPDATE season
- SET (start_date, end_date) = (SELECT MIN(date), MAX(date) FROM delivery WHERE year = {Year}),
- bin_1_name = 'gebunden mit zwei Attributen',
- bin_2_name = 'gebunden mit (erstem) Attribut',
- bin_3_name = 'gebunden mit zweitem Attribut',
- bin_4_name = 'gebunden ohne Attribut',
- bin_5_name = 'ungebunden',
- bin_6_name = NULL,
- bin_7_name = NULL,
- bin_8_name = NULL,
- bin_9_name = NULL
+ SET (start_date, end_date) = (SELECT MIN(date), MAX(date) FROM delivery WHERE year = {Year})
WHERE year = {Year}
""";
await cmd.ExecuteNonQueryAsync();
}
+
+ using (var cmd = cnx.CreateCommand()) {
+ cmd.CommandText = $"DELETE FROM delivery_part_bin WHERE year = {Year}";
+ await cmd.ExecuteNonQueryAsync();
+ }
}
public async Task CalculateBins(bool allowAttrsIntoLowerBins, bool avoidUnderDeliveries, bool honorGebunden) {
@@ -47,7 +43,7 @@ namespace Elwig.Helpers.Billing {
var attrForced = attrVals.Where(a => a.Value == 0).Select(a => a.Key).ToArray();
using var cnx = await AppDbContext.ConnectAsync();
var memberOblRig = await GetMemberRightsObligations(cnx, Year);
- var inserts = new List<(int, int, int, int, int, int, int)>();
+ var inserts = new List<(int, int, int, string, int)>();
var deliveries = new List<(int, int, int, string, int, double, string, string[], string[], bool?)>();
using (var cmd = cnx.CreateCommand()) {
@@ -91,7 +87,7 @@ namespace Elwig.Helpers.Billing {
// Mitglied hat keine Flächenbindungen, oder
// Nicht mindestens Qualitätswein (QUW)
// -> ungebunden
- inserts.Add((did, dpnr, 0, 0, 0, 0, weight));
+ inserts.Add((did, dpnr, 0, "_", weight));
continue;
}
@@ -99,44 +95,36 @@ namespace Elwig.Helpers.Billing {
throw new NotSupportedException();
int w = weight;
- int[] b = new int[4];
foreach (var p in Utils.Permutate(attributes, attributes.Intersect(attrForced))) {
var c = p.Count();
var key = sortid + string.Join("", p);
if (rights.ContainsKey(key) && obligations.ContainsKey(key)) {
- int i = 0;
+ int i = 4;
if (c == 1) {
- i = (p.ElementAt(0) == attributes[0]) ? 1 : 2;
+ i = (p.ElementAt(0) == attributes[0]) ? 2 : 3;
} else if (c == 0) {
- i = b.Length - 1;
+ i = 1;
}
- var vr = Math.Max(0, Math.Min(rights[key] - used.GetValueOrDefault(key, 0), w));
- var vo = Math.Max(0, Math.Min(obligations[key] - used.GetValueOrDefault(key, 0), w));
+ var u = used.GetValueOrDefault(key, 0);
+ var vr = Math.Max(0, Math.Min(rights[key] - u, w));
+ var vo = Math.Max(0, Math.Min(obligations[key] - u, w));
var v = (c == 0 || p.Select(a => attrVals[a]).Min() == 2) ? vr : vo;
- b[i] += v;
- used[key] = used.GetValueOrDefault(key, 0) + v;
+ used[key] = u + v;
+ inserts.Add((did, dpnr, i, key[2..], v));
w -= v;
}
if (w == 0 || !allowAttrsIntoLowerBins) break;
}
- inserts.Add((did, dpnr, b[0], b[1], b[2], b[3], weight - b[0] - b[1] - b[2] - b[3]));
+ inserts.Add((did, dpnr, 0, "_", w));
lastMgNr = mgnr;
}
using (var cmd = cnx.CreateCommand()) {
cmd.CommandText = $"""
- INSERT INTO delivery_part_bin (year, did, dpnr, bin_1, bin_2, bin_3, bin_4, bin_5)
- VALUES {string.Join(",\n ", inserts.Select(i => $"({Year}, {i.Item1}, {i.Item2}, {i.Item3}, {i.Item4}, {i.Item5}, {i.Item6}, {i.Item7})"))}
+ INSERT INTO delivery_part_bin (year, did, dpnr, binnr, discr, value)
+ VALUES {string.Join(",\n ", inserts.Select(i => $"({Year}, {i.Item1}, {i.Item2}, {i.Item3}, '{i.Item4}', {i.Item5})"))}
ON CONFLICT DO UPDATE
- SET bin_1 = excluded.bin_1,
- bin_2 = excluded.bin_2,
- bin_3 = excluded.bin_3,
- bin_4 = excluded.bin_4,
- bin_5 = excluded.bin_5,
- bin_6 = NULL,
- bin_7 = NULL,
- bin_8 = NULL,
- bin_9 = NULL;
+ SET discr = excluded.discr, value = value + excluded.value
""";
await cmd.ExecuteNonQueryAsync();
}
diff --git a/Elwig/Models/DeliveryPart.cs b/Elwig/Models/DeliveryPart.cs
index f285429..d74015a 100644
--- a/Elwig/Models/DeliveryPart.cs
+++ b/Elwig/Models/DeliveryPart.cs
@@ -118,10 +118,6 @@ namespace Elwig.Models {
public string OriginString => Origin.OriginString + "\n" + (Kg?.Gl != null ? $" / {Kg.Gl.Name}" : "") + (Kg != null ? $" / {Kg.AtKg.Gem.Name} / KG {Kg.AtKg.Name}" : "") + (Rd != null ? $" / Ried {Rd.Name}" : "");
[InverseProperty("Part")]
- public virtual DeliveryPartBin? Bin { get; private set; }
-
- [NotMapped]
- public int[] Bins => (new int?[] { Bin?.Bin1, Bin?.Bin2, Bin?.Bin3, Bin?.Bin4, Bin?.Bin5, Bin?.Bin6, Bin?.Bin7, Bin?.Bin8, Bin?.Bin9 })
- .Where(b => b != null).Select(b => b.Value).ToArray();
+ public virtual ISet Bins { get; private set; }
}
}
diff --git a/Elwig/Models/DeliveryPartBin.cs b/Elwig/Models/DeliveryPartBin.cs
index 576c833..a441760 100644
--- a/Elwig/Models/DeliveryPartBin.cs
+++ b/Elwig/Models/DeliveryPartBin.cs
@@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Elwig.Models {
- [Table("delivery_part_bin"), PrimaryKey("Year", "DId", "DPNr")]
+ [Table("delivery_part_bin"), PrimaryKey("Year", "DId", "DPNr", "BinNr")]
public class DeliveryPartBin {
[Column("year")]
public int Year { get; set; }
@@ -13,34 +13,16 @@ namespace Elwig.Models {
[Column("dpnr")]
public int DPNr { get; set; }
+ [Column("binnr")]
+ public int BinNr { get; set; }
+
+ [Column("discr")]
+ public string Discr { get; set; }
+
+ [Column("value")]
+ public int Value { get; set; }
+
[ForeignKey("Year, DId, DPNr")]
public virtual DeliveryPart Part { get; private set; }
-
- [Column("bin_1")]
- public int? Bin1 { get; set; }
-
- [Column("bin_2")]
- public int? Bin2 { get; set; }
-
- [Column("bin_3")]
- public int? Bin3 { get; set; }
-
- [Column("bin_4")]
- public int? Bin4 { get; set; }
-
- [Column("bin_5")]
- public int? Bin5 { get; set; }
-
- [Column("bin_6")]
- public int? Bin6 { get; set; }
-
- [Column("bin_7")]
- public int? Bin7 { get; set; }
-
- [Column("bin_8")]
- public int? Bin8 { get; set; }
-
- [Column("bin_9")]
- public int? Bin9 { get; set; }
}
}
diff --git a/Elwig/Models/PaymentDeliveryPart.cs b/Elwig/Models/PaymentDeliveryPart.cs
index 7266282..a6db7a2 100644
--- a/Elwig/Models/PaymentDeliveryPart.cs
+++ b/Elwig/Models/PaymentDeliveryPart.cs
@@ -1,7 +1,5 @@
using Microsoft.EntityFrameworkCore;
-using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
namespace Elwig.Models {
[Table("payment_delivery_part"), PrimaryKey("Year", "DId", "DPNr", "AvNr")]
@@ -34,78 +32,6 @@ namespace Elwig.Models {
set => ModRelValue = (double)value;
}
- [Column("price_1")]
- public long? Price1Value { get; set; }
- [NotMapped]
- public decimal? Price1 {
- get => Price1Value != null ? Variant.Season.DecFromDb(Price1Value.Value) : null;
- set => Price1Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_2")]
- public long? Price2Value { get; set; }
- [NotMapped]
- public decimal? Price2 {
- get => Price2Value != null ? Variant.Season.DecFromDb(Price2Value.Value) : null;
- set => Price2Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_3")]
- public long? Price3Value { get; set; }
- [NotMapped]
- public decimal? Price3 {
- get => Price3Value != null ? Variant.Season.DecFromDb(Price3Value.Value) : null;
- set => Price3Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_4")]
- public long? Price4Value { get; set; }
- [NotMapped]
- public decimal? Price4 {
- get => Price4Value != null ? Variant.Season.DecFromDb(Price4Value.Value) : null;
- set => Price4Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_5")]
- public long? Price5Value { get; set; }
- [NotMapped]
- public decimal? Price5 {
- get => Price5Value != null ? Variant.Season.DecFromDb(Price5Value.Value) : null;
- set => Price5Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_6")]
- public long? Price6Value { get; set; }
- [NotMapped]
- public decimal? Price6 {
- get => Price6Value != null ? Variant.Season.DecFromDb(Price6Value.Value) : null;
- set => Price6Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_7")]
- public long? Price7Value { get; set; }
- [NotMapped]
- public decimal? Price7 {
- get => Price7Value != null ? Variant.Season.DecFromDb(Price7Value.Value) : null;
- set => Price7Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_8")]
- public long? Price8Value { get; set; }
- [NotMapped]
- public decimal? Price8 {
- get => Price8Value != null ? Variant.Season.DecFromDb(Price8Value.Value) : null;
- set => Price8Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
- [Column("price_9")]
- public long? Price9Value { get; set; }
- [NotMapped]
- public decimal? Price9 {
- get => Price9Value != null ? Variant.Season.DecFromDb(Price9Value.Value) : null;
- set => Price9Value = value != null ? Variant.Season.DecToDb(value.Value) : null;
- }
-
[Column("amount")]
public long? AmountValue { get; set; }
[NotMapped]
@@ -114,10 +40,6 @@ namespace Elwig.Models {
set => AmountValue = value != null ? Variant.Season.DecToDb(value.Value) : null;
}
- [NotMapped]
- public decimal[] Prices => (new decimal?[] { Price1, Price2, Price3, Price4, Price5, Price6, Price7, Price8, Price9 })
- .Where(p => p != null).Select(p => p.Value).ToArray();
-
[ForeignKey("Year, AvNr")]
public virtual PaymentVar Variant { get; private set; }
diff --git a/Elwig/Models/PaymentDeliveryPartBin.cs b/Elwig/Models/PaymentDeliveryPartBin.cs
new file mode 100644
index 0000000..5c1e3b0
--- /dev/null
+++ b/Elwig/Models/PaymentDeliveryPartBin.cs
@@ -0,0 +1,44 @@
+using Microsoft.EntityFrameworkCore;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace Elwig.Models {
+ [Table("payment_delivery_part_bin"), PrimaryKey("Year", "DId", "DPNr", "BinNr", "AvNr")]
+ public class PaymentDeliveryPartBin {
+ [Column("year")]
+ public int Year { get; set; }
+
+ [Column("did")]
+ public int DId { get; set; }
+
+ [Column("dpnr")]
+ public int DPNr { get; set; }
+
+ [Column("binnr")]
+ public int BinNr { get; set; }
+
+ [Column("avnr")]
+ public int AvNr { get; set; }
+
+ [Column("price")]
+ public long PriceValue { get; set; }
+ [NotMapped]
+ public decimal Price {
+ get => Variant.Season.DecFromDb(PriceValue);
+ set => PriceValue = Variant.Season.DecToDb(value);
+ }
+
+ [Column("amount")]
+ public long AmountValue { get; set; }
+ [NotMapped]
+ public decimal Amount {
+ get => Variant.Season.DecFromDb(AmountValue);
+ set => AmountValue = Variant.Season.DecToDb(value);
+ }
+
+ [ForeignKey("Year, AvNr")]
+ public virtual PaymentVar Variant { get; private set; }
+
+ [ForeignKey("Year, DId, DPNr")]
+ public virtual DeliveryPart DeliveryPart { get; private set; }
+ }
+}
diff --git a/Elwig/Models/Season.cs b/Elwig/Models/Season.cs
index 834a93c..6c6d09d 100644
--- a/Elwig/Models/Season.cs
+++ b/Elwig/Models/Season.cs
@@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
namespace Elwig.Models {
[Table("season"), PrimaryKey("Year")]
@@ -43,37 +42,6 @@ namespace Elwig.Models {
}
}
- [Column("bin_1_name")]
- public string? Bin1Name { get; set; }
-
- [Column("bin_2_name")]
- public string? Bin2Name { get; set; }
-
- [Column("bin_3_name")]
- public string? Bin3Name { get; set; }
-
- [Column("bin_4_name")]
- public string? Bin4Name { get; set; }
-
- [Column("bin_5_name")]
- public string? Bin5Name { get; set; }
-
- [Column("bin_6_name")]
- public string? Bin6Name { get; set; }
-
- [Column("bin_7_name")]
- public string? Bin7Name { get; set; }
-
- [Column("bin_8_name")]
- public string? Bin8Name { get; set; }
-
- [Column("bin_9_name")]
- public string? Bin9Name { get; set; }
-
- [NotMapped]
- public string[] BinNames => (new string?[] { Bin1Name, Bin2Name, Bin3Name, Bin4Name, Bin5Name, Bin6Name, Bin7Name, Bin8Name, Bin9Name })
- .Where(n => n != null).Select(n => n ?? "").ToArray();
-
[ForeignKey("CurrencyCode")]
public virtual Currency Currency { get; private set; }