219 lines
9.0 KiB
C#
219 lines
9.0 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Elwig.Helpers;
|
|
using Elwig.Models.Entities;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Windows.Controls;
|
|
|
|
namespace Elwig.ViewModels {
|
|
public partial class DeliveryAdminViewModel : ObservableObject {
|
|
|
|
public bool IsReceipt { get; set; } = false;
|
|
|
|
[ObservableProperty]
|
|
public partial string Title { get; set; } = "Lieferungen - Elwig";
|
|
|
|
public Member? FilterMember { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial string? SearchQuery { get; set; } = "";
|
|
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0) ?? []];
|
|
|
|
[ObservableProperty]
|
|
public partial string? LastScaleError { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? ManualWeighingReason { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? ScaleTerminalId { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? WeighingData { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial bool FilterTodayOnly { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool FilterAllSeasons { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool EnableAllSeasons { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? FilterSeasonString { get; set; }
|
|
public int? FilterSeason {
|
|
get => int.TryParse(FilterSeasonString, out var year) ? year : null;
|
|
set => FilterSeasonString = $"{value}";
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public partial Delivery? SelectedDelivery { get; set; }
|
|
[ObservableProperty]
|
|
public partial IEnumerable<Delivery> Deliveries { get; set; } = [];
|
|
|
|
[ObservableProperty]
|
|
public partial string? MgNrString { get; set; }
|
|
public int? MgNr {
|
|
get => int.TryParse(MgNrString, out var mgnr) ? mgnr : null;
|
|
set => MgNrString = $"{value}";
|
|
}
|
|
[ObservableProperty]
|
|
public partial Member? Member { get; set; }
|
|
[ObservableProperty]
|
|
public partial IEnumerable<Member> MemberSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial string? MemberAddress { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? LsNr { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? Date { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? Time { get; set; }
|
|
[ObservableProperty]
|
|
public partial Branch? Branch { get; set; }
|
|
[ObservableProperty]
|
|
public partial IEnumerable<Branch> BranchSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial string? Comment { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial string? SortId { get; set; }
|
|
[ObservableProperty]
|
|
public partial WineVar? WineVar { get; set; }
|
|
[ObservableProperty]
|
|
public partial IEnumerable<WineVar> WineVarSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial object? WineAttrObj { get; set; }
|
|
public WineAttr? WineAttr {
|
|
get => WineAttrObj as WineAttr;
|
|
set => WineAttrObj = value ?? WineAttrSource.FirstOrDefault();
|
|
}
|
|
[ObservableProperty]
|
|
public partial IEnumerable<object> WineAttrSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial object? WineCultObj { get; set; }
|
|
public WineCult? WineCult {
|
|
get => WineCultObj as WineCult;
|
|
set => WineCultObj = value ?? WineCultSource.FirstOrDefault();
|
|
}
|
|
[ObservableProperty]
|
|
public partial IEnumerable<object> WineCultSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial string? GradationOeString { get; set; }
|
|
public double? GradationOe {
|
|
get => double.TryParse(GradationOeString, out var oe) ? oe : null;
|
|
set => GradationOeString = $"{value:0}";
|
|
}
|
|
[ObservableProperty]
|
|
public partial string? GradationKmwString { get; set; }
|
|
public double? GradationKmw {
|
|
get => double.TryParse(GradationKmwString, out var kmw) ? kmw : null;
|
|
set => GradationKmwString = $"{value:0.0}";
|
|
}
|
|
[ObservableProperty]
|
|
public partial WineQualLevel? WineQualityLevel { get; set; }
|
|
[ObservableProperty]
|
|
public partial IEnumerable<WineQualLevel> WineQualityLevelSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial bool Abgewertet { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial string? WeightString { get; set; }
|
|
public int? Weight {
|
|
get => int.TryParse(WeightString?.Replace(Utils.GroupSeparator, ""), out var w) ? w : null;
|
|
set => WeightString = $"{value:N0}";
|
|
}
|
|
[ObservableProperty]
|
|
public partial string? TareString { get; set; } = "-";
|
|
public int? Tare {
|
|
get => int.TryParse(TareString?.Replace(Utils.GroupSeparator, "").Replace(" kg", ""), out var w) ? w : null;
|
|
set => TareString = value == null ? "-" : $"{value:N0} kg{(TargetTare != null ? "*" : "")}";
|
|
}
|
|
public int? ActualTare { get; set; }
|
|
public int? TargetTare { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool IsManualWeighing { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool? IsNetWeightValue { get; set; } = false;
|
|
public bool IsNetWeight {
|
|
get => IsNetWeightValue ?? false;
|
|
set => IsNetWeightValue = value;
|
|
}
|
|
|
|
[ObservableProperty]
|
|
public partial WineOrigin? WineOrigin { get; set; }
|
|
[ObservableProperty]
|
|
public partial IEnumerable<WineOrigin> WineOriginSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial object? WineKgObj { get; set; }
|
|
public AT_Kg? WineKg {
|
|
get => WineKgObj as AT_Kg;
|
|
set => WineKgObj = value ?? WineKgSource.FirstOrDefault();
|
|
}
|
|
[ObservableProperty]
|
|
public partial IEnumerable<object> WineKgSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial object? WineRdObj { get; set; }
|
|
public WbRd? WineRd {
|
|
get => WineRdObj as WbRd;
|
|
set => WineRdObj = value ?? WineRdSource.FirstOrDefault();
|
|
}
|
|
[ObservableProperty]
|
|
public partial IEnumerable<object> WineRdSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial bool? IsContracted { get; set; }
|
|
|
|
public ObservableCollection<Modifier> Modifiers { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial IEnumerable<Modifier> ModifiersSource { get; set; } = [];
|
|
[ObservableProperty]
|
|
public partial string? PartComment { get; set; }
|
|
[ObservableProperty]
|
|
public partial string? TemperatureString { get; set; }
|
|
public double? Temperature {
|
|
get => double.TryParse(TemperatureString, out var t) ? t : null;
|
|
set => TemperatureString = $"{value:0.0}";
|
|
}
|
|
[ObservableProperty]
|
|
public partial string? AcidString { get; set; }
|
|
public double? Acid {
|
|
get => double.TryParse(AcidString, out var a) ? a : null;
|
|
set => AcidString = $"{value:0.0}";
|
|
}
|
|
[ObservableProperty]
|
|
public partial bool? IsHandPicked { get; set; }
|
|
|
|
public string? Unloading {
|
|
get => IsUnloadingDumper ? DeliveryPart.Dumper : IsUnloadingPumped ? DeliveryPart.Pumped : IsUnloadingBox ? DeliveryPart.Box : null;
|
|
set {
|
|
switch (value) {
|
|
case DeliveryPart.Dumper: IsUnloadingDumper = true; break;
|
|
case DeliveryPart.Pumped: IsUnloadingPumped = true; break;
|
|
case DeliveryPart.Box: IsUnloadingBox = true; break;
|
|
default: IsUnloadingOther = true; break;
|
|
}
|
|
}
|
|
}
|
|
[ObservableProperty]
|
|
public partial bool IsUnloadingDumper { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool IsUnloadingPumped { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool IsUnloadingBox { get; set; }
|
|
[ObservableProperty]
|
|
public partial bool IsUnloadingOther { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial string StatusMembers { get; set; } = "-";
|
|
[ObservableProperty]
|
|
public partial string StatusDeliveries { get; set; } = "-";
|
|
[ObservableProperty]
|
|
public partial string StatusVarieties { get; set; } = "-";
|
|
[ObservableProperty]
|
|
public partial string StatusWeight { get; set; } = "-";
|
|
[ObservableProperty]
|
|
public partial string StatusGradation { get; set; } = "-";
|
|
|
|
[ObservableProperty]
|
|
public partial Grid? StatusWeightToolTip { get; set; }
|
|
[ObservableProperty]
|
|
public partial Grid? StatusGradationToolTip { get; set; }
|
|
}
|
|
}
|