@ -36,7 +36,7 @@ namespace Elwig.Documents {
|
||||
}
|
||||
|
||||
private static string GetColGroup(IEnumerable<double> cols) {
|
||||
return "<colgroup>\n" + string.Join("\n", cols.Select(g => $"<col style=\"width: {g}mm;\"/>")) + "\n</colgroup>\n";
|
||||
return "<colgroup>\n" + string.Join("\n", cols.Select(g => $"<col style=\"width: {g.ToString().Replace(',', '.')}mm;\"/>")) + "\n</colgroup>\n";
|
||||
}
|
||||
|
||||
public static string PrintSortenaufteilung(Dictionary<string, MemberBucket> buckets) {
|
||||
@ -80,9 +80,19 @@ namespace Elwig.Documents {
|
||||
return "<table class=\"sortenaufteilung small number cohere\">" + tbl + "</table>";
|
||||
}
|
||||
|
||||
private static string FormatRow(int obligation, int right, int delivery, int? payment = null, bool isGa = false, bool showPayment = false) {
|
||||
private static string FormatRow(
|
||||
int obligation, int right, int delivery, int? payment = null, int? area = null,
|
||||
bool isGa = false, bool showPayment = false, bool showArea = false
|
||||
) {
|
||||
payment ??= delivery;
|
||||
var baseline = showPayment ? payment : delivery;
|
||||
|
||||
if (showArea) {
|
||||
return $"<td>{(area == null ? "" : $"{area:N0}")}</td>" +
|
||||
$"<td>{obligation:N0}</td>" +
|
||||
$"<td>{right:N0}</td>";
|
||||
}
|
||||
|
||||
return $"<td>{(obligation == 0 ? "-" : $"{obligation:N0}")}</td>" +
|
||||
$"<td>{(right == 0 ? "-" : $"{right:N0}")}</td>" +
|
||||
$"<td>{(baseline < obligation ? $"<b>{obligation - baseline:N0}</b>" : "-")}</td>" +
|
||||
@ -92,29 +102,41 @@ namespace Elwig.Documents {
|
||||
$"<td>{delivery:N0}</td>";
|
||||
}
|
||||
|
||||
private static string FormatRow(MemberBucket bucket, bool isGa = false, bool showPayment = false) {
|
||||
return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment, isGa, showPayment);
|
||||
private static string FormatRow(MemberBucket bucket, bool isGa = false, bool showPayment = false, bool showArea = false) {
|
||||
return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment, bucket.Area, isGa, showPayment, showArea);
|
||||
}
|
||||
|
||||
public string PrintBucketTable(Season season, Dictionary<string, MemberBucket> buckets, bool includePayment = false, bool isTiny = false, IEnumerable<string>? filter = null) {
|
||||
string tbl = GetColGroup(includePayment ? [45, 17, 17, 17, 19, 16, 17, 17] : [45, 20, 20, 20, 20, 20, 20]);
|
||||
public string PrintBucketTable(
|
||||
Season season, Dictionary<string, MemberBucket> buckets,
|
||||
bool includeDelivery = true, bool includePayment = false,
|
||||
bool isTiny = false, IEnumerable<string>? filter = null
|
||||
) {
|
||||
includePayment = includePayment && includeDelivery;
|
||||
string tbl = GetColGroup(!includeDelivery ? [105, 20, 20, 20] : includePayment ? [45, 17, 17, 17, 19, 16, 17, 17] : [45, 20, 20, 20, 20, 20, 20]);
|
||||
tbl += $"""
|
||||
<thead>
|
||||
<tr>
|
||||
<th><b>Lese {season.Year}</b> per {Date:dd.MM.yyyy} [kg]</th>
|
||||
<th{(!includeDelivery ? " rowspan=\"2\"" : "")}>
|
||||
<b>{(includeDelivery ? "Lese " + season.Year : "Zusammengefasste Flächenbindungen")}</b>
|
||||
per {Date:dd.MM.yyyy} {(includeDelivery ? "[kg]" : "")}
|
||||
</th>
|
||||
{(!includeDelivery ? "<th>Fläche</th>" : "")}
|
||||
<th>Lieferpflicht</th>
|
||||
<th>Lieferrecht</th>
|
||||
<th>Unterliefert</th>
|
||||
<th>Noch lieferbar</th>
|
||||
<th>Überliefert</th>
|
||||
{(includeDelivery ? "<th>Unterliefert</th>" : "")}
|
||||
{(includeDelivery ? "<th>Noch lieferbar</th>" : "")}
|
||||
{(includeDelivery ? "<th>Geliefert</th>" : "")}
|
||||
{(includePayment ? "<th>Zugeteilt</th>" : "")}
|
||||
<th>Geliefert</th>
|
||||
{(includeDelivery ? "<th>Geliefert</th>" : "")}
|
||||
</tr>
|
||||
{(!includeDelivery ? "<tr><th class=\"unit\">[m²]</th><th class=\"unit\">[kg]</th><th class=\"unit\">[kg]</th></tr>" : "")}
|
||||
</thead>
|
||||
""";
|
||||
|
||||
var mBuckets = buckets
|
||||
.Where(b => (b.Value.Right > 0 || b.Value.Obligation > 0 || b.Value.Delivery > 0) && (filter == null || filter.Contains(b.Key[..2])))
|
||||
.Where(b => ((!includeDelivery && b.Value.Area > 0) ||
|
||||
(includeDelivery && (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)
|
||||
@ -136,20 +158,20 @@ namespace Elwig.Documents {
|
||||
Member.BusinessShares * season.MinKgPerBusinessShare,
|
||||
Member.BusinessShares * season.MaxKgPerBusinessShare,
|
||||
Member.Deliveries.Where(d => d.Year == season.Year).Sum(d => d.Weight),
|
||||
isGa: true, showPayment: includePayment
|
||||
isGa: true, showPayment: includePayment, showArea: !includeDelivery
|
||||
)}</tr>";
|
||||
if (fbs.Any()) {
|
||||
tbl += $"<tr class=\"subheading{(filter == null ? " border" : "")}\"><th colspan=\"{(includePayment ? 8 : 7)}\">" +
|
||||
$"Flächenbindungen{(vtr.Any() ? " (inkl. Verträge)" : "")}:</th></tr>";
|
||||
foreach (var (id, b) in fbs) {
|
||||
tbl += $"<tr><th>{b.Name}</th>{FormatRow(b, showPayment: includePayment)}</tr>";
|
||||
tbl += $"<tr><th>{b.Name}</th>{FormatRow(b, showPayment: includePayment, showArea: !includeDelivery)}</tr>";
|
||||
}
|
||||
}
|
||||
if (vtr.Any()) {
|
||||
tbl += $"<tr class=\"subheading{(filter == null ? " border" : "")}\"><th colspan=\"{(includePayment ? 8 : 7)}\">" +
|
||||
"Verträge:</th></tr>";
|
||||
foreach (var (id, b) in vtr) {
|
||||
tbl += $"<tr><th>{b.Name}</th>{FormatRow(b, showPayment: includePayment)}</tr>";
|
||||
tbl += $"<tr><th>{b.Name}</th>{FormatRow(b, showPayment: includePayment, showArea: !includeDelivery)}</tr>";
|
||||
}
|
||||
}
|
||||
tbl += "\n</tbody>\n";
|
||||
|
Reference in New Issue
Block a user