diff --git a/Elwig/Documents/BusinessDocument.cs b/Elwig/Documents/BusinessDocument.cs index 53b061e..2ac8866 100644 --- a/Elwig/Documents/BusinessDocument.cs +++ b/Elwig/Documents/BusinessDocument.cs @@ -1,5 +1,7 @@ using Elwig.Helpers; using Elwig.Models.Entities; +using System.Collections.Generic; +using System.Linq; namespace Elwig.Documents { public abstract class BusinessDocument : Document { @@ -32,5 +34,93 @@ namespace Elwig.Documents { return (addr is BillingAddr ? $"{addr.Name}\n" : "") + $"{Member.AdministrativeName}\n{addr.Address}\n{plz?.Plz} {plz?.Ort.Name.Split(",")[0]}\n{addr.PostalDest.Country.Name}"; } } + + public string PrintSortenaufteilung(int year, Dictionary buckets) { + return ""; + } + + private enum RowMode { + GA_CONFIRMATION, CONFIRMATION, GA_NOTE, NOTE + } + + private static string FormatRow(RowMode mode, int obligation, int right, int delivery, int? payment = null) { + var isGa = (mode == RowMode.GA_CONFIRMATION || mode == RowMode.GA_NOTE); + var showPayment = (mode == RowMode.GA_CONFIRMATION || mode == RowMode.CONFIRMATION); + payment ??= delivery; + var baseline = showPayment ? payment : delivery; + return $"{(obligation == 0 ? "-" : $"{obligation:N0}")}" + + $"{(right == 0 ? "-" : $"{right:N0}")}" + + $"{(baseline < obligation ? $"{obligation - baseline:N0}" : "-")}" + + $"{(baseline >= obligation && delivery <= right ? $"{right - delivery:N0}" : "-")}" + + $"{(obligation == 0 && right == 0 ? "-" : (delivery > right ? ((isGa ? "" : "") + $"{delivery - right:N0}" + (isGa ? "" : "")) : "-"))}" + + (showPayment ? $"{(isGa ? "" : obligation == 0 && right == 0 ? "-" : $"{payment:N0}")}" : "") + + $"{delivery:N0}"; + } + + private static string FormatRow(RowMode mode, MemberBucket bucket) { + return FormatRow(mode, bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment); + } + + public string PrintBucketTable(Season season, Dictionary buckets, bool includePayment = false, bool isTiny = false, IEnumerable? filter = null) { + int[] colGroups = includePayment ? [45, 17, 17, 17, 19, 16, 17, 17] : [45, 20, 20, 20, 20, 20, 20]; + string tbl = "\n" + string.Join("\n", colGroups.Select(g => $"")) + "\n\n"; + tbl += $""" + + + Lese {season.Year} per {Date:dd.MM.yyyy} [kg] + Lieferpflicht + Lieferrecht + Unterliefert + Noch lieferbar + Überliefert + {(includePayment ? "Zugeteilt" : "")} + Geliefert + + + """; + + var mBuckets = buckets + .Where(b => (b.Value.Right > 0 || b.Value.Obligation > 0 || b.Value.Delivery > 0) && (filter == null || filter.Contains(b.Key[..2]))) + .ToList(); + var fbVars = mBuckets + .Where(b => b.Value.Right > 0 || b.Value.Obligation > 0) + .Select(b => b.Key.Replace("_", "")) + .Order() + .ToArray(); + var fbs = mBuckets + .Where(b => fbVars.Contains(b.Key) && b.Key.Length == 2) + .OrderBy(b => b.Value.Name); + var vtr = mBuckets + .Where(b => fbVars.Contains(b.Key) && b.Key.Length > 2) + .OrderBy(b => b.Value.Name); + var rem = mBuckets + .Where(b => !fbVars.Contains(b.Key)) + .OrderBy(b => b.Value.Name); + + tbl += "\n\n"; + tbl += $"Gesamtlieferung lt. gez. GA{FormatRow( + includePayment ? RowMode.GA_CONFIRMATION : RowMode.GA_NOTE, + Member.BusinessShares * season.MinKgPerBusinessShare, + Member.BusinessShares * season.MaxKgPerBusinessShare, + Member.Deliveries.Where(d => d.Year == season.Year).Sum(d => d.Weight) + )}"; + if (fbs.Any()) { + tbl += $"" + + $"Flächenbindungen{(vtr.Any() ? " (inkl. Verträge)" : "")}:"; + foreach (var (id, b) in fbs) { + tbl += $"{b.Name}{FormatRow(includePayment ? RowMode.CONFIRMATION : RowMode.NOTE, b)}"; + } + } + if (vtr.Any()) { + tbl += $"" + + "Verträge:"; + foreach (var (id, b) in vtr) { + tbl += $"{b.Name}{FormatRow(includePayment ? RowMode.CONFIRMATION : RowMode.NOTE, b)}"; + } + } + tbl += "\n\n"; + + return $"\n" + tbl + "\n
"; + } } } diff --git a/Elwig/Documents/CreditNote.css b/Elwig/Documents/CreditNote.css index d973d40..47088b9 100644 --- a/Elwig/Documents/CreditNote.css +++ b/Elwig/Documents/CreditNote.css @@ -1,49 +1,5 @@ -table.credit { - font-size: 10pt; -} - -table.credit th, -table.credit td { - padding: 0 0.25mm; -} - -table.credit thead { - font-size: 8pt -} - -table.credit thead th { - font-weight: normal; - font-style: italic; - vertical-align: bottom; -} - -table.credit td { - vertical-align: top; -} - -table.credit .oe, -table.credit .kmw { - text-align: center; -} - -table.credit .dpnr { - text-align: center; -} - -table.credit .amount, -table.credit .weight, -table.credit .price { - text-align: right; -} - -table.credit .rel, -table.credit .abs { - text-align: center; -} - table.credit .amount.sum { - vertical-align: bottom; padding-bottom: 1mm; } @@ -59,11 +15,3 @@ table.credit tbody tr.first td { table.credit tbody tr.last td { padding-bottom: 1mm; } - -table.credit tbody tr.new { - border-top: 0.5pt solid black; -} - -table.credit .small { - font-size: 8pt; -} diff --git a/Elwig/Documents/DeliveryConfirmation.cshtml b/Elwig/Documents/DeliveryConfirmation.cshtml index 11cff05..e39c702 100644 --- a/Elwig/Documents/DeliveryConfirmation.cshtml +++ b/Elwig/Documents/DeliveryConfirmation.cshtml @@ -22,7 +22,7 @@ Lieferschein-Nr. - Pos. + Pos. Sorte Attribut Qualitätsstufe @@ -32,11 +32,11 @@ Davon
abzuwerten - [°Oe] - [°KMW] - [kg] - [kg] - [kg] + [°Oe] + [°KMW] + [kg] + [kg] + [kg] @@ -54,28 +54,28 @@ @p.Variant @p.Attribute @p.QualityLevel - @($"{p.Gradation.Oe:N0}") - @($"{p.Gradation.Kmw:N1}") + @($"{p.Gradation.Oe:N0}") + @($"{p.Gradation.Kmw:N1}") } @if (i > 0 && i <= p.Modifiers.Length) { - @(p.Modifiers[i - 1]) + @(p.Modifiers[i - 1]) } else if (i > 0) { } @if (i < p.Buckets.Length) { var bucket = p.Buckets[i]; - @bucket.Name: - @($"{bucket.Value:N0}") + @bucket.Name: + @($"{bucket.Value:N0}") } else { } @if (i == p.Buckets.Length - 1) { - @($"{p.Weight:N0}") + @($"{p.Weight:N0}") } else { } @if (first) { - + first = false; } @@ -84,91 +84,12 @@ } Gesamt: - @($"{Model.Data.Rows.Sum(p => p.Weight):N0}") + @($"{Model.Data.Rows.Sum(p => p.Weight):N0}") - - - - - - - - - - - - - - - - - - - - - - - - - @{ - string FormatRow(int mode, int obligation, int right, int sum, int? payment = null) { - var isGa = mode == 0; - payment ??= sum; - return $"" + - $"" + - $"" + - $"" + - $"" + - $"" + - $""; - } - var mBuckets = Model.MemberBuckets.Where(b => b.Value.Right > 0 || b.Value.Obligation > 0 || b.Value.Delivery > 0).ToList(); - var fbVars = mBuckets.Where(b => b.Value.Right > 0 || b.Value.Obligation > 0).Select(b => b.Key.Replace("_", "")).Order().ToArray(); - var fbs = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length == 2).OrderBy(b => b.Value.Name); - var vtr = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length > 2).OrderBy(b => b.Value.Name); - var rem = mBuckets.Where(b => !fbVars.Contains(b.Key)).OrderBy(b => b.Value.Name); - } - - - @Raw(FormatRow( - 0, - Model.Member.BusinessShares * Model.Season.MinKgPerBusinessShare, - Model.Member.BusinessShares * Model.Season.MaxKgPerBusinessShare, - Model.Member.Deliveries.Where(d => d.Year == Model.Season.Year).Sum(d => d.Weight) - )) - - @if (rem.Any()) { - - } - @foreach (var (id, b) in rem) { - - - @Raw(FormatRow(1, b.Obligation, b.Right, b.Delivery, b.Payment)) - - } - @if (fbs.Any()){ - - } - @foreach (var (id, b) in fbs) { - - - @Raw(FormatRow(2, b.Obligation, b.Right, b.Delivery, b.Payment)) - - } - @if (vtr.Any()) { - - } - @foreach (var (id, b) in vtr) { - - - @Raw(FormatRow(2, b.Obligation, b.Right, b.Delivery, b.Payment)) - - } - -
Lese @Model.Season.Year per @($"{Model.Date:dd.MM.yyyy}") [kg]LieferpflichtLieferrechtUnterliefertNoch lieferbarÜberliefertZugeteiltGeliefert
{(mode == 1 ? "" : obligation == 0 ? "-" : $"{obligation:N0}")}{(mode == 1 ? "" : right == 0 ? "-" : $"{right:N0}")}{(mode == 1 ? "" : payment < obligation ? $"{obligation - payment:N0}\x3c/b>" : "-")}{(mode == 1 ? "" : payment >= obligation && sum <= right ? $"{right - sum:N0}" : "-")}{(mode == 1 ? "" : obligation == 0 && right == 0 ? "-" : (sum > right ? ((isGa ? "" : "") + $"{sum - right:N0}" + (isGa ? "" : "")) : "-"))}{(mode != 2 ? "" : obligation == 0 && right == 0 ? "-" : $"{payment:N0}")}{sum:N0}
Gesamtlieferung lt. gez. GA
Sortenaufteilung:
@b.Name
Flächenbindungen:
@b.Name
Verträge:
@b.Name
+ @Raw(Model.PrintBucketTable(Model.Season, Model.MemberBuckets, includePayment: true))
@if (Model.Text != null) {

@Model.Text

diff --git a/Elwig/Documents/DeliveryConfirmation.css b/Elwig/Documents/DeliveryConfirmation.css index c9ad161..9a6a332 100644 --- a/Elwig/Documents/DeliveryConfirmation.css +++ b/Elwig/Documents/DeliveryConfirmation.css @@ -1,52 +1,8 @@ -table.delivery-confirmation { - font-size: 10pt; - margin-bottom: 5mm; -} - -table.delivery-confirmation thead { - font-size: 8pt; -} - -table.delivery-confirmation thead th { - font-weight: normal; - font-style: italic; -} - -table.delivery-confirmation td { - overflow: hidden; - white-space: nowrap; -} - -table.delivery-confirmation td[rowspan] { - vertical-align: top; -} - -table.delivery-confirmation .weight { - text-align: right; -} - -table.delivery-confirmation .grad { - text-align: center; -} - -table.delivery-confirmation .geb { - font-size: 8pt; -} - table.delivery-confirmation .mod { - font-size: 8pt; padding-left: 5mm; } -table.delivery-confirmation .small { - font-size: 8pt; -} - -table.delivery-confirmation tr.new td { - border-top: 0.5pt solid black; -} - table.delivery-confirmation tr:not(.first) { break-before: avoid; } @@ -60,54 +16,9 @@ table.delivery-confirmation tr.trailing td { } table.delivery-confirmation tr.sum { - border-top: 0.5pt solid black; - break-before: avoid; - font-weight: bold; font-size: 12pt; } table.delivery-confirmation tr.sum td { padding-top: 1mm; } - -table.delivery-confirmation-stats { - font-size: 10pt; - break-inside: avoid; -} - -table.delivery-confirmation-stats th, -table.delivery-confirmation-stats td { - padding: 0.125mm 0; - overflow: hidden; - white-space: nowrap; -} - -table.delivery-confirmation-stats tr.subheading th { - text-align: left; -} - -table.delivery-confirmation-stats thead th { - font-weight: normal; - font-style: italic; - text-align: right; - font-size: 8pt; -} - -table.delivery-confirmation-stats thead th:first-child { - text-align: left; -} - -table.delivery-confirmation-stats td { - text-align: right; -} - -table.delivery-confirmation-stats tbody th { - font-weight: normal; - font-style: italic; - text-align: left; -} - -table.delivery-confirmation-stats tr.subheading th { - font-weight: bold; - border-top: 0.5pt solid black; -} diff --git a/Elwig/Documents/DeliveryJournal.cshtml b/Elwig/Documents/DeliveryJournal.cshtml index e48a158..cf4f5d8 100644 --- a/Elwig/Documents/DeliveryJournal.cshtml +++ b/Elwig/Documents/DeliveryJournal.cshtml @@ -10,9 +10,9 @@ - - + + @@ -22,7 +22,7 @@ Lieferschein-Nr. - Pos. + Pos. Datum Zeit Mitglied @@ -31,9 +31,9 @@ Gewicht - [°Oe] - [°KMW] - [kg] + [°Oe] + [°KMW] + [kg] @@ -41,14 +41,14 @@ @p.Delivery.LsNr @p.DPNr - @($"{p.Delivery.Date:dd.MM.yyyy}") - @($"{p.Delivery.Time:HH:mm}") - @p.Delivery.Member.MgNr - @p.Delivery.Member.AdministrativeName - @p.Variant.Name - @($"{p.Oe:N0}") - @($"{p.Kmw:N1}") - @($"{p.Weight:N0}") + @($"{p.Delivery.Date:dd.MM.yyyy}") + @($"{p.Delivery.Time:HH:mm}") + @p.Delivery.Member.MgNr + @p.Delivery.Member.AdministrativeName + @p.Variant.Name + @($"{p.Oe:N0}") + @($"{p.Kmw:N1}") + @($"{p.Weight:N0}") } @@ -58,9 +58,9 @@ } Gesamt: (Teil-)Lieferungen: @($"{Model.Deliveries.DistinctBy(p => p.Delivery).Count():N0}") (@($"{Model.Deliveries.Count():N0}")) - @($"{oe:N0}") - @($"{kmw:N1}") - @($"{Model.Deliveries.Sum(p => p.Weight):N0}") + @($"{oe:N0}") + @($"{kmw:N1}") + @($"{Model.Deliveries.Sum(p => p.Weight):N0}") diff --git a/Elwig/Documents/DeliveryJournal.css b/Elwig/Documents/DeliveryJournal.css index 0258686..be6327a 100644 --- a/Elwig/Documents/DeliveryJournal.css +++ b/Elwig/Documents/DeliveryJournal.css @@ -10,38 +10,3 @@ h2 { font-size: 14pt; margin-top: 2mm; } - -table.journal { - font-size: 10pt; -} - -table.journal thead { - font-size: 8pt; -} - -table.journal th { - font-weight: normal; - font-style: italic; -} - -table.journal td { - overflow: hidden; - white-space: nowrap; -} - -table.journal .mgnr, -table.journal .weight { - text-align: right; -} - -table.journal .grad { - text-align: center; -} - -table.journal tr.sum { - font-weight: bold; -} - -table.journal tr.sum td { - border-top: 0.5pt solid black; -} diff --git a/Elwig/Documents/DeliveryNote.cshtml b/Elwig/Documents/DeliveryNote.cshtml index 463413f..b87bd73 100644 --- a/Elwig/Documents/DeliveryNote.cshtml +++ b/Elwig/Documents/DeliveryNote.cshtml @@ -5,7 +5,7 @@

