diff --git a/Elwig/Documents/DeliveryNote.cshtml b/Elwig/Documents/DeliveryNote.cshtml
index a22b33f..fa96c64 100644
--- a/Elwig/Documents/DeliveryNote.cshtml
+++ b/Elwig/Documents/DeliveryNote.cshtml
@@ -7,12 +7,15 @@
@Model.Title
@{ var forcePageBreak = Model.Delivery.Parts.Count > 2; }
@if (forcePageBreak) {
+
Siehe nächste Seite.
- if (Model.Delivery.Year == Model.CurrentNextSeason) {
-
- Gesamtlieferung usw.
- Flächenbindung-Lieferrecht/-pflicht usw.
- }
+ // JS delivery-stats
}
@@ -84,8 +87,56 @@
@if (Model.Delivery.Comment != null) {
}
-@if (!forcePageBreak && Model.Delivery.Year == Model.CurrentNextSeason) {
- Gesamtlieferung usw.
+@if (true || Model.Delivery.Year == Model.CurrentNextSeason) {
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Gesamtlieferung [kg] |
+ Lieferpflicht |
+ Lieferrecht |
+ Unterliefert |
+ Noch zu liefern |
+ Überliefert |
+ Geliefert |
+
+
+
+ @{
+ string FormatRow(int obligation, int right, int sum) {
+ return $"{obligation:N0} | " +
+ $"{right:N0} | " +
+ $"{(sum < obligation ? $"{obligation - sum:N0}" : "-")} | " +
+ $"{(sum >= obligation && sum <= right ? $"{right - sum:N0}" : "-")} | " +
+ $"{(sum > right ? $"{sum - right:N0}" : "-")} | " +
+ $"{sum:N0} | ";
+ }
+ var sortids = Model.Delivery.Parts.Select(p => p.SortId).ToList();
+ }
+
+ Geschäftsanteile |
+ @Raw(FormatRow(Model.Member.DeliveryObligation, Model.Member.DeliveryRight, Model.Member.Deliveries.Where(d => d.Year == Model.Delivery.Year).Sum(d => d.Weight)))
+
+ @foreach (var (id, name, right, obligation, sum) in Model.MemberBuckets.OrderBy(b => b.Item1)) {
+ if (right > 0 && obligation > 0) {
+
+ @name |
+ @Raw(FormatRow(obligation, right, sum))
+
+ }
+ }
+
+
+
}
@for (int i = 0; i < 2; i++) {
diff --git a/Elwig/Documents/DeliveryNote.cshtml.cs b/Elwig/Documents/DeliveryNote.cshtml.cs
index 0f83a16..999f85e 100644
--- a/Elwig/Documents/DeliveryNote.cshtml.cs
+++ b/Elwig/Documents/DeliveryNote.cshtml.cs
@@ -1,12 +1,15 @@
+using Elwig.Helpers;
using Elwig.Models;
+using System.Collections.Generic;
namespace Elwig.Documents {
public class DeliveryNote : BusinessDocument {
public Delivery Delivery;
public string? Text;
+ public IEnumerable<(string, string, int, int, int)> MemberBuckets;
- public DeliveryNote(Delivery d) : base($"Traubenübernahmeschein Nr. {d.LsNr}", d.Member) {
+ public DeliveryNote(Delivery d, AppDbContext ctx) : base($"Traubenübernahmeschein Nr. {d.LsNr}", d.Member) {
Delivery = d;
Aside = Aside.Replace("
", "") +
$"Lieferung |
" +
@@ -16,6 +19,7 @@ namespace Elwig.Documents {
$"";
Text = App.Client.DeliveryNoteText;
DocumentId = d.LsNr;
+ MemberBuckets = ctx.GetMemberBuckets(d.Member, d.Year).GetAwaiter().GetResult();
}
}
}
diff --git a/Elwig/Documents/style.css b/Elwig/Documents/style.css
index a0ba588..19b58a5 100644
--- a/Elwig/Documents/style.css
+++ b/Elwig/Documents/style.css
@@ -206,7 +206,7 @@ table {
}
table.delivery {
- margin-bottom: 1cm;
+ margin-bottom: 5mm;
}
table.delivery th {
@@ -249,6 +249,43 @@ table.delivery tr.sum td {
padding-top: 1mm;
}
+table.delivery-stats {
+ font-size: 8pt;
+}
+
+table.delivery-stats:not(.expanded) th,
+table.delivery-stats:not(.expanded) td {
+ padding: 0.125mm 0.5mm;
+}
+
+table.delivery-stats:not(.expanded) tr.optional {
+ display: none;
+}
+
+table.delivery-stats thead th {
+ font-weight: normal;
+ font-style: italic;
+ text-align: right;
+}
+
+table.delivery-stats thead th:first-child {
+ text-align: left;
+}
+
+table.delivery-stats.expanded tbody {
+ font-size: 10pt;
+}
+
+table.delivery-stats td {
+ text-align: right;
+}
+
+table.delivery-stats tbody th {
+ font-weight: normal;
+ font-style: italic;
+ text-align: left;
+}
+
.hidden {
visibility: hidden;
}
diff --git a/Elwig/Helpers/AppDbContext.cs b/Elwig/Helpers/AppDbContext.cs
index a9dc8b0..42d403c 100644
--- a/Elwig/Helpers/AppDbContext.cs
+++ b/Elwig/Helpers/AppDbContext.cs
@@ -202,5 +202,27 @@ namespace Elwig.Helpers {
}
}
}
+
+ public async Task> GetMemberBuckets(Member m, int year) {
+ using var cnx = await ConnectAsync();
+ var (rights, obligations) = await Billing.Billing.GetMemberRightsObligations(m.MgNr, year, cnx);
+ var buckets = await Billing.Billing.GetMemberBucketWeights(m.MgNr, year, cnx);
+
+ var list = new List<(string, string, int, int, int)>();
+ foreach (var id in rights.Keys.Union(obligations.Keys).Union(buckets.Keys)) {
+ var s = await WineVarieties.FindAsync(id[..2]);
+ var attrIds = id[2..];
+ var a = await WineAttributes.Where(a => attrIds.Contains(a.AttrId)).ToListAsync();
+ var name = (s?.Name ?? "") + (a.Count > 0 ? $" ({string.Join(" / ", a.Select(a => a.Name))})" : "");
+ list.Add((
+ id, name,
+ rights.TryGetValue(id, out var v1) ? v1 : 0,
+ obligations.TryGetValue(id, out var v2) ? v2 : 0,
+ buckets.TryGetValue(id, out var v3) ? v3 : 0
+ ));
+ }
+
+ return list;
+ }
}
}
diff --git a/Elwig/Models/Member.cs b/Elwig/Models/Member.cs
index f523c10..c7daa57 100644
--- a/Elwig/Models/Member.cs
+++ b/Elwig/Models/Member.cs
@@ -176,6 +176,9 @@ namespace Elwig.Models {
public string FullAddress => $"{Address}, {PostalDest.AtPlz.Plz} {PostalDest.AtPlz.Ort.Name}";
+ public int DeliveryRight => BusinessShares * App.Client.DeliveryRight;
+ public int DeliveryObligation => BusinessShares * App.Client.DeliveryObligation;
+
public int SearchScore(IEnumerable keywords) {
return Utils.GetSearchScore(new string?[] {
MgNr.ToString(),
diff --git a/Elwig/Windows/DeliveryAdminWindow.xaml.cs b/Elwig/Windows/DeliveryAdminWindow.xaml.cs
index f6ca088..0605536 100644
--- a/Elwig/Windows/DeliveryAdminWindow.xaml.cs
+++ b/Elwig/Windows/DeliveryAdminWindow.xaml.cs
@@ -106,14 +106,14 @@ namespace Elwig.Windows {
private async void Menu_Print_ShowDeliveryNote_Click(object sender, RoutedEventArgs evt) {
if (DeliveryList.SelectedItem is not Delivery d) return;
- using var doc = new DeliveryNote(d);
+ using var doc = new DeliveryNote(d, Context);
await doc.Generate();
doc.Show();
}
private async void Menu_Print_PrintDeliveryNote_Click(object sender, RoutedEventArgs evt) {
if (DeliveryList.SelectedItem is not Delivery d) return;
- using var doc = new DeliveryNote(d);
+ using var doc = new DeliveryNote(d, Context);
await doc.Generate();
await doc.Print();
}
@@ -714,7 +714,7 @@ namespace Elwig.Windows {
await RefreshDeliveryList();
await RefreshDeliveryParts();
if (p?.Delivery != null) {
- using var doc = new DeliveryNote(p.Delivery);
+ using var doc = new DeliveryNote(p.Delivery, Context);
await doc.Generate();
doc.Show();
//await doc.Print(2);
diff --git a/Elwig/Windows/MainWindow.xaml.cs b/Elwig/Windows/MainWindow.xaml.cs
index a0c9211..ec20564 100644
--- a/Elwig/Windows/MainWindow.xaml.cs
+++ b/Elwig/Windows/MainWindow.xaml.cs
@@ -41,7 +41,7 @@ namespace Elwig.Windows {
private void PdfButton_Click(object sender, RoutedEventArgs evt) {
Utils.RunBackground("PDF Generation", async () => {
using var ctx = new AppDbContext();
- using var doc = new DeliveryNote(ctx.Deliveries.OrderBy(d => d.Parts.Count).ThenBy(d => d.Year).ThenBy(d => d.DId).Last());
+ using var doc = new DeliveryNote(ctx.Deliveries.OrderBy(d => d.Parts.Count).ThenBy(d => d.Year).ThenBy(d => d.DId).Last(), ctx);
await doc.Generate();
doc.Show();
});