Add Gesamtlieferung to DeliveryNote

This commit is contained in:
2023-08-30 14:18:43 +02:00
parent 75e6c1bd5d
commit 9b84452b86
7 changed files with 130 additions and 13 deletions

View File

@ -7,12 +7,15 @@
<h1>@Model.Title</h1>
@{ var forcePageBreak = Model.Delivery.Parts.Count > 2; }
@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>
if (Model.Delivery.Year == Model.CurrentNextSeason) {
<!-- TODO Gesamtlieferung -->
<p>Gesamtlieferung usw.</p>
<p>Flächenbindung-Lieferrecht/-pflicht usw.</p>
}
// JS delivery-stats
<hr class="page-break"/>
}
<table class="delivery">
@ -84,8 +87,56 @@
@if (Model.Delivery.Comment != null) {
<p class="comment">Amerkung zur Lieferung: @Model.Delivery.Comment</p>
}
@if (!forcePageBreak && Model.Delivery.Year == Model.CurrentNextSeason) {
<p>Gesamtlieferung usw.</p>
@if (true || Model.Delivery.Year == Model.CurrentNextSeason) {
<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++) {
<div class="@(i == 0 ? "hidden" : "bottom")">