From 8555748202985dfb2ff0025d39f62f4b3a1e4906 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Sat, 23 Dec 2023 13:29:24 +0100 Subject: [PATCH] CreditNote: Add FormatRow() --- Elwig/Documents/CreditNote.cshtml | 102 ++++++------------------------ 1 file changed, 21 insertions(+), 81 deletions(-) diff --git a/Elwig/Documents/CreditNote.cshtml b/Elwig/Documents/CreditNote.cshtml index 0c23ab0..4e78032 100644 --- a/Elwig/Documents/CreditNote.cshtml +++ b/Elwig/Documents/CreditNote.cshtml @@ -78,101 +78,41 @@ } } + @{ + string FormatRow(string name, decimal? value, bool add = false, bool halfLine = true, bool bold = false) { + return $"" + + $"" + + $"{name}:" + + $"{(value < 0 ? "–" : (add ? "+" : ""))}" + + $"" + + $"{Model.CurrencySymbol}{Math.Abs(value ?? 0):N2}" + + $"\n"; + } + } + @{ var sum = Model.Data.Rows.Sum(p => p.Amount); } @if (Model.Payment == null) { - - - Gesamt: - - - @Model.CurrencySymbol - @($"{Model.Data.Rows.Sum(p => p.Amount):N2}") - - + @Raw(FormatRow("Gesamt", sum, halfLine: false, bold: true)) } else { var totalLine = false; if (Model.Payment.NetAmount != Model.Payment.Amount) { - - - Zwischensumme: - - - @Model.CurrencySymbol - @($"{Model.Payment.NetAmount:N2}") - - + @Raw(FormatRow("Zwischensumme", Model.Payment.NetAmount, halfLine: totalLine)) totalLine = true; - - - @Model.MemberModifier: - @(Model.Payment.NetAmount > Model.Payment.Amount ? "–" : "+") - - @Model.CurrencySymbol - @($"{Math.Abs(Model.Payment.Amount - Model.Payment.NetAmount):N2}") - - + @Raw(FormatRow(Model.MemberModifier, Model.Payment.Amount - Model.Payment.NetAmount, add: true, halfLine: totalLine)) } if (Model.Credit == null) { - - - Gesamtbetrag: - - - @Model.CurrencySymbol - @($"{Model.Payment.Amount:N2}") - - + @Raw(FormatRow("Gesamtbetrag", Model.Payment.Amount, bold: true, halfLine: totalLine)) totalLine = true; } else { var hasPrev = Model.Credit.PrevNetAmount != null; - - - @(hasPrev ? "Gesamtbetrag" : "Nettobetrag"): - - - @Model.CurrencySymbol - @($"{Model.Credit.NetAmount:N2}") - - + @Raw(FormatRow(hasPrev ? "Gesamtbetrag" : "Nettobetrag", Model.Credit.NetAmount, bold: true, halfLine: totalLine)) totalLine = true; if (hasPrev) { - - - Bisher ausgezahlt: - – - - @Model.CurrencySymbol - @($"{Model.Credit.PrevNetAmount:N2}") - - - - - Nettobetrag: - - - @Model.CurrencySymbol - @($"{Model.Credit.NetAmount - (Model.Credit.PrevNetAmount ?? 0):N2}") - - + @Raw(FormatRow("Bisher ausgezahlt", -Model.Credit.PrevNetAmount, add: true)) + @Raw(FormatRow("Nettobetrag", Model.Credit.NetAmount - (Model.Credit.PrevNetAmount ?? 0))) } - - - Mehrwertsteuer (@($"{Model.Credit.Vat * 100} %")): - + - - @Model.CurrencySymbol - @($"{Model.Credit.VatAmount:N2}") - - - - - Bruttobetrag: - - - @Model.CurrencySymbol - @($"{Model.Credit.Amount:N2}") - - + @Raw(FormatRow($"Mehrwertsteuer ({Model.Credit.Vat * 100} %)", Model.Credit.VatAmount, add: true)) + @Raw(FormatRow("Bruttobetrag", Model.Credit.GrossAmount, bold: true)) } }