CreditNote: Display under deliveries of area commitments

This commit is contained in:
2023-12-23 21:27:26 +01:00
parent 4f07d9b129
commit 8e71e82efc
5 changed files with 100 additions and 22 deletions

View File

@ -79,12 +79,12 @@
}
</tbody>
@{
string FormatRow(string name, decimal? value, bool add = false, bool halfLine = true, bool bold = false) {
string FormatRow(string name, decimal? value, bool add = false, bool halfLine = true, bool bold = false, bool subCat = false) {
return $"<tr class=\"{(halfLine || add ? "" : "sum")} {(bold ? "large bold" : "")}\">"
+ $"<td colspan=\"4\"></td>"
+ $"<td class=\"{(halfLine && !add ? "sum" : "")}\" colspan=\"4\">{name}:</td>"
+ $"<td class=\"number large {(halfLine && !add ? "sum" : "")}\">{(value < 0 ? "" : (add ? "+" : ""))}</td>"
+ $"<td colspan=\"2\" class=\"number large {(halfLine && !add ? "sum" : "")}\">"
+ $"<td class=\"{(halfLine && !add ? "sum" : "")} {(subCat ? "small" : "")}\" colspan=\"4\" style=\"overflow: visible;\">{name}:</td>"
+ $"<td class=\"number {(subCat ? "small" : "large")} {(halfLine && !add ? "sum" : "")}\">{(value < 0 ? "" : (add ? "+" : ""))}</td>"
+ $"<td colspan=\"2\" class=\"number {(subCat ? "small" : "large")} {(halfLine && !add ? "sum" : "")}\">"
+ $"<span class=\"fleft\">{Model.CurrencySymbol}</span>{Math.Abs(value ?? 0):N2}</td>"
+ $"</tr>\n";
}
@ -116,5 +116,33 @@
}
}
</tbody>
<tbody style="break-inside: avoid;">
@{ decimal penalty = 0; }
@if (Model.MemberUnderDeliveries != null && Model.MemberUnderDeliveries.Count() > 0) {
<tr class="small">
<td colspan="4"></td>
<td colspan="5" style="padding-top: 5mm;">Anfallende Pönalen durch Unterlieferungen:</td>
<td colspan="2"></td>
</tr>
foreach (var u in Model.MemberUnderDeliveries) {
@Raw(FormatRow($"{u.Name} ({u.Kg:N0} kg)", u.Amount, add: true, subCat: true))
penalty += u.Amount;
}
penalty = Math.Round(penalty, 2, MidpointRounding.AwayFromZero);
}
@if (Model.Credit == null) {
@Raw(FormatRow("Auszahlungsbetrag", (Model.Payment?.Amount + penalty) ?? (sum + penalty), bold: true))
} else {
if (Model.Credit.Modifiers - penalty != 0) {
@Raw(FormatRow("Weitere Abzüge", Model.Credit.Modifiers - penalty, add: true))
}
if (Model.Credit.PrevModifiers != null && Model.Credit.PrevModifiers != 0) {
@Raw(FormatRow("Bereits berücksichtigte Abzüge", -Model.Credit.PrevModifiers, add: true))
}
@Raw(FormatRow("Auszahlungsbetrag", Model.Credit.Amount, bold: true))
}
</tbody>
</table>
</main>