Database: Change bins once again...
This commit is contained in:
@ -70,12 +70,14 @@
|
||||
<td rowspan="@binNum" class="kmw">@($"{part.Kmw:N1}")</td>
|
||||
<td rowspan="@binNum" class="abs">@abs</td>
|
||||
<td rowspan="@binNum" class="rel">@rel</td>
|
||||
@Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(0), pmt?.Prices?.ElementAtOrDefault(0)))
|
||||
<!--FIXME price-->
|
||||
@Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(0)?.Value, 0))
|
||||
<td rowspan="@binNum" class="amount sum">@($"{pmt?.Amount:N2}")</td>
|
||||
</tr>
|
||||
@for (int i = 1; i < binNum; i++) {
|
||||
<tr class="@(i == binNum - 1 ? "last" : "")">
|
||||
@Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(i), pmt?.Prices?.ElementAtOrDefault(i)))
|
||||
<!--FIXME price-->
|
||||
@Raw(FormatRow(pmt?.DeliveryPart.Bins?.ElementAtOrDefault(i)?.Value, 0))
|
||||
</tr>
|
||||
}
|
||||
last = part.SortId;
|
||||
|
@ -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.*
|
||||
|
@ -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 @@
|
||||
<td colspan="3"></td>
|
||||
}
|
||||
@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;
|
||||
}
|
||||
<td class="geb">@name:</td>
|
||||
<td class="weight">@($"{b:N0}")</td>
|
||||
var bin = bins[i];
|
||||
<td class="geb">@(bin.Discr == "_" ? "ungeb." : $"geb. {p.SortId}{bin.Discr}"):</td>
|
||||
<td class="weight">@($"{bin.Value:N0}")</td>
|
||||
} else {
|
||||
<td colspan="2"></td>
|
||||
}
|
||||
@ -97,4 +89,6 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- TODO add Gesamtlieferung tabelle -->
|
||||
<!-- TODO add Freitext -->
|
||||
</main>
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<DeliveryPartBin> Bins { get; private set; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
44
Elwig/Models/PaymentDeliveryPartBin.cs
Normal file
44
Elwig/Models/PaymentDeliveryPartBin.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
|
Reference in New Issue
Block a user