Weighing: Do not ignore gross and tare weight and show it on DeliveryNote
This commit is contained in:
@ -60,8 +60,18 @@
|
||||
}
|
||||
}
|
||||
<tr><td></td><td colspan="5">
|
||||
@Raw(part.IsManualWeighing ? "<i>Handwiegung</i>" : $"<i>Waage:</i> {part.ScaleId ?? "?"}, <i>ID:</i> {part.WeighingId ?? "?"}")
|
||||
(@(part.IsNetWeight ? "netto/gerebelt gewogen" : "brutto/nicht gerebelt gewogen"))@Raw(part.WeighingReason != null ? $", <i>Begründung:</i>" : "") @part.WeighingReason
|
||||
@if (part.IsManualWeighing) {
|
||||
<i>Handwiegung @(part.IsNetWeight ? " (gerebelt gewogen)" : " (nicht gerebelt gewogen)")</i>@Raw(part.WeighingReason != null ? ", <i>Begründung:</i> " : "") @part.WeighingReason
|
||||
} else {
|
||||
var info = part.WeighingInfo;
|
||||
<i>Waage:</i> @(part.ScaleId ?? "?")@(", ") <i>ID:</i> @(info.Id ?? "?")
|
||||
@(info.Date != null || info.Time != null ? " – " : "")@(info.Time != null ? $"{info.Time:HH:mm}" : "")@(info.Date != null ? $", {info.Date:dd.MM.yyyy}" : "")
|
||||
@if (info.Gross != null && info.Tare != null && info.Net != null) {
|
||||
<br/><i>Brutto:</i> @($"{info.Gross:N0} kg")@(" – ") <i>Tara:</i> @($"{info.Tare:N0} kg")@(" – ") <i>Netto:</i> @($"{info.Net:N0} kg")@(" – ")@Raw(part.IsNetWeight ? "<i>gerebelt gewogen</i>" : "<i>nicht gerebelt gewogen</i>")
|
||||
} else {
|
||||
@Raw($" <i>({(part.IsNetWeight ? "gerebelt gewogen" : "nicht gerebelt gewogen")})</i>")
|
||||
}
|
||||
}
|
||||
</td></tr>
|
||||
@if (part.Comment != null) {
|
||||
<tr><td></td><td colspan="5"><i>Anmerkung:</i> @part.Comment</td></tr>
|
||||
|
@ -9,7 +9,7 @@ namespace Elwig.Helpers {
|
||||
public static class AppDbUpdater {
|
||||
|
||||
// Don't forget to update value in Tests/fetch-resources.bat!
|
||||
public static readonly int RequiredSchemaVersion = 24;
|
||||
public static readonly int RequiredSchemaVersion = 25;
|
||||
|
||||
private static int VersionOffset = 0;
|
||||
|
||||
|
@ -194,7 +194,7 @@ namespace Elwig.Helpers.Export {
|
||||
if (p.Temperature != null) obj["temperature"] = p.Temperature;
|
||||
if (p.Acid != null) obj["acid"] = p.Acid;
|
||||
if (p.ScaleId != null) obj["scale_id"] = p.ScaleId;
|
||||
if (p.WeighingId != null) obj["weighing_id"] = p.WeighingId;
|
||||
if (p.WeighingData != null) obj["weighing_data"] = JsonNode.Parse(p.WeighingData);
|
||||
if (p.WeighingReason != null) obj["weighing_reason"] = p.WeighingReason;
|
||||
return obj;
|
||||
}).ToArray()),
|
||||
@ -238,7 +238,7 @@ namespace Elwig.Helpers.Export {
|
||||
Temperature = p["temperature"]?.AsValue().GetValue<double>(),
|
||||
Acid = p["acid"]?.AsValue().GetValue<double>(),
|
||||
ScaleId = p["scale_id"]?.AsValue().GetValue<string>(),
|
||||
WeighingId = p["weighing_id"]?.AsValue().GetValue<string>(),
|
||||
WeighingData = p["weighing_data"]?.AsObject().ToJsonString(),
|
||||
WeighingReason = p["weighing_reason"]?.AsValue().GetValue<string>(),
|
||||
}).ToList(), json["parts"]!.AsArray().SelectMany(p => p!["modids"]!.AsArray().Select(m => new DeliveryPartModifier {
|
||||
Year = year,
|
||||
|
@ -79,7 +79,7 @@ namespace Elwig.Helpers.Weighing {
|
||||
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
|
||||
var parsedDate = DateOnly.Parse(date);
|
||||
return new() {
|
||||
Weight = int.Parse(netto),
|
||||
NetWeight = int.Parse(netto),
|
||||
WeighingId = identNr,
|
||||
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
|
||||
Date = parsedDate,
|
||||
|
@ -69,13 +69,14 @@ namespace Elwig.Helpers.Weighing {
|
||||
var time = line[37..43];
|
||||
|
||||
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
|
||||
var parsedDate = DateOnly.ParseExact(date, "yyyyMMdd");
|
||||
return new() {
|
||||
Weight = int.Parse(netto),
|
||||
GrossWeight = int.Parse(brutto),
|
||||
TareWeight = int.Parse(tara),
|
||||
NetWeight = int.Parse(netto),
|
||||
WeighingId = identNr,
|
||||
FullWeighingId = identNr,
|
||||
Date = parsedDate,
|
||||
Time = TimeOnly.ParseExact(time, "HHmmss"),
|
||||
Date = DateOnly.TryParseExact(date, "yyyyMMdd", out var d) ? d : null,
|
||||
Time = TimeOnly.TryParseExact(time, "HHmmss", out var t) ? t : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Elwig.Helpers.Weighing {
|
||||
/// <summary>
|
||||
/// Interface for controlling a a scale which responds to commands sent to it
|
||||
/// Interface for controlling a weighing scale which responds to commands sent to it
|
||||
/// </summary>
|
||||
public interface ICommandScale : IScale {
|
||||
/// <summary>
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace Elwig.Helpers.Weighing {
|
||||
/// <summary>
|
||||
/// Interface for controlling a a scale which automatically sends weighing updates
|
||||
/// Interface for controlling a weighing scale which automatically sends weighing updates
|
||||
/// </summary>
|
||||
public interface IEventScale : IScale {
|
||||
|
||||
|
@ -2,7 +2,7 @@ using System;
|
||||
|
||||
namespace Elwig.Helpers.Weighing {
|
||||
/// <summary>
|
||||
/// Interface for controlling a industrial scale (industrial terminal, "IT")
|
||||
/// Interface for controlling a industrial weighing scale (industrial terminal, "IT")
|
||||
/// </summary>
|
||||
public interface IScale : IDisposable {
|
||||
/// <summary>
|
||||
|
@ -98,7 +98,9 @@ namespace Elwig.Helpers.Weighing {
|
||||
identNr = identNr.Length > 0 && identNr != "0" ? identNr : null;
|
||||
var parsedDate = DateOnly.Parse(date);
|
||||
return new() {
|
||||
Weight = int.Parse(netto),
|
||||
GrossWeight = int.Parse(brutto),
|
||||
TareWeight = int.Parse(tara),
|
||||
NetWeight = int.Parse(netto),
|
||||
WeighingId = identNr,
|
||||
FullWeighingId = identNr != null ? $"{parsedDate:yyyy-MM-dd}/{identNr}" : null,
|
||||
Date = parsedDate,
|
||||
|
@ -1,12 +1,7 @@
|
||||
using System;
|
||||
|
||||
namespace Elwig.Helpers.Weighing {
|
||||
public class WeighingEventArgs : EventArgs {
|
||||
|
||||
public WeighingResult Result { get; set; }
|
||||
|
||||
public WeighingEventArgs(WeighingResult result) {
|
||||
Result = result;
|
||||
}
|
||||
public class WeighingEventArgs(WeighingResult result) : EventArgs {
|
||||
public readonly WeighingResult Result = result;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,25 @@
|
||||
using System;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Elwig.Helpers.Weighing {
|
||||
/// <summary>
|
||||
/// Result of a weighing process on an industrial scale
|
||||
/// Result of a weighing process on an industrial weighing scale
|
||||
/// </summary>
|
||||
public struct WeighingResult {
|
||||
/// <summary>
|
||||
/// Measured gross weight in kg
|
||||
/// </summary>
|
||||
public int? GrossWeight;
|
||||
|
||||
/// <summary>
|
||||
/// Measured tare weight in kg
|
||||
/// </summary>
|
||||
public int? TareWeight;
|
||||
|
||||
/// <summary>
|
||||
/// Measured net weight in kg
|
||||
/// </summary>
|
||||
public int? Weight;
|
||||
public int? NetWeight;
|
||||
|
||||
/// <summary>
|
||||
/// Weighing id (or IdentNr) provided by the scale
|
||||
@ -30,12 +41,22 @@ namespace Elwig.Helpers.Weighing {
|
||||
/// </summary>
|
||||
public TimeOnly? Time;
|
||||
|
||||
/// <returns><Weight/WeighingId/Date/Time></returns>
|
||||
/// <returns><[GrossWeight-TaraWeight=]NetWeight/WeighingId/Date/Time></returns>
|
||||
public override readonly string ToString() {
|
||||
var w = Weight != null ? $"{Weight}kg" : "";
|
||||
var w = NetWeight != null ? (GrossWeight != null && TareWeight != null ? $"{GrossWeight}-{TareWeight}=" : "") + $"{NetWeight}kg" : "";
|
||||
return $"<{w}/{WeighingId}/{Date:yyyy-MM-dd}/{Time:HH:mm}>";
|
||||
}
|
||||
|
||||
|
||||
public readonly JsonObject ToJson() {
|
||||
var obj = new JsonObject();
|
||||
if (FullWeighingId != null) obj["id"] = FullWeighingId;
|
||||
if (WeighingId != null) obj["nr"] = int.Parse(WeighingId);
|
||||
if (Date != null) obj["date"] = $"{Date:yyyy-MM-dd}";
|
||||
if (Time != null) obj["time"] = $"{Time:HH:mm:ss}";
|
||||
if (GrossWeight != null) obj["gross_weight"] = GrossWeight;
|
||||
if (TareWeight != null) obj["tare_weight"] = TareWeight;
|
||||
if (NetWeight != null) obj["net_weight"] = NetWeight;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Nodes;
|
||||
|
||||
namespace Elwig.Models.Entities {
|
||||
[Table("delivery_part"), PrimaryKey("Year", "DId", "DPNr")]
|
||||
@ -99,8 +101,26 @@ namespace Elwig.Models.Entities {
|
||||
[Column("scale_id")]
|
||||
public string? ScaleId { get; set; }
|
||||
|
||||
[Column("weighing_id")]
|
||||
public string? WeighingId { get; set; }
|
||||
[Column("weighing_data")]
|
||||
public string? WeighingData { get; set; }
|
||||
[NotMapped]
|
||||
public (string? Id, int? Gross, int? Tare, int? Net, DateOnly? Date, TimeOnly? Time) WeighingInfo {
|
||||
get {
|
||||
try {
|
||||
var obj = JsonNode.Parse(WeighingData!)!.AsObject();
|
||||
return (
|
||||
obj["id"]?.AsValue().GetValue<string>(),
|
||||
obj["gross_weight"]?.AsValue().GetValue<int>(),
|
||||
obj["tare_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,
|
||||
TimeOnly.TryParseExact(obj["time"]?.AsValue().GetValue<string>(), ["HH:mm:ss", "HH:mm"], out var t) ? t : null
|
||||
);
|
||||
} catch {
|
||||
return (null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Column("weighing_reason")]
|
||||
public string? WeighingReason { get; set; }
|
||||
|
4
Elwig/Resources/Sql/24-25.sql
Normal file
4
Elwig/Resources/Sql/24-25.sql
Normal file
@ -0,0 +1,4 @@
|
||||
-- schema version 24 to 25
|
||||
|
||||
ALTER TABLE delivery_part RENAME COLUMN weighing_id TO weighing_data;
|
||||
UPDATE delivery_part SET weighing_data = '{"id":"' || weighing_data || '","nr":' || SUBSTR(weighing_data, INSTR(weighing_data, '/') + 1) || '}';
|
@ -80,7 +80,7 @@ namespace Elwig.Services {
|
||||
vm.IsGebunden = p.IsGebunden;
|
||||
|
||||
vm.ScaleId = p.ScaleId;
|
||||
vm.WeighingId = p.WeighingId;
|
||||
vm.WeighingData = p.WeighingData;
|
||||
vm.ManualWeighingReason = p.WeighingReason;
|
||||
}
|
||||
|
||||
@ -174,11 +174,11 @@ namespace Elwig.Services {
|
||||
prd = prd.And(p => p.IsManualWeighing == false);
|
||||
filter.RemoveAt(i--);
|
||||
filterNames.Add("keine Handwiegung");
|
||||
} else if (e.ToLower() is "bto" or "brut" or "brutt" or "brutto" or "!gerebelt") {
|
||||
} else if (e.ToLower() == "!gerebelt") {
|
||||
prd = prd.And(p => p.IsNetWeight == false);
|
||||
filter.RemoveAt(i--);
|
||||
filterNames.Add("brutto Wiegung");
|
||||
} else if (e.ToLower() is "nto" or "net" or "nett" or "netto" or "gerebelt") {
|
||||
} else if (e.ToLower() == "gerebelt") {
|
||||
prd = prd.And(p => p.IsNetWeight == true);
|
||||
filter.RemoveAt(i--);
|
||||
filterNames.Add("netto Wiegung");
|
||||
@ -465,7 +465,7 @@ namespace Elwig.Services {
|
||||
Weight = (int)vm.Weight!,
|
||||
IsManualWeighing = vm.IsManualWeighing,
|
||||
ScaleId = vm.ScaleId,
|
||||
WeighingId = vm.WeighingId,
|
||||
WeighingData = vm.WeighingData,
|
||||
WeighingReason = vm.ManualWeighingReason,
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace Elwig.ViewModels {
|
||||
[ObservableProperty]
|
||||
private string? _scaleId;
|
||||
[ObservableProperty]
|
||||
private string? _weighingId;
|
||||
private string? _weighingData;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _filterTodayOnly;
|
||||
|
@ -176,7 +176,7 @@
|
||||
<Bold>Handwiegung</Bold>: handw[iegung], !Handw[iegung] (alle ohne Handwiegung)<LineBreak/>
|
||||
<Bold>Handlese</Bold>: Handl[ese], !handl[ese] (alle ohne Handlese)<LineBreak/>
|
||||
<Bold>Gebunden</Bold>: geb[unden], ungeb[unden], !geb[unden], !ungeb[unden]<LineBreak/>
|
||||
<Bold>Brutto/Netto Wiegung</Bold>: bto, Brut[to], nto, Net[to], gerebelt, !Gerebelt<LineBreak/>
|
||||
<Bold>Gerebelt</Bold>: gerebelt, !Gerebelt (nicht gerebelt gewogen)<LineBreak/>
|
||||
<Bold>Freitext</Bold>: z.B. Lieferscheinnummern, Anmerkung, "quw" (sucht nach dem Text "quw")
|
||||
</TextBlock>
|
||||
</TextBox.ToolTip>
|
||||
@ -469,7 +469,7 @@
|
||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||
|
||||
<CheckBox x:Name="GerebeltGewogenInput" IsChecked="{Binding IsNetWeight, Mode=TwoWay}"
|
||||
Content="Netto (gerebelt gewogen)"
|
||||
Content="Gerebelt gewogen"
|
||||
VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,75,10,10" Grid.Column="0" Grid.ColumnSpan="2"
|
||||
Checked="GerebeltGewogenInput_Changed" Unchecked="GerebeltGewogenInput_Changed"/>
|
||||
|
||||
|
@ -285,7 +285,7 @@ namespace Elwig.Windows {
|
||||
|
||||
private void InitialInputs() {
|
||||
ViewModel.LastScaleError = null;
|
||||
ViewModel.WeighingId = null;
|
||||
ViewModel.WeighingData = null;
|
||||
ViewModel.ScaleId = null;
|
||||
ViewModel.ManualWeighingReason = null;
|
||||
|
||||
@ -525,7 +525,7 @@ namespace Elwig.Windows {
|
||||
OnWeighingResult(s, res);
|
||||
} catch (Exception ex) {
|
||||
ViewModel.LastScaleError = ex.Message.Split(": ")[^1];
|
||||
OnWeighingResult(s, new() { Weight = 0 });
|
||||
OnWeighingResult(s, new());
|
||||
MessageBox.Show($"Beim Wiegen ist ein Fehler aufgetreten:\n\n{ex.Message}", "Waagenfehler",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
@ -538,16 +538,16 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private void OnWeighingResult(IScale scale, WeighingResult res) {
|
||||
if ((res.Weight ?? 0) > 0 && res.FullWeighingId != null) {
|
||||
ViewModel.Weight = res.Weight;
|
||||
if ((res.NetWeight ?? 0) > 0 && res.FullWeighingId != null) {
|
||||
ViewModel.Weight = res.NetWeight;
|
||||
ViewModel.ScaleId = scale.ScaleId;
|
||||
ViewModel.WeighingId = res.FullWeighingId;
|
||||
ViewModel.WeighingData = res.ToJson().ToJsonString();
|
||||
ViewModel.ManualWeighingReason = null;
|
||||
ManualWeighingInput.IsChecked = false;
|
||||
} else {
|
||||
ViewModel.Weight = null;
|
||||
ViewModel.ScaleId = null;
|
||||
ViewModel.WeighingId = null;
|
||||
ViewModel.WeighingData = null;
|
||||
}
|
||||
ViewModel.LastScaleError = null;
|
||||
TextBox_TextChanged(WeightInput, null);
|
||||
@ -842,7 +842,7 @@ namespace Elwig.Windows {
|
||||
ManualWeighingInput.IsChecked = true;
|
||||
ViewModel.ManualWeighingReason = res?.Item2;
|
||||
ViewModel.ScaleId = null;
|
||||
ViewModel.WeighingId = null;
|
||||
ViewModel.WeighingData = null;
|
||||
}
|
||||
|
||||
protected override void ShortcutEdit() {
|
||||
@ -1004,7 +1004,7 @@ namespace Elwig.Windows {
|
||||
DId = await ctx.NextDId(p.Year),
|
||||
LNr = lnr,
|
||||
DateString = $"{delivery.Date:yyyy-MM-dd}",
|
||||
TimeString = $"{delivery.Time:HH:mm:SS}",
|
||||
TimeString = $"{delivery.Time:HH:mm:ss}",
|
||||
ZwstId = delivery.ZwstId,
|
||||
MgNr = delivery.MgNr,
|
||||
Comment = delivery.Comment,
|
||||
|
Reference in New Issue
Block a user