[WIP] Tara
Test / Run tests (push) Successful in 2m45s

This commit is contained in:
2026-09-14 10:32:14 +02:00
parent fea779bd95
commit dbc1363213
6 changed files with 33 additions and 6 deletions
+10 -2
View File
@@ -196,9 +196,17 @@ namespace Elwig.Documents {
.Add(Italic("Brutto:")) .Add(Italic("Brutto:"))
.Add(Normal($" {info.Gross:N0} kg \u2013 ")) .Add(Normal($" {info.Gross:N0} kg \u2013 "))
.Add(Italic("Tara:")) .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(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")); .Add(Italic(part.IsNetWeight ? "gerebelt gewogen" : "nicht gerebelt gewogen"));
} else { } else {
weighing.Add(" ") weighing.Add(" ")
+3 -2
View File
@@ -124,7 +124,7 @@ namespace Elwig.Models.Entities {
[Column("weighing_data")] [Column("weighing_data")]
public string? WeighingData { get; set; } public string? WeighingData { get; set; }
[NotMapped] [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 { get {
try { try {
var obj = JsonNode.Parse(WeighingData!)!.AsObject(); var obj = JsonNode.Parse(WeighingData!)!.AsObject();
@@ -133,12 +133,13 @@ namespace Elwig.Models.Entities {
obj["id"]?.AsValue().GetValue<string>(), obj["id"]?.AsValue().GetValue<string>(),
obj["gross_weight"]?.AsValue().GetValue<int>(), obj["gross_weight"]?.AsValue().GetValue<int>(),
obj["tare_weight"]?.AsValue().GetValue<int>(), obj["tare_weight"]?.AsValue().GetValue<int>(),
obj["tare_correction"]?.AsValue().GetValue<int>(),
obj["net_weight"]?.AsValue().GetValue<int>(), obj["net_weight"]?.AsValue().GetValue<int>(),
DateOnly.TryParseExact(obj["date"]?.AsValue().GetValue<string>(), "yyyy-MM-dd", out var d) ? d : null, DateOnly.TryParseExact(obj["date"]?.AsValue().GetValue<string>(), "yyyy-MM-dd", out var d) ? d : null,
TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null
); );
} catch { } catch {
return (null, null, null, null, null, null, null); return (null, null, null, null, null, null, null, null);
} }
} }
} }
+2
View File
@@ -36,6 +36,7 @@ namespace Elwig.Services {
vm.SortId = ""; vm.SortId = "";
vm.GradationKmwString = ""; vm.GradationKmwString = "";
vm.WeightString = ""; vm.WeightString = "";
vm.Tare = "-";
vm.IsManualWeighing = false; vm.IsManualWeighing = false;
vm.PartComment = ""; vm.PartComment = "";
vm.TemperatureString = ""; vm.TemperatureString = "";
@@ -52,6 +53,7 @@ namespace Elwig.Services {
vm.WineRd = ControlUtils.GetItemFromSourceWithPk(vm.WineRdSource, p.KgNr, p.RdNr) as WbRd; vm.WineRd = ControlUtils.GetItemFromSourceWithPk(vm.WineRdSource, p.KgNr, p.RdNr) as WbRd;
vm.WineOrigin = ControlUtils.GetItemFromSourceWithPk(vm.WineOriginSource, p.HkId) as WineOrigin; vm.WineOrigin = ControlUtils.GetItemFromSourceWithPk(vm.WineOriginSource, p.HkId) as WineOrigin;
vm.WeightString = $"{p.Weight:N0}"; vm.WeightString = $"{p.Weight:N0}";
vm.Tare = p.WeighingInfo.Tare is int t && t != 0 ? $"{t:N0} kg" : "-";
vm.IsManualWeighing = p.IsManualWeighing; vm.IsManualWeighing = p.IsManualWeighing;
vm.IsNetWeight = p.IsNetWeight; vm.IsNetWeight = p.IsNetWeight;
@@ -120,6 +120,8 @@ namespace Elwig.ViewModels {
set => WeightString = $"{value:N0}"; set => WeightString = $"{value:N0}";
} }
[ObservableProperty] [ObservableProperty]
private string? _tare = "-";
[ObservableProperty]
private bool _isManualWeighing; private bool _isManualWeighing;
[ObservableProperty] [ObservableProperty]
private bool? _isNetWeightValue = false; private bool? _isNetWeightValue = false;
+9 -2
View File
@@ -565,16 +565,23 @@
TextChanged="WeightInput_TextChanged" TextChanged="WeightInput_TextChanged"
Grid.Column="1" Width="70" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/> Grid.Column="1" Width="70" Margin="0,10,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Label Content="Tara:" Margin="10,40,10,10"/>
<TextBlock x:Name="Tare" Text="{Binding Tare}" Width="40"
Grid.Column="1" Margin="30,44,10,10" TextAlignment="Center" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<CheckBox x:Name="ManualWeighingInput" IsChecked="{Binding IsManualWeighing, Mode=TwoWay}" <CheckBox x:Name="ManualWeighingInput" IsChecked="{Binding IsManualWeighing, Mode=TwoWay}"
Content="Handwiegung" IsEnabled="False" Content="Handwiegung" IsEnabled="False"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,45,10,10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,70,10,10" Grid.Column="0" Grid.ColumnSpan="2"
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/> Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
<CheckBox x:Name="GerebeltGewogenInput" IsChecked="{Binding IsNetWeightValue, Mode=TwoWay}" <CheckBox x:Name="GerebeltGewogenInput" IsChecked="{Binding IsNetWeightValue, Mode=TwoWay}"
Content="Gerebelt gewogen" IsThreeState="True" Content="Gerebelt gewogen" IsThreeState="True"
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,95,10,10" Grid.Column="0" Grid.ColumnSpan="2"
Checked="GerebeltGewogenInput_Changed" Unchecked="GerebeltGewogenInput_Changed" Indeterminate="GerebeltGewogenInput_Changed"/> Checked="GerebeltGewogenInput_Changed" Unchecked="GerebeltGewogenInput_Changed" Indeterminate="GerebeltGewogenInput_Changed"/>
<Button x:Name="CorrectTareButton" Content="Tara korrigieren" Width="120" Visibility="Hidden"
Click="CorrectTareButton_Click"
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
<Button x:Name="WeighingAButton" Content="Wiegen A" Width="120" <Button x:Name="WeighingAButton" Content="Wiegen A" Width="120"
Click="WeighingButton_Click" Click="WeighingButton_Click"
VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/> VerticalAlignment="Top" HorizontalAlignment="Right" Margin="10,10,10,10" Grid.Column="2"/>
@@ -612,14 +612,20 @@ namespace Elwig.Windows {
ClearOriginalValues(); ClearOriginalValues();
ClearDefaultValues(); ClearDefaultValues();
ViewModel.FillInputs(p); ViewModel.FillInputs(p);
CorrectTareButton.Visibility = !ViewModel.IsReceipt && p.WeighingInfo.Tare != null && p.WeighingInfo.Tare != 0 ? Visibility.Visible : Visibility.Hidden;
FinishInputFilling(); FinishInputFilling();
} }
new protected void ClearInputs(bool validate = false) { new protected void ClearInputs(bool validate = false) {
ViewModel.ClearInputs(); ViewModel.ClearInputs();
CorrectTareButton.Visibility = Visibility.Hidden;
base.ClearInputs(validate); base.ClearInputs(validate);
} }
private void CorrectTareButton_Click(object sender, RoutedEventArgs evt) {
}
private void WeighingButton_Click(object sender, RoutedEventArgs evt) { private void WeighingButton_Click(object sender, RoutedEventArgs evt) {
int index = Array.IndexOf(WeighingButtons, sender as Button); int index = Array.IndexOf(WeighingButtons, sender as Button);
if (index >= 0) WeighingButton_Click(index); if (index >= 0) WeighingButton_Click(index);
@@ -651,6 +657,7 @@ namespace Elwig.Windows {
private void OnWeighingResult(IScale scale, WeighingResult res) { private void OnWeighingResult(IScale scale, WeighingResult res) {
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) { if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
ViewModel.Weight = res.NetWeight; ViewModel.Weight = res.NetWeight;
ViewModel.Tare = res.TareWeight is int t && t != 0 ? $"{t:N0} kg" : "-";
ViewModel.ScaleTerminalId = scale.ScaleTerminalId; ViewModel.ScaleTerminalId = scale.ScaleTerminalId;
ViewModel.WeighingData = res.ToJson().ToJsonString(); ViewModel.WeighingData = res.ToJson().ToJsonString();
ViewModel.ManualWeighingReason = null; ViewModel.ManualWeighingReason = null;