diff --git a/Elwig/Documents/DeliveryNote.cs b/Elwig/Documents/DeliveryNote.cs index 1723543..92c6f91 100644 --- a/Elwig/Documents/DeliveryNote.cs +++ b/Elwig/Documents/DeliveryNote.cs @@ -196,9 +196,17 @@ namespace Elwig.Documents { .Add(Italic("Brutto:")) .Add(Normal($" {info.Gross:N0} kg \u2013 ")) .Add(Italic("Tara:")) - .Add(Normal($" {info.Tare:N0} kg \u2013 ")) + .Add(Normal($" {info.Tare:N0} kg ")); + if (info.TareCorrection != null && info.TareCorrection != 0) + weighing.Add(Bold($"(Kurrektur: {Utils.GetSign(info.TareCorrection.Value)}{Math.Abs(info.TareCorrection.Value)} kg)")).Add(" "); + weighing + .Add(Normal("\u2013 ")) .Add(Italic("Netto:")) - .Add(Normal($" {info.Net:N0} kg \u2013 ")) + .Add(Normal($" {info.Net:N0} kg ")); + if (info.TareCorrection != null && info.TareCorrection != 0) + weighing.Add(Normal($"({Utils.GetSign(-info.TareCorrection.Value)}{Math.Abs(info.TareCorrection.Value)} kg) ")); + weighing + .Add(Normal("\u2013 ")) .Add(Italic(part.IsNetWeight ? "gerebelt gewogen" : "nicht gerebelt gewogen")); } else { weighing.Add(" ") diff --git a/Elwig/Models/Entities/DeliveryPart.cs b/Elwig/Models/Entities/DeliveryPart.cs index fc6379d..7febef1 100644 --- a/Elwig/Models/Entities/DeliveryPart.cs +++ b/Elwig/Models/Entities/DeliveryPart.cs @@ -124,7 +124,7 @@ namespace Elwig.Models.Entities { [Column("weighing_data")] public string? WeighingData { get; set; } [NotMapped] - public (string? ScaleId, string? Id, int? Gross, int? Tare, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo { + public (string? ScaleId, string? Id, int? Gross, int? Tare, int? TareCorrection, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo { get { try { var obj = JsonNode.Parse(WeighingData!)!.AsObject(); @@ -133,12 +133,13 @@ namespace Elwig.Models.Entities { obj["id"]?.AsValue().GetValue(), obj["gross_weight"]?.AsValue().GetValue(), obj["tare_weight"]?.AsValue().GetValue(), + obj["tare_correction"]?.AsValue().GetValue(), obj["net_weight"]?.AsValue().GetValue(), DateOnly.TryParseExact(obj["date"]?.AsValue().GetValue(), "yyyy-MM-dd", out var d) ? d : null, TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null ); } catch { - return (null, null, null, null, null, null, null); + return (null, null, null, null, null, null, null, null); } } } diff --git a/Elwig/Services/DeliveryService.cs b/Elwig/Services/DeliveryService.cs index 258da89..788f205 100644 --- a/Elwig/Services/DeliveryService.cs +++ b/Elwig/Services/DeliveryService.cs @@ -36,6 +36,7 @@ namespace Elwig.Services { vm.SortId = ""; vm.GradationKmwString = ""; vm.WeightString = ""; + vm.Tare = "-"; vm.IsManualWeighing = false; vm.PartComment = ""; vm.TemperatureString = ""; @@ -52,6 +53,7 @@ namespace Elwig.Services { vm.WineRd = ControlUtils.GetItemFromSourceWithPk(vm.WineRdSource, p.KgNr, p.RdNr) as WbRd; vm.WineOrigin = ControlUtils.GetItemFromSourceWithPk(vm.WineOriginSource, p.HkId) as WineOrigin; vm.WeightString = $"{p.Weight:N0}"; + vm.Tare = p.WeighingInfo.Tare is int t && t != 0 ? $"{t:N0} kg" : "-"; vm.IsManualWeighing = p.IsManualWeighing; vm.IsNetWeight = p.IsNetWeight; diff --git a/Elwig/ViewModels/DeliveryAdminViewModel.cs b/Elwig/ViewModels/DeliveryAdminViewModel.cs index 9d41b87..754bf74 100644 --- a/Elwig/ViewModels/DeliveryAdminViewModel.cs +++ b/Elwig/ViewModels/DeliveryAdminViewModel.cs @@ -120,6 +120,8 @@ namespace Elwig.ViewModels { set => WeightString = $"{value:N0}"; } [ObservableProperty] + private string? _tare = "-"; + [ObservableProperty] private bool _isManualWeighing; [ObservableProperty] private bool? _isNetWeightValue = false; diff --git a/Elwig/Windows/DeliveryAdminWindow.xaml b/Elwig/Windows/DeliveryAdminWindow.xaml index 87e59ae..d79d86f 100644 --- a/Elwig/Windows/DeliveryAdminWindow.xaml +++ b/Elwig/Windows/DeliveryAdminWindow.xaml @@ -565,16 +565,23 @@ TextChanged="WeightInput_TextChanged" Grid.Column="1" Width="70" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/> +