diff --git a/Elwig/Documents/BusinessDocument.cs b/Elwig/Documents/BusinessDocument.cs index 2ac8866..dae50a1 100644 --- a/Elwig/Documents/BusinessDocument.cs +++ b/Elwig/Documents/BusinessDocument.cs @@ -39,13 +39,7 @@ namespace Elwig.Documents { 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); + private static string FormatRow(int obligation, int right, int delivery, int? payment = null, bool isGa = false, bool showPayment = false) { payment ??= delivery; var baseline = showPayment ? payment : delivery; return $"{(obligation == 0 ? "-" : $"{obligation:N0}")}" + @@ -57,8 +51,8 @@ namespace Elwig.Documents { $"{delivery:N0}"; } - private static string FormatRow(RowMode mode, MemberBucket bucket) { - return FormatRow(mode, bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment); + private static string FormatRow(MemberBucket bucket, bool isGa = false, bool showPayment = false) { + return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment, isGa, showPayment); } public string PrintBucketTable(Season season, Dictionary buckets, bool includePayment = false, bool isTiny = false, IEnumerable? filter = null) { @@ -99,23 +93,23 @@ namespace Elwig.Documents { 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) + Member.Deliveries.Where(d => d.Year == season.Year).Sum(d => d.Weight), + isGa: true, showPayment: includePayment )}"; 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)}"; + tbl += $"{b.Name}{FormatRow(b, showPayment: includePayment)}"; } } if (vtr.Any()) { tbl += $"" + "Verträge:"; foreach (var (id, b) in vtr) { - tbl += $"{b.Name}{FormatRow(includePayment ? RowMode.CONFIRMATION : RowMode.NOTE, b)}"; + tbl += $"{b.Name}{FormatRow(b, showPayment: includePayment)}"; } } tbl += "\n\n";