[#17] CreditNote: Overhaul CreditNote

This commit is contained in:
2023-12-22 15:30:39 +01:00
parent 82f93746ab
commit b9a2893d80
10 changed files with 226 additions and 79 deletions

View File

@ -1,3 +1,4 @@
@using Elwig.Helpers
@using RazorLight
@inherits TemplatePage<Elwig.Documents.CreditNote>
@model Elwig.Documents.CreditNote
@ -8,84 +9,89 @@
<table class="credit">
<colgroup>
<col style="width: 25mm;"/>
<col style="width: 5mm;"/>
<col style="width: 5mm;"/>
<col style="width: 20mm;"/>
<col style="width: 20mm;"/>
<col style="width: 18mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
<col style="width: 15mm;"/>
<col style="width: 12mm;"/>
<col style="width: 15mm;"/>
<col style="width: 10mm;"/>
<col style="width: 10mm;"/>
<col style="width: 15mm;"/>
<col style="width: 17mm;"/>
<col style="width: 16mm;"/>
</colgroup>
<thead>
<tr>
<th rowspan="3" style="text-align: left;">Lieferschein-Nr.</th>
<th rowspan="3">Pos.</th>
<th rowspan="3" style="text-align: left;">Sorte</th>
<th rowspan="3" style="text-align: left;">Attribut</th>
<th rowspan="2" colspan="2">Gradation</th>
<th rowspan="2" colspan="2">Flächenbindung</th>
<th rowspan="2">Preis</th>
<th colspan="2">Zu-/Abschläge</th>
<th rowspan="2">Betrag</th>
<th rowspan="2" style="text-align: left;">Lieferschein-Nr.</th>
<th rowspan="2" class="narrow">Pos.</th>
<th rowspan="2" style="text-align: left;">Sorte</th>
<th rowspan="2" style="text-align: left;">Attribut</th>
<th colspan="2">Gradation</th>
<th colspan="2">Flächenbindung</th>
<th>Preis</th>
<th class="narrow">Zu-/Abschläge</th>
<th>Betrag</th>
</tr>
<tr>
<th>Rel.</th>
<th>Abs.</th>
</tr>
<tr>
<th>[°Oe]</th>
<th>[°KMW]</th>
<th colspan="2">[kg]</th>
<th>[@Model.CurrencySymbol/kg]</th>
<th>[%]</th>
<th>[@Model.CurrencySymbol/kg]</th>
<th>[@Model.CurrencySymbol]</th>
<th class="unit">[°Oe]</th>
<th class="unit narrow">[°KMW]</th>
<th class="unit" colspan="2">[kg]</th>
<th class="unit">[@Model.CurrencySymbol/kg]</th>
<th class="unit">[@Model.CurrencySymbol]</th>
<th class="unit">[@Model.CurrencySymbol]</th>
</tr>
</thead>
<tbody>
@foreach (var p in Model.Data.Rows) {
var rows = Math.Max(p.Buckets.Length, p.Modifiers.Length + 1);
var first = true;
//var pmt = p.Payment;
var abs = 0; // pmt?.ModAbs == null || pmt?.ModAbs == 0 ? "-" : pmt?.ModAbs.ToString("0." + string.Concat(Enumerable.Repeat('0', Model.Precision)));
var rel = 0; // pmt?.ModRel == null || pmt?.ModRel == 0 ? "-" : $"{pmt?.ModRel * 100:0.00##}";
@for (int i = 0; i < rows; i++) {
<tr class="@(first ? "first" : "") @(rows > i + 1 ? "trailing" : "")">
<tr class="@(first ? "first" : "") @(rows > i + 1 ? "last" : "")">
@if (first) {
<td rowspan="@rows" class="lsnr">@p.LsNr</td>
<td rowspan="@rows" class="dpnr">@p.DPNr</td>
<td class="variant small">@p.Variant</td>
<td class="attribute small">@p.Attribute</td>
<td rowspan="@rows" class="oe">@($"{p.Gradation.Oe:N0}")</td>
<td rowspan="@rows" class="kmw">@($"{p.Gradation.Kmw:N1}")</td>
<td rowspan="@rows">@p.LsNr</td>
<td rowspan="@rows">@p.DPNr</td>
<td class="small">@p.Variant</td>
<td class="small">@p.Attribute</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>
}
@if (i > 0 && i <= p.Modifiers.Length) {
<td colspan="2" class="mod">@(p.Modifiers[i - 1])</td>
<td colspan="2" class="small mod">@p.Modifiers[i - 1]</td>
} else if (i > 0) {
<td colspan="2"></td>
}
@if (i < p.Buckets.Length) {
var bucket = p.Buckets[i];
<td class="geb small">@bucket.Name:</td>
<td class="weight">@($"{bucket.Value:N0}")</td>
<td class="price">@($"{bucket.Price:N4}")</td>
<td class="small">@bucket.Name:</td>
<td class="number">@($"{bucket.Value:N0}")</td>
<td class="number">@($"{bucket.Price:N4}")</td>
} else {
<td colspan="3"></td>
}
@if (first) {
<td rowspan="@rows" class="rel">@rel</td>
<td rowspan="@rows" class="abs">@abs</td>
<!-- FIXME rel/abs mods -->
<td rowspan="@rows" class="amount">@($"{p.Buckets.Sum(b => b.Amount):N2}")</td>
first = false;
@if (i == p.Buckets.Length - 1) {
var totalMod = p.TotalModifiers ?? 0;
<td class="number@(totalMod == 0 ? " center" : "")">@(totalMod == 0 ? "-" : Utils.GetSign(totalMod) + $"{Math.Abs(totalMod):N2}")</td>
<td class="number">@($"{p.Amount:N2}")</td>
} else {
<td colspan="2"></td>
}
</tr>
first = false;
}
}
@if (Model.Payment == null) {
<tr class="sum">
<td colspan="7"></td>
<td colspan="2">Gesamt:</td>
<td colspan="2" class="number">@($"{Model.Data.Rows.Sum(p => p.Amount):N2}")</td>
</tr>
} else {
<tr class="sum">
<td colspan="7"></td>
<td colspan="2">Gesamt:</td>
<td colspan="2" class="number">@($"{Model.Payment.NetAmount:N2}")</td>
</tr>
}
</tbody>
</table>
</main>