Config: Add option to specify weighing mode
All checks were successful
Test / Run tests (push) Successful in 2m8s
All checks were successful
Test / Run tests (push) Successful in 2m8s
This commit is contained in:
@@ -115,6 +115,16 @@ namespace Elwig {
|
|||||||
BranchNum = branches.Count;
|
BranchNum = branches.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Config.WeighingMode == null) {
|
||||||
|
if (App.Client.IsMatzen || App.Client.IsWolkersdorf) {
|
||||||
|
Config.WeighingMode = WeighingMode.Net;
|
||||||
|
} else if (App.Client.IsHaugsdorf || App.Client.IsSitzendorf) {
|
||||||
|
Config.WeighingMode = WeighingMode.Box;
|
||||||
|
} else if (App.Client.IsBaden || App.Client.IsGrInzersdorf) {
|
||||||
|
Config.WeighingMode = WeighingMode.Gross;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Utils.RunBackground("Temp File Cleanup", () => {
|
Utils.RunBackground("Temp File Cleanup", () => {
|
||||||
Utils.CleanupTempFiles();
|
Utils.CleanupTempFiles();
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
@@ -19,14 +19,6 @@ namespace Elwig.Helpers {
|
|||||||
public bool IsSitzendorf => IsWinzerkeller && App.ZwstId == "S";
|
public bool IsSitzendorf => IsWinzerkeller && App.ZwstId == "S";
|
||||||
public bool IsGrInzersdorf => IsWeinland;
|
public bool IsGrInzersdorf => IsWeinland;
|
||||||
|
|
||||||
public bool HasNetWeighing(string? zwstId) => IsMatzen || (IsWinzerkeller && zwstId == "W");
|
|
||||||
public bool HasNetWeighing(Branch? b) => HasNetWeighing(b?.ZwstId);
|
|
||||||
public bool HasNetWeighing() => HasNetWeighing(App.ZwstId);
|
|
||||||
|
|
||||||
public bool HasBoxWeighing(string? zwstId) => IsWinzerkeller && (zwstId != "W");
|
|
||||||
public bool HasBoxWeighing(Branch? b) => HasBoxWeighing(b?.ZwstId);
|
|
||||||
public bool HasBoxWeighing() => HasBoxWeighing(App.ZwstId);
|
|
||||||
|
|
||||||
public string NameToken;
|
public string NameToken;
|
||||||
public string NameShort;
|
public string NameShort;
|
||||||
public string Name;
|
public string Name;
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -5,6 +6,8 @@ using Microsoft.Extensions.Configuration;
|
|||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
|
|
||||||
|
public enum WeighingMode { Gross, Net, Box }
|
||||||
|
|
||||||
public record struct ScaleConfig {
|
public record struct ScaleConfig {
|
||||||
public string Id;
|
public string Id;
|
||||||
public string? Type;
|
public string? Type;
|
||||||
@@ -41,6 +44,7 @@ namespace Elwig.Helpers {
|
|||||||
public string DatabaseFile = App.DataPath + "database.sqlite3";
|
public string DatabaseFile = App.DataPath + "database.sqlite3";
|
||||||
public string? DatabaseLog = null;
|
public string? DatabaseLog = null;
|
||||||
public string? Branch = null;
|
public string? Branch = null;
|
||||||
|
public WeighingMode? WeighingMode;
|
||||||
public string? UpdateUrl = null;
|
public string? UpdateUrl = null;
|
||||||
public bool UpdateAuto = false;
|
public bool UpdateAuto = false;
|
||||||
public string? SyncUrl = null;
|
public string? SyncUrl = null;
|
||||||
@@ -74,6 +78,8 @@ namespace Elwig.Helpers {
|
|||||||
DatabaseLog = log != null ? Path.Combine(Path.GetDirectoryName(FileName) ?? App.DataPath, log) : null;
|
DatabaseLog = log != null ? Path.Combine(Path.GetDirectoryName(FileName) ?? App.DataPath, log) : null;
|
||||||
Branch = config["general:branch"];
|
Branch = config["general:branch"];
|
||||||
Debug = TrueValues.Contains(config["general:debug"]?.ToLower());
|
Debug = TrueValues.Contains(config["general:debug"]?.ToLower());
|
||||||
|
var weighing = config["general:weighing"];
|
||||||
|
WeighingMode = weighing != null && Enum.TryParse<WeighingMode>(weighing, true, out var w) ? w : null;
|
||||||
UpdateUrl = config["update:url"];
|
UpdateUrl = config["update:url"];
|
||||||
UpdateAuto = TrueValues.Contains(config["update:auto"]?.ToLower());
|
UpdateAuto = TrueValues.Contains(config["update:auto"]?.ToLower());
|
||||||
SyncUrl = config["sync:url"];
|
SyncUrl = config["sync:url"];
|
||||||
|
@@ -291,7 +291,7 @@ namespace Elwig.Windows {
|
|||||||
DateInput.IsReadOnly = true;
|
DateInput.IsReadOnly = true;
|
||||||
TimeInput.IsReadOnly = true;
|
TimeInput.IsReadOnly = true;
|
||||||
BranchInput.IsEnabled = false;
|
BranchInput.IsEnabled = false;
|
||||||
GerebeltGewogenInput.IsEnabled = !App.Client.HasNetWeighing(ViewModel.Branch);
|
GerebeltGewogenInput.IsEnabled = App.Config.WeighingMode != WeighingMode.Net;
|
||||||
OnSecondPassed(null, null);
|
OnSecondPassed(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void InitialDefaultInputs() {
|
private void InitialDefaultInputs() {
|
||||||
if (App.Client.HasNetWeighing(ViewModel.Branch)) {
|
if (App.Config.WeighingMode == WeighingMode.Net) {
|
||||||
GerebeltGewogenInput.IsEnabled = false;
|
GerebeltGewogenInput.IsEnabled = false;
|
||||||
SetDefaultValue(GerebeltGewogenInput, true);
|
SetDefaultValue(GerebeltGewogenInput, true);
|
||||||
} else {
|
} else {
|
||||||
@@ -315,7 +315,7 @@ namespace Elwig.Windows {
|
|||||||
UnsetDefaultValue(GerebeltGewogenInput);
|
UnsetDefaultValue(GerebeltGewogenInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (App.Client.HasBoxWeighing(ViewModel.Branch)) {
|
if (App.Config.WeighingMode == WeighingMode.Box) {
|
||||||
LesewagenInput.IsEnabled = false;
|
LesewagenInput.IsEnabled = false;
|
||||||
SetDefaultValue(LesewagenInput, false);
|
SetDefaultValue(LesewagenInput, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -323,7 +323,7 @@ namespace Elwig.Windows {
|
|||||||
UnsetDefaultValue(LesewagenInput);
|
UnsetDefaultValue(LesewagenInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!App.Client.HasNetWeighing(ViewModel.Branch)) {
|
if (App.Config.WeighingMode != WeighingMode.Net) {
|
||||||
HandPickedInput.IsThreeState = false;
|
HandPickedInput.IsThreeState = false;
|
||||||
UnsetDefaultValue(HandPickedInput);
|
UnsetDefaultValue(HandPickedInput);
|
||||||
} else {
|
} else {
|
||||||
@@ -349,9 +349,9 @@ namespace Elwig.Windows {
|
|||||||
ClearOriginalValues();
|
ClearOriginalValues();
|
||||||
ClearDefaultValues();
|
ClearDefaultValues();
|
||||||
|
|
||||||
ViewModel.IsNetWeight = App.Client.HasNetWeighing(ViewModel.Branch);
|
ViewModel.IsNetWeight = App.Config.WeighingMode == WeighingMode.Net;
|
||||||
ViewModel.IsLesewagen = false;
|
ViewModel.IsLesewagen = false;
|
||||||
ViewModel.IsHandPicked = !App.Client.HasNetWeighing(ViewModel.Branch) ? true : null;
|
ViewModel.IsHandPicked = App.Config.WeighingMode != WeighingMode.Net ? true : null;
|
||||||
ViewModel.IsGebunden = null;
|
ViewModel.IsGebunden = null;
|
||||||
InitialDefaultInputs();
|
InitialDefaultInputs();
|
||||||
|
|
||||||
@@ -1144,7 +1144,7 @@ namespace Elwig.Windows {
|
|||||||
DateInput.IsReadOnly = !Menu_Settings_EnableFreeEditing.IsChecked;
|
DateInput.IsReadOnly = !Menu_Settings_EnableFreeEditing.IsChecked;
|
||||||
TimeInput.IsReadOnly = !Menu_Settings_EnableFreeEditing.IsChecked;
|
TimeInput.IsReadOnly = !Menu_Settings_EnableFreeEditing.IsChecked;
|
||||||
BranchInput.IsEnabled = Menu_Settings_EnableFreeEditing.IsChecked;
|
BranchInput.IsEnabled = Menu_Settings_EnableFreeEditing.IsChecked;
|
||||||
GerebeltGewogenInput.IsEnabled = App.Client.HasNetWeighing(ViewModel.Branch) || Menu_Settings_EnableFreeEditing.IsChecked;
|
GerebeltGewogenInput.IsEnabled = App.Config.WeighingMode == WeighingMode.Net || Menu_Settings_EnableFreeEditing.IsChecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisableWeighingButtons() {
|
private void DisableWeighingButtons() {
|
||||||
@@ -1395,17 +1395,17 @@ namespace Elwig.Windows {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void GerebeltGewogenInput_Changed(object sender, RoutedEventArgs evt) {
|
private void GerebeltGewogenInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
if ((IsEditing || IsCreating) && !App.Client.HasNetWeighing(ViewModel.Branch)) {
|
if ((IsEditing || IsCreating) && App.Config.WeighingMode != WeighingMode.Net) {
|
||||||
HandPickedInput.IsChecked = !GerebeltGewogenInput.IsChecked;
|
HandPickedInput.IsChecked = !GerebeltGewogenInput.IsChecked;
|
||||||
}
|
}
|
||||||
if (!ViewModel.IsReceipt || App.Client.HasNetWeighing(ViewModel.Branch)) {
|
if (!ViewModel.IsReceipt || App.Config.WeighingMode == WeighingMode.Net) {
|
||||||
GerebeltGewogenInput.IsChecked ??= false;
|
GerebeltGewogenInput.IsChecked ??= false;
|
||||||
}
|
}
|
||||||
CheckBox_Changed(sender, evt);
|
CheckBox_Changed(sender, evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandPickedInput_Changed(object sender, RoutedEventArgs evt) {
|
private void HandPickedInput_Changed(object sender, RoutedEventArgs evt) {
|
||||||
if ((IsEditing || IsCreating) && !App.Client.HasNetWeighing(ViewModel.Branch)) {
|
if ((IsEditing || IsCreating) && App.Config.WeighingMode != WeighingMode.Net) {
|
||||||
GerebeltGewogenInput.IsChecked = !HandPickedInput.IsChecked;
|
GerebeltGewogenInput.IsChecked = !HandPickedInput.IsChecked;
|
||||||
}
|
}
|
||||||
CheckBox_Changed(sender, evt);
|
CheckBox_Changed(sender, evt);
|
||||||
|
Reference in New Issue
Block a user