Weighing: Do not ignore gross and tare weight and show it on DeliveryNote
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user