[#17][#23] BusinessDocument: Remove enum RowMode

This commit is contained in:
2023-12-19 18:06:15 +01:00
parent 161bf31a62
commit 8811ca25ce

View File

@ -39,13 +39,7 @@ namespace Elwig.Documents {
return ""; return "";
} }
private enum RowMode { private static string FormatRow(int obligation, int right, int delivery, int? payment = null, bool isGa = false, bool showPayment = false) {
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; payment ??= delivery;
var baseline = showPayment ? payment : delivery; var baseline = showPayment ? payment : delivery;
return $"<td>{(obligation == 0 ? "-" : $"{obligation:N0}")}</td>" + return $"<td>{(obligation == 0 ? "-" : $"{obligation:N0}")}</td>" +
@ -57,8 +51,8 @@ namespace Elwig.Documents {
$"<td>{delivery:N0}</td>"; $"<td>{delivery:N0}</td>";
} }
private static string FormatRow(RowMode mode, MemberBucket bucket) { private static string FormatRow(MemberBucket bucket, bool isGa = false, bool showPayment = false) {
return FormatRow(mode, bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment); return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment, isGa, showPayment);
} }
public string PrintBucketTable(Season season, Dictionary<string, MemberBucket> buckets, bool includePayment = false, bool isTiny = false, IEnumerable<string>? filter = null) { public string PrintBucketTable(Season season, Dictionary<string, MemberBucket> buckets, bool includePayment = false, bool isTiny = false, IEnumerable<string>? filter = null) {
@ -99,23 +93,23 @@ namespace Elwig.Documents {
tbl += "\n<tbody>\n"; tbl += "\n<tbody>\n";
tbl += $"<tr><th>Gesamtlieferung lt. gez. GA</th>{FormatRow( tbl += $"<tr><th>Gesamtlieferung lt. gez. GA</th>{FormatRow(
includePayment ? RowMode.GA_CONFIRMATION : RowMode.GA_NOTE,
Member.BusinessShares * season.MinKgPerBusinessShare, Member.BusinessShares * season.MinKgPerBusinessShare,
Member.BusinessShares * season.MaxKgPerBusinessShare, Member.BusinessShares * season.MaxKgPerBusinessShare,
Member.Deliveries.Where(d => d.Year == season.Year).Sum(d => d.Weight) Member.Deliveries.Where(d => d.Year == season.Year).Sum(d => d.Weight),
isGa: true, showPayment: includePayment
)}</tr>"; )}</tr>";
if (fbs.Any()) { if (fbs.Any()) {
tbl += $"<tr class=\"subheading{(filter == null ? " border" : "")}\"><th colspan=\"{(includePayment ? 8 : 7)}\">" + tbl += $"<tr class=\"subheading{(filter == null ? " border" : "")}\"><th colspan=\"{(includePayment ? 8 : 7)}\">" +
$"Flächenbindungen{(vtr.Any() ? " (inkl. Verträge)" : "")}:</th></tr>"; $"Flächenbindungen{(vtr.Any() ? " (inkl. Verträge)" : "")}:</th></tr>";
foreach (var (id, b) in fbs) { foreach (var (id, b) in fbs) {
tbl += $"<tr><th>{b.Name}</th>{FormatRow(includePayment ? RowMode.CONFIRMATION : RowMode.NOTE, b)}</tr>"; tbl += $"<tr><th>{b.Name}</th>{FormatRow(b, showPayment: includePayment)}</tr>";
} }
} }
if (vtr.Any()) { if (vtr.Any()) {
tbl += $"<tr class=\"subheading{(filter == null ? " border" : "")}\"><th colspan=\"{(includePayment ? 8 : 7)}\">" + tbl += $"<tr class=\"subheading{(filter == null ? " border" : "")}\"><th colspan=\"{(includePayment ? 8 : 7)}\">" +
"Verträge:</th></tr>"; "Verträge:</th></tr>";
foreach (var (id, b) in vtr) { foreach (var (id, b) in vtr) {
tbl += $"<tr><th>{b.Name}</th>{FormatRow(includePayment ? RowMode.CONFIRMATION : RowMode.NOTE, b)}</tr>"; tbl += $"<tr><th>{b.Name}</th>{FormatRow(b, showPayment: includePayment)}</tr>";
} }
} }
tbl += "\n</tbody>\n"; tbl += "\n</tbody>\n";