From 72155fc54e1b9ac24218208e4e0234528fa52a8b Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Wed, 29 Apr 2026 11:29:16 +0200 Subject: [PATCH] Documents: Fix error because of modifiers in CreditNote and DeliveryConfirmation --- Elwig/Documents/CreditNote.cs | 11 +++++++---- Elwig/Documents/DeliveryConfirmation.cs | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Elwig/Documents/CreditNote.cs b/Elwig/Documents/CreditNote.cs index 4a765c3..cac5909 100644 --- a/Elwig/Documents/CreditNote.cs +++ b/Elwig/Documents/CreditNote.cs @@ -296,11 +296,14 @@ namespace Elwig.Documents { if (p.QualId == "WEI") varibute.Add(Italic("abgew.")); sub.AddCell(NewCell(colspan: 2)) .AddCell(NewTd(varibute, colspan: 3).SetPaddingTop(0)); - } else if (i - (rows - p.Modifiers.Length) < p.Modifiers.Length) { - sub.AddCell(NewCell(colspan: 2)) - .AddCell(NewTd(p.Modifiers[i - (rows - p.Modifiers.Length)], 8, colspan: 3).SetPaddingTop(0).SetPaddingLeftMM(5)); } else { - sub.AddCell(NewCell(colspan: 5)); + var idx = i - (rows - p.Modifiers.Length); + if (idx >= 0 && idx < p.Modifiers.Length) { + sub.AddCell(NewCell(colspan: 2)) + .AddCell(NewTd(p.Modifiers[idx], 8, colspan: 3).SetPaddingTop(0).SetPaddingLeftMM(5)); + } else { + sub.AddCell(NewCell(colspan: 5)); + } } if (i < p.Buckets.Length) { diff --git a/Elwig/Documents/DeliveryConfirmation.cs b/Elwig/Documents/DeliveryConfirmation.cs index 3475a6e..2a3ac37 100644 --- a/Elwig/Documents/DeliveryConfirmation.cs +++ b/Elwig/Documents/DeliveryConfirmation.cs @@ -118,8 +118,9 @@ namespace Elwig.Documents { .AddCell(NewCell(colspan: 2)); } else { sub.AddCell(NewCell(colspan: 2)); - if (i - (rows - p.Modifiers.Length) < p.Modifiers.Length) { - sub.AddCell(NewTd(p.Modifiers[i - (rows - p.Modifiers.Length)], 8, colspan: 2) + var idx = i - (rows - p.Modifiers.Length); + if (idx >= 0 && idx < p.Modifiers.Length) { + sub.AddCell(NewTd(p.Modifiers[idx], 8, colspan: 2) .SetPaddingsMM(0.125f, 0, 0.125f, 5)); } else { sub.AddCell(NewCell(colspan: 2));