Add Gesamtlieferung to DeliveryNote
This commit is contained in:
@ -7,12 +7,15 @@
|
|||||||
<h1>@Model.Title</h1>
|
<h1>@Model.Title</h1>
|
||||||
@{ var forcePageBreak = Model.Delivery.Parts.Count > 2; }
|
@{ var forcePageBreak = Model.Delivery.Parts.Count > 2; }
|
||||||
@if (forcePageBreak) {
|
@if (forcePageBreak) {
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const stats = document.getElementById("delivery-stats");
|
||||||
|
document.getElementsByClassName("page-break")[0].before(stats);
|
||||||
|
stats.getElementsByTagName("table")[0].classList.add("expanded");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<p>Siehe nächste Seite.</p>
|
<p>Siehe nächste Seite.</p>
|
||||||
if (Model.Delivery.Year == Model.CurrentNextSeason) {
|
// JS delivery-stats
|
||||||
<!-- TODO Gesamtlieferung -->
|
|
||||||
<p>Gesamtlieferung usw.</p>
|
|
||||||
<p>Flächenbindung-Lieferrecht/-pflicht usw.</p>
|
|
||||||
}
|
|
||||||
<hr class="page-break"/>
|
<hr class="page-break"/>
|
||||||
}
|
}
|
||||||
<table class="delivery">
|
<table class="delivery">
|
||||||
@ -84,8 +87,56 @@
|
|||||||
@if (Model.Delivery.Comment != null) {
|
@if (Model.Delivery.Comment != null) {
|
||||||
<p class="comment">Amerkung zur Lieferung: @Model.Delivery.Comment</p>
|
<p class="comment">Amerkung zur Lieferung: @Model.Delivery.Comment</p>
|
||||||
}
|
}
|
||||||
@if (!forcePageBreak && Model.Delivery.Year == Model.CurrentNextSeason) {
|
@if (true || Model.Delivery.Year == Model.CurrentNextSeason) {
|
||||||
<p>Gesamtlieferung usw.</p>
|
<div id="delivery-stats">
|
||||||
|
<table class="delivery-stats">
|
||||||
|
<colgroup>
|
||||||
|
<col style="width: 100%;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
<col style="width: 2cm;"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><b>Gesamtlieferung</b> [kg]</th>
|
||||||
|
<th>Lieferpflicht</th>
|
||||||
|
<th>Lieferrecht</th>
|
||||||
|
<th>Unterliefert</th>
|
||||||
|
<th>Noch zu liefern</th>
|
||||||
|
<th>Überliefert</th>
|
||||||
|
<th>Geliefert</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@{
|
||||||
|
string FormatRow(int obligation, int right, int sum) {
|
||||||
|
return $"<td>{obligation:N0}</td>" +
|
||||||
|
$"<td>{right:N0}</td>" +
|
||||||
|
$"<td>{(sum < obligation ? $"{obligation - sum:N0}" : "-")}</td>" +
|
||||||
|
$"<td>{(sum >= obligation && sum <= right ? $"{right - sum:N0}" : "-")}</td>" +
|
||||||
|
$"<td>{(sum > right ? $"{sum - right:N0}" : "-")}</td>" +
|
||||||
|
$"<td>{sum:N0}</td>";
|
||||||
|
}
|
||||||
|
var sortids = Model.Delivery.Parts.Select(p => p.SortId).ToList();
|
||||||
|
}
|
||||||
|
<tr>
|
||||||
|
<th>Geschäftsanteile</th>
|
||||||
|
@Raw(FormatRow(Model.Member.DeliveryObligation, Model.Member.DeliveryRight, Model.Member.Deliveries.Where(d => d.Year == Model.Delivery.Year).Sum(d => d.Weight)))
|
||||||
|
</tr>
|
||||||
|
@foreach (var (id, name, right, obligation, sum) in Model.MemberBuckets.OrderBy(b => b.Item1)) {
|
||||||
|
if (right > 0 && obligation > 0) {
|
||||||
|
<tr class="@(sortids.Contains(id[..2]) ? "" : "optional")">
|
||||||
|
<th>@name</th>
|
||||||
|
@Raw(FormatRow(obligation, right, sum))
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
@for (int i = 0; i < 2; i++) {
|
@for (int i = 0; i < 2; i++) {
|
||||||
<div class="@(i == 0 ? "hidden" : "bottom")">
|
<div class="@(i == 0 ? "hidden" : "bottom")">
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Elwig.Documents {
|
namespace Elwig.Documents {
|
||||||
public class DeliveryNote : BusinessDocument {
|
public class DeliveryNote : BusinessDocument {
|
||||||
|
|
||||||
public Delivery Delivery;
|
public Delivery Delivery;
|
||||||
public string? Text;
|
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;
|
Delivery = d;
|
||||||
Aside = Aside.Replace("</table>", "") +
|
Aside = Aside.Replace("</table>", "") +
|
||||||
$"<thead><tr><th colspan='2'>Lieferung</th></tr></thead><tbody>" +
|
$"<thead><tr><th colspan='2'>Lieferung</th></tr></thead><tbody>" +
|
||||||
@ -16,6 +19,7 @@ namespace Elwig.Documents {
|
|||||||
$"</tbody></table>";
|
$"</tbody></table>";
|
||||||
Text = App.Client.DeliveryNoteText;
|
Text = App.Client.DeliveryNoteText;
|
||||||
DocumentId = d.LsNr;
|
DocumentId = d.LsNr;
|
||||||
|
MemberBuckets = ctx.GetMemberBuckets(d.Member, d.Year).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table.delivery {
|
table.delivery {
|
||||||
margin-bottom: 1cm;
|
margin-bottom: 5mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.delivery th {
|
table.delivery th {
|
||||||
@ -249,6 +249,43 @@ table.delivery tr.sum td {
|
|||||||
padding-top: 1mm;
|
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 {
|
.hidden {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
|
@ -202,5 +202,27 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<(string, string, int, int, int)>> 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,9 @@ namespace Elwig.Models {
|
|||||||
|
|
||||||
public string FullAddress => $"{Address}, {PostalDest.AtPlz.Plz} {PostalDest.AtPlz.Ort.Name}";
|
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<string> keywords) {
|
public int SearchScore(IEnumerable<string> keywords) {
|
||||||
return Utils.GetSearchScore(new string?[] {
|
return Utils.GetSearchScore(new string?[] {
|
||||||
MgNr.ToString(),
|
MgNr.ToString(),
|
||||||
|
@ -106,14 +106,14 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private async void Menu_Print_ShowDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
private async void Menu_Print_ShowDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) return;
|
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.Generate();
|
||||||
doc.Show();
|
doc.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Menu_Print_PrintDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
private async void Menu_Print_PrintDeliveryNote_Click(object sender, RoutedEventArgs evt) {
|
||||||
if (DeliveryList.SelectedItem is not Delivery d) return;
|
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.Generate();
|
||||||
await doc.Print();
|
await doc.Print();
|
||||||
}
|
}
|
||||||
@ -714,7 +714,7 @@ namespace Elwig.Windows {
|
|||||||
await RefreshDeliveryList();
|
await RefreshDeliveryList();
|
||||||
await RefreshDeliveryParts();
|
await RefreshDeliveryParts();
|
||||||
if (p?.Delivery != null) {
|
if (p?.Delivery != null) {
|
||||||
using var doc = new DeliveryNote(p.Delivery);
|
using var doc = new DeliveryNote(p.Delivery, Context);
|
||||||
await doc.Generate();
|
await doc.Generate();
|
||||||
doc.Show();
|
doc.Show();
|
||||||
//await doc.Print(2);
|
//await doc.Print(2);
|
||||||
|
@ -41,7 +41,7 @@ namespace Elwig.Windows {
|
|||||||
private void PdfButton_Click(object sender, RoutedEventArgs evt) {
|
private void PdfButton_Click(object sender, RoutedEventArgs evt) {
|
||||||
Utils.RunBackground("PDF Generation", async () => {
|
Utils.RunBackground("PDF Generation", async () => {
|
||||||
using var ctx = new AppDbContext();
|
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();
|
await doc.Generate();
|
||||||
doc.Show();
|
doc.Show();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user