@Model.Title

- +
@@ -19,7 +19,7 @@ - + @@ -27,21 +27,21 @@ - - - + + + @foreach (var part in Model.Delivery.Parts.OrderBy(p => p.DPNr)) { - + - - - + + + @if (part.Modifiers.Count() > 0) { @@ -65,9 +65,9 @@ @if (Model.Delivery.Parts.Count() > 1) { - - - + + + } @@ -76,63 +76,12 @@

Amerkung zur Lieferung: @Model.Delivery.Comment

} @if (Model.DisplayStats > 0) { -
Pos.Pos. Sorte Attribut QualitätsstufeGewicht
[°Oe][°KMW][kg][°Oe][°KMW][kg]
@part.DPNr@part.DPNr @part.Variant.Name @part.Attribute?.Name @part.Quality.Name@($"{part.Oe:N0}")@($"{part.Kmw:N1}")@($"{part.Weight:N0}")@($"{part.Oe:N0}")@($"{part.Kmw:N1}")@($"{part.Weight:N0}")
Herkunft: @part.OriginString
Gesamt:@($"{Model.Delivery.Oe:N0}")@($"{Model.Delivery.Kmw:N1}")@($"{Model.Delivery.Weight:N0}")@($"{Model.Delivery.Oe:N0}")@($"{Model.Delivery.Kmw:N1}")@($"{Model.Delivery.Weight:N0}")
- - - - - - - - - - - - - - - - - - - - - - @{ - string FormatRow(int obligation, int right, int sum) { - return $"" + - $"" + - $"" + - $"" + - $"" + - $""; - } - var sortids = Model.Delivery.Parts.Select(p => p.SortId).ToList(); - var buckets = Model.MemberBuckets.GroupBy(b => b.Key[..2]).ToDictionary(g => g.Key, g => g.Count()); - } - - - @Raw(FormatRow( - Model.Member.BusinessShares * Model.Delivery.Season.MinKgPerBusinessShare, - Model.Member.BusinessShares * Model.Delivery.Season.MaxKgPerBusinessShare, - Model.Member.Deliveries.Where(d => d.Year == Model.Delivery.Year).Sum(d => d.Weight) - )) - - @if (Model.DisplayStats > 1) { - - - - @foreach (var (id, b) in Model.MemberBuckets.OrderBy(b => b.Key)) { - if (b.Right > 0 || b.Obligation > 0 || (b.Delivery > 0 && buckets[id[..2]] > 1 && !id.EndsWith('_'))) { - - - @Raw(FormatRow(b.Obligation, b.Right, b.Delivery)) - - } - } - } - -
Lese @Model.Delivery.Year per @($"{Model.Date:dd.MM.yyyy}") [kg]LieferpflichtLieferrechtUnterliefertNoch lieferbarÜberliefertGeliefert
{obligation:N0}{right:N0}{(sum < obligation ? $"{obligation - sum:N0}" : "-")}{(sum >= obligation && sum <= right ? $"{right - sum:N0}" : "-")}{(sum > right ? $"{sum - right:N0}" : "-")}{sum:N0}
Gesamtlieferung lt. gez. GA
Flächenbindungen:
@b.Name
+ @Raw(Model.PrintBucketTable( + Model.Delivery.Season, Model.MemberBuckets, isTiny: true, + filter: Model.DisplayStats > 2 ? null : + Model.DisplayStats == 1 ? new List() : + Model.Delivery.Parts.Select(p => p.SortId).Distinct().ToList() + )) }
@for (int i = 0; i < 2; i++) { diff --git a/Elwig/Documents/DeliveryNote.css b/Elwig/Documents/DeliveryNote.css index 190ded3..b60e7c2 100644 --- a/Elwig/Documents/DeliveryNote.css +++ b/Elwig/Documents/DeliveryNote.css @@ -11,12 +11,6 @@ table.delivery tr:not(.main) { break-before: avoid; } -table.delivery th { - font-weight: normal; - font-style: italic; - font-size: 10pt; -} - table.delivery th.main { text-align: left; } @@ -43,55 +37,10 @@ table.delivery tr.tight:has(+ tr:not(.tight)) td { padding-bottom: 0.5mm !important; } -table.delivery tr.sum { - border-top: 0.5pt solid black; - break-before: avoid; -} - table.delivery tr.sum td { padding-top: 1mm; } table.delivery-note-stats { - font-size: 8pt; - break-inside: avoid; break-after: avoid; } - -table.delivery-note-stats th, -table.delivery-note-stats td { - padding: 0.125mm 0; -} - -table.delivery-note-stats:not(.expanded) tr.optional { - display: none; -} - -table.delivery-note-stats tr.subheading th { - text-align: left; -} - -table.delivery-note-stats.expanded tr.subheading:not(:has(~ tr)), -table.delivery-note-stats tr.subheading:not(:has(~ tr:not(.optional))) { - display: none; -} - -table.delivery-note-stats thead th { - font-weight: normal; - font-style: italic; - text-align: right; -} - -table.delivery-note-stats thead th:first-child { - text-align: left; -} - -table.delivery-note-stats td { - text-align: right; -} - -table.delivery-note-stats tbody th { - font-weight: normal; - font-style: italic; - text-align: left; -} diff --git a/Elwig/Documents/Document.Table.css b/Elwig/Documents/Document.Table.css new file mode 100644 index 0000000..d203cd2 --- /dev/null +++ b/Elwig/Documents/Document.Table.css @@ -0,0 +1,113 @@ + +main table { + border-collapse: collapse; + margin-bottom: 10mm; + font-size: 10pt; +} +main table.large {font-size: 12pt;} +main table.tiny { + font-size: 8pt; + margin-bottom: 5mm; +} + +main table tr { + break-inside: avoid; +} + +main table th, +main table td { + overflow: hidden; + white-space: nowrap; + vertical-align: middle; + padding: 0.5mm 1mm; + font-weight: normal; +} +main table.small th, +main table.small td, +main table.tiny th, +main table.tiny td { + padding: 0.125mm 0.125mm; +} + +main table td[rowspan] { + vertical-align: top; +} + +main table thead { + font-size: 8pt; +} +main table.large thead { + font-size: 10pt; +} + +main table th { + font-style: italic; +} + +main table tbody { +} + +main table tbody .small { + font-size: 8pt; +} + +main table.number td, +main table.number th { + padding-left: 0; + padding-right: 0; +} + +main table.number thead th, +main table.number td, +main table tbody td.number { + text-align: right; +} + +main table.center tbody td, +main table tbody td.center { + text-align: center; +} + +main table tbody th { + text-align: left; +} + +main table.cohere { + break-inside: avoid; +} + +main table tr.subheading th { + text-align: left; + font-weight: bold; + font-size: 10pt; +} +main table.small tr.subheading th, +main table.tiny tr.subheading th { + font-size: 8pt; +} + +main table.number thead tr:first-child th:first-child { + text-align: left; +} + +main table tr.sum td { + font-weight: bold; +} + +main table tr.sum, +main table tr.new, +main table tr.border { + border-top: 0.5pt solid black; +} +table.delivery tr.sum { + break-before: avoid; +} + +main table th.unit { + font-size: 8pt; +} + +main table th.narrow { + padding-left: 0; + padding-right: 0; +} diff --git a/Elwig/Documents/Document.cshtml b/Elwig/Documents/Document.cshtml index 74e33af..bdd4d72 100644 --- a/Elwig/Documents/Document.cshtml +++ b/Elwig/Documents/Document.cshtml @@ -9,6 +9,7 @@ + @if (Model.DoubleSided) {