From d44d82a614cded9d76ac4869ed474bec6e2cf429 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Sat, 1 Aug 2026 23:14:02 +0200 Subject: [PATCH] Weighing: Set Date/Time of scales at startup --- Elwig/App.xaml.cs | 8 +++++++- Elwig/Documents/DeliveryNote.cs | 2 +- Elwig/Helpers/Weighing/WeighingResult.cs | 2 +- Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Elwig/App.xaml.cs b/Elwig/App.xaml.cs index 5e77ff4..953f83b 100644 --- a/Elwig/App.xaml.cs +++ b/Elwig/App.xaml.cs @@ -145,7 +145,13 @@ namespace Elwig { var list = new List(); foreach (var s in Config.Scales) { try { - list.Add(Scale.FromConfig(s)); + var scale = Scale.FromConfig(s); + if (scale is ICommandScale cmd) { + try { + await cmd.SetDateAndTime(DateTime.Now); + } catch { } + } + list.Add(scale); } catch (Exception exc) { list.Add(new InvalidScale(s.Id)); if (s.Required) diff --git a/Elwig/Documents/DeliveryNote.cs b/Elwig/Documents/DeliveryNote.cs index ea7bf04..d8fe420 100644 --- a/Elwig/Documents/DeliveryNote.cs +++ b/Elwig/Documents/DeliveryNote.cs @@ -188,7 +188,7 @@ namespace Elwig.Documents { if (info.Date != null || info.Time != null) weighing.Add(Normal(" \u2013 ")); if (info.Time != null) - weighing.Add(Normal($"{info.Time:HH:mm}")); + weighing.Add(Normal($"{info.Time:HH:mm:ss}")); if (info.Date != null) weighing.Add(Normal($", {info.Date:dd.MM.yyyy}")); if (info.Gross != null && info.Tare != null && info.Net != null) { diff --git a/Elwig/Helpers/Weighing/WeighingResult.cs b/Elwig/Helpers/Weighing/WeighingResult.cs index d69afbc..2e3e4ca 100644 --- a/Elwig/Helpers/Weighing/WeighingResult.cs +++ b/Elwig/Helpers/Weighing/WeighingResult.cs @@ -49,7 +49,7 @@ namespace Elwig.Helpers.Weighing { /// <[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time> public override readonly string ToString() { var w = NetWeight != null ? (GrossWeight != null && TareWeight != null ? $"{GrossWeight}-{TareWeight}=" : "") + $"{NetWeight}kg" : ""; - return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm}>"; + return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm:ss}>"; } public readonly JsonObject ToJson() { diff --git a/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs b/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs index 98ab9d2..5bc9fc9 100644 --- a/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs +++ b/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs @@ -23,7 +23,7 @@ namespace Tests.UnitTests.DocumentTests { 1 Grüner Veltliner Qualitätswein 73 15,0 3 219 Herkunft: Österreich / Weinland / Niederösterreich / Matzner Hügel / Hohenruppersdorf / KG Hohenruppersdorf - Waage/Terminal: ?/1, ID: 321 – 09:02, 01.10.2020 + Waage/Terminal: ?/1, ID: 321 – 09:02:46, 01.10.2020 Brutto: 3 219 kg – Tara: 0 kg – Netto: 3 219 kg – gerebelt gewogen """)); });