WineAttr: Add MinQualId and MaxQualId
Test / Run tests (push) Successful in 2m27s

This commit is contained in:
lorenz.stechauner committed 2026-11-26 15:45:49 +01:00
1 parent bc419ce57a
commit 065fbc2eea
16 files changed
+161 -53

No files matched your search

+3 -1
View File
@@ -111,7 +111,7 @@ namespace Elwig.Helpers {
private static readonly Func<AppDbContext, bool, IAsyncEnumerable<WineQualLevel>> _compiledQueryWineQualityLevels =
EF.CompileAsyncQuery<AppDbContext, bool, WineQualLevel>((ctx, includePredicate) => ctx.WineQualityLevels
.Where(l => includePredicate || !l.IsPredicate)
.OrderBy(l => l.MinKmw));
.OrderBy(l => l.IsPredicate).ThenBy(l => l.MinKmw));
private static readonly Func<AppDbContext, int?, bool, IAsyncEnumerable<Modifier>> _compiledQueryModifiers =
EF.CompileAsyncQuery<AppDbContext, int?, bool, Modifier>((ctx, year, incudeNotActive) => ctx.Modifiers
@@ -217,6 +217,8 @@ namespace Elwig.Helpers {
modelBuilder.Entity<BillingAddr>().Navigation(a => a.PostalDest).AutoInclude();
modelBuilder.Entity<Modifier>().Navigation(m => m.Season).AutoInclude();
modelBuilder.Entity<Season>().Navigation(s => s.Currency).AutoInclude();
modelBuilder.Entity<WineAttr>().Navigation(s => s.MinQualityLevel).AutoInclude();
modelBuilder.Entity<WineAttr>().Navigation(s => s.MaxQualityLevel).AutoInclude();
modelBuilder.Entity<PaymentVar>().Navigation(v => v.Season).AutoInclude();
modelBuilder.Entity<PaymentDeliveryPart>().Navigation(p => p.Variant).AutoInclude();
modelBuilder.Entity<Credit>().Navigation(c => c.Payment).AutoInclude();
+1 -1
View File
@@ -12,7 +12,7 @@ namespace Elwig.Helpers {
public static class AppDbUpdater {
// Don't forget to update value in Tests/fetch-resources.bat!
public static readonly int RequiredSchemaVersion = 42;
public static readonly int RequiredSchemaVersion = 43;
private static int VersionOffset = 0;
+8
View File
@@ -81,6 +81,8 @@ namespace Elwig.Helpers {
public int ExportEbicsVersion;
public int ExportEbicsAddress;
public string? ReceiptMaxQualId;
public (int? AllowanceKg, double? AllowanceShares, int? AllowanceKgPerShare, double? AllowancePercent, int? MinShares) AutoAdjustShares;
public static readonly Dictionary<string, string?> DefaultParameters = new() {
@@ -211,6 +213,11 @@ namespace Elwig.Helpers {
case "FULL": ExportEbicsAddress = 2; break;
}
ReceiptMaxQualId = parameters.GetValueOrDefault("RECEIPT_MAX_QUALID", "QUW")?.ToUpper();
if (ReceiptMaxQualId?.Length != 3 || !ReceiptMaxQualId.All(char.IsAsciiLetter)) {
ReceiptMaxQualId = null;
}
var autoAdjust = (parameters.GetValueOrDefault("AUTOADJUST_BUSINESSSHARES") ?? "").Split(';');
AutoAdjustShares = autoAdjust.Length == 5 ? (
int.TryParse(autoAdjust[0], out var v1) ? v1 : null,
@@ -322,6 +329,7 @@ namespace Elwig.Helpers {
("MAIL_ORDERING", mailOrdering),
("EXPORT_EBICS_VERSION", ExportEbicsVersion.ToString()),
("EXPORT_EBICS_ADDRESS", exportEbicsAddress),
("RECEIPT_MAX_QUALID", ReceiptMaxQualId),
("AUTOADJUST_BUSINESSSHARES", autoAdjust),
];
}
+10
View File
@@ -23,6 +23,16 @@ namespace Elwig.Models.Entities {
[Column("fill_lower")]
public int FillLower { get; set; }
[Column("min_qualid")]
public string? MinQualId { get; set; }
[ForeignKey("MinQualId")]
public virtual WineQualLevel MinQualityLevel { get; private set; } = null!;
[Column("max_qualid")]
public string? MaxQualId { get; set; }
[ForeignKey("MaxQualId")]
public virtual WineQualLevel MaxQualityLevel { get; private set; } = null!;
public override string ToString() {
return Name;
}
+24
View File
@@ -0,0 +1,24 @@
-- schema version 42 to 43
ALTER TABLE wine_attribute ADD COLUMN min_qualid TEXT DEFAULT NULL;
ALTER TABLE wine_attribute ADD COLUMN max_qualid TEXT DEFAULT NULL;
UPDATE wine_attribute SET min_qualid = 'KAB', max_qualid = 'KAB' WHERE name LIKE '%Kabinett%';
UPDATE wine_attribute SET min_qualid = 'QUW' WHERE name LIKE '%DAC%';
UPDATE wine_attribute SET max_qualid = 'RSW' WHERE name LIKE '%wei%gepresst%' OR name LIKE '%saft%';
PRAGMA writable_schema = ON;
UPDATE sqlite_schema SET sql = REPLACE(sql, '
) STRICT', ',
CONSTRAINT fk_wine_attribute_wine_quality_level_min FOREIGN KEY (min_qualid) REFERENCES wine_quality_level (qualid)
ON UPDATE CASCADE
ON DELETE RESTRICT,
CONSTRAINT fk_wine_attribute_wine_quality_level_max FOREIGN KEY (max_qualid) REFERENCES wine_quality_level (qualid)
ON UPDATE CASCADE
ON DELETE RESTRICT
) STRICT')
WHERE type = 'table' AND name = 'wine_attribute';
PRAGMA schema_version = 4201;
PRAGMA writable_schema = OFF;
+1 -1
View File
@@ -415,7 +415,7 @@ namespace Elwig.Windows {
private void RevisionList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
RefreshInputs();
if (RevisionList.SelectedItem is AreaCmt c) {
if (RevisionList.SelectedItem is AreaCmt) {
EditAreaCommitmentButton.IsEnabled = true;
} else {
EditAreaCommitmentButton.IsEnabled = false;
+49 -16
View File
@@ -247,6 +247,8 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="110"/>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<Label Content="Identifikator:" Margin="10,10,0,10"/>
@@ -258,10 +260,28 @@
TextChanged="WineAttribute_Changed"/>
<CheckBox x:Name="WineAttributeActiveInput" Content="In Übernahme-Fenster anzeigen"
Grid.Column="1" Margin="0,74,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
Grid.Column="1" Grid.ColumnSpan="3" Margin="0,74,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
Checked="WineAttribute_Changed" Unchecked="WineAttribute_Changed"/>
<GroupBox Header="Auszahlung" Grid.ColumnSpan="2" Margin="10,100,10,10">
<Label Content="Niedrigste Qual.:" Margin="10,10,0,10" Grid.Column="2"/>
<ComboBox x:Name="WineAttributeMinQualityLevelInput" Grid.Column="3" Margin="0,10,10,10" HorizontalAlignment="Stretch"
TextSearch.TextPath="Name"
SelectionChanged="WineAttribute_Changed">
<ComboBox.ItemTemplateSelector>
<ctrl:WineQualityLevelTemplateSelector/>
</ComboBox.ItemTemplateSelector>
</ComboBox>
<Label Content="Höchste Qual.:" Margin="10,40,0,10" Grid.Column="2"/>
<ComboBox x:Name="WineAttributeMaxQualityLevelInput" Grid.Column="3" Margin="0,40,10,10" HorizontalAlignment="Stretch"
TextSearch.TextPath="Name"
SelectionChanged="WineAttribute_Changed">
<ComboBox.ItemTemplateSelector>
<ctrl:WineQualityLevelTemplateSelector/>
</ComboBox.ItemTemplateSelector>
</ComboBox>
<GroupBox Header="Auszahlung" Grid.ColumnSpan="4" Margin="10,100,10,10">
<Grid>
<Label Content="Max. Ertrag:" Margin="10,10,0,10"/>
<ctrl:UnitTextBox x:Name="WineAttributeMaxKgPerHaInput" Unit="kg/ha" TextChanged="WineAttributeMaxKgPerHaInput_TextChanged"
@@ -551,21 +571,34 @@
</TabItem>
<TabItem Header="Parameter">
<StackPanel>
<GroupBox x:Name="ParameterBusinessShare" Header="Geschäftsanteile" Margin="10,10,10,0" VerticalAlignment="Top">
<Grid>
<Label Content="Modus:" Margin="10,10,10,10"/>
<ComboBox x:Name="ParameterBusinessShareModeInput" Margin="160,10,10,10" Width="100"
HorizontalAlignment="Left">
<ComboBoxItem IsSelected="True">Normal</ComboBoxItem>
<ComboBoxItem>Rot/weiß</ComboBoxItem>
</ComboBox>
<StackPanel Orientation="Horizontal">
<GroupBox x:Name="ParameterBusinessShare" Header="Geschäftsanteile" Margin="10,10,10,0" VerticalAlignment="Stretch">
<Grid>
<Label Content="Modus:" Margin="10,10,10,10"/>
<ComboBox x:Name="ParameterBusinessShareModeInput" Margin="160,10,10,10" Width="100"
HorizontalAlignment="Left">
<ComboBoxItem IsSelected="True">Normal</ComboBoxItem>
<ComboBoxItem>Rot/weiß</ComboBoxItem>
</ComboBox>
<Label Content="Mitgliederbewegungen:" Margin="10,40,10,10"/>
<CheckBox x:Name="ParameterBusinessShareHistoryInput" Content="Mit Elwig erfassen" Margin="160,45,10,15"
HorizontalAlignment="Left"
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
</Grid>
</GroupBox>
<Label Content="Mitgliederbewegungen:" Margin="10,40,10,10"/>
<CheckBox x:Name="ParameterBusinessShareHistoryInput" Content="Mit Elwig erfassen" Margin="160,45,10,15"
HorizontalAlignment="Left"
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
</Grid>
</GroupBox>
<GroupBox x:Name="ParameterReceipt" Header="Übernahme" Margin="10,10,10,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid>
<Label Content="Höchste Qualitätsstufe:" Margin="10,10,0,10" Grid.Column="2"/>
<ComboBox x:Name="ParameterReceiptMaxQualityLevelInput" Grid.Column="3" Margin="150,10,10,10" Width="130"
TextSearch.TextPath="Name">
<ComboBox.ItemTemplateSelector>
<ctrl:WineQualityLevelTemplateSelector/>
</ComboBox.ItemTemplateSelector>
</ComboBox>
</Grid>
</GroupBox>
</StackPanel>
<GroupBox x:Name="ParameterAreaCmtGroup" Header="Berechnung Flächenbindungen (aktuelle Saison)" Margin="10,10,10,0" VerticalAlignment="Top">
<Grid>
<CheckBox x:Name="ParameterAllowAttrIntoLowerInput" Content="Erlauben Lieferungen auch auf (konfigurierte) &quot;schlechtere&quot; Flächenbindungen aufzuteilen"
@@ -19,9 +19,9 @@ namespace Elwig.Windows {
private bool _actUpdate = false;
private async Task AreaCommitmentTypesInitEditing(AppDbContext ctx) {
_actList = new(await ctx.AreaCommitmentTypes
_actList = [with(await ctx.AreaCommitmentTypes
.OrderBy(v => v.VtrgId)
.ToListAsync());
.ToListAsync())];
_acts = _actList.ToDictionary(v => v.VtrgId, v => (string?)v.VtrgId);
_actIds = _actList.ToDictionary(v => v, v => v.VtrgId);
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, _actList);
@@ -56,7 +56,7 @@ namespace Elwig.Windows {
.Where(_actIds.ContainsKey)
.Select(t => {
t.VtrgId = _actIds[t];
ctx.Entry(t).State = EntityState.Added;
ctx.Entry(t).State = EntityState.Modified;
return t;
}));
await ctx.SaveChangesAsync();
+2 -2
View File
@@ -19,7 +19,7 @@ namespace Elwig.Windows {
private bool _branchUpdate = false;
private async Task BranchesInitEditing(AppDbContext ctx) {
_branchList = new(await ctx.FetchBranches().ToListAsync());
_branchList = [with(await ctx.FetchBranches().ToListAsync())];
_branches = _branchList.ToDictionary(b => b.ZwstId, b => (string?)b.ZwstId);
_branchIds = _branchList.ToDictionary(b => b, b => b.ZwstId);
ControlUtils.RenewItemsSource(BranchList, _branchList);
@@ -50,7 +50,7 @@ namespace Elwig.Windows {
.Where(_branchIds.ContainsKey)
.Select(b => {
b.ZwstId = _branchIds[b];
ctx.Entry(b).State = EntityState.Added;
ctx.Entry(b).State = EntityState.Modified;
return b;
}));
await ctx.SaveChangesAsync();
+2 -2
View File
@@ -22,7 +22,7 @@ namespace Elwig.Windows {
private async Task ModifiersInitEditing(AppDbContext ctx) {
SeasonList.IsEnabled = false;
var year = (SeasonList.SelectedItem as Season)?.Year;
_modList = new(await ctx.FetchModifiers(year ?? 0).ToListAsync());
_modList = [with(await ctx.FetchModifiers(year ?? 0).ToListAsync())];
_mods = _modList.ToDictionary(m => m.ModId, m => (string?)m.ModId);
_modIds = _modList.ToDictionary(m => m, m => m.ModId);
ControlUtils.RenewItemsSource(SeasonModifierList, _modList);
@@ -61,7 +61,7 @@ namespace Elwig.Windows {
.Where(_modIds.ContainsKey)
.Select(m => {
m.ModId = _modIds[m];
ctx.Entry(m).State = EntityState.Added;
ctx.Entry(m).State = EntityState.Modified;
return m;
}));
await ctx.SaveChangesAsync();
+11 -2
View File
@@ -19,7 +19,7 @@ namespace Elwig.Windows {
private bool _attrUpdate = false;
private async Task WineAttributesInitEditing(AppDbContext ctx) {
_attrList = new(await ctx.FetchWineAttributes().ToListAsync());
_attrList = [with(await ctx.FetchWineAttributes().ToListAsync())];
_attrs = _attrList.ToDictionary(a => a.AttrId, a => (string?)a.AttrId);
_attrIds = _attrList.ToDictionary(a => a, a => a.AttrId);
ControlUtils.RenewItemsSource(WineAttributeList, _attrList);
@@ -50,7 +50,7 @@ namespace Elwig.Windows {
.Where(_attrIds.ContainsKey)
.Select(a => {
a.AttrId = _attrIds[a];
ctx.Entry(a).State = EntityState.Added;
ctx.Entry(a).State = EntityState.Modified;
return a;
}));
await ctx.SaveChangesAsync();
@@ -73,13 +73,18 @@ namespace Elwig.Windows {
WineAttributeIdInput.Text = "";
WineAttributeNameInput.Text = "";
WineAttributeActiveInput.IsChecked = false;
WineAttributeMinQualityLevelInput.SelectedIndex = 0;
WineAttributeMaxQualityLevelInput.SelectedIndex = 0;
WineAttributeMaxKgPerHaInput.Text = "";
WineAttributeStrictInput.IsChecked = false;
WineAttributeFillLowerInput.SelectedItem = null;
} else {
WineAttributeIdInput.Text = attr.AttrId;
WineAttributeNameInput.Text = attr.Name;
WineAttributeActiveInput.IsChecked = attr.IsActive;
ControlUtils.SelectItemWithPk(WineAttributeMinQualityLevelInput, attr.MinQualId);
ControlUtils.SelectItemWithPk(WineAttributeMaxQualityLevelInput, attr.MaxQualId);
WineAttributeMaxKgPerHaInput.Text = attr.MaxKgPerHa?.ToString() ?? "";
WineAttributeStrictInput.IsChecked = attr.IsStrict;
WineAttributeFillLowerInput.SelectedIndex = attr.FillLower;
@@ -113,6 +118,8 @@ namespace Elwig.Windows {
WineAttributeIdInput.Text != attr.AttrId ||
WineAttributeNameInput.Text != attr.Name ||
WineAttributeActiveInput.IsChecked != attr.IsActive ||
WineAttributeMinQualityLevelInput.SelectedItem as WineQualLevel != attr.MinQualityLevel ||
WineAttributeMaxQualityLevelInput.SelectedItem as WineQualLevel != attr.MaxQualityLevel ||
WineAttributeMaxKgPerHaInput.Text != attr.MaxKgPerHa?.ToString() ||
WineAttributeStrictInput.IsChecked != attr.IsStrict ||
WineAttributeFillLowerInput.SelectedIndex != attr.FillLower;
@@ -123,6 +130,8 @@ namespace Elwig.Windows {
attr.AttrId = id;
attr.Name = WineAttributeNameInput.Text ?? "";
attr.IsActive = WineAttributeActiveInput.IsChecked ?? false;
attr.MinQualId = (WineAttributeMinQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
attr.MaxQualId = (WineAttributeMaxQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
attr.MaxKgPerHa = WineAttributeMaxKgPerHaInput.Text.Length > 0 ? int.Parse(WineAttributeMaxKgPerHaInput.Text) : null;
attr.IsStrict = WineAttributeStrictInput.IsChecked ?? false;
attr.FillLower = WineAttributeFillLowerInput.SelectedIndex;
@@ -19,7 +19,7 @@ namespace Elwig.Windows {
private bool _cultUpdate = false;
private async Task WineCultivationsInitEditing(AppDbContext ctx) {
_cultList = new(await ctx.FetchWineCultivations().ToListAsync());
_cultList = [with(await ctx.FetchWineCultivations().ToListAsync())];
_cults = _cultList.ToDictionary(c => c.CultId, c => (string?)c.CultId);
_cultIds = _cultList.ToDictionary(c => c, c => c.CultId);
ControlUtils.RenewItemsSource(WineCultivationList, _cultList);
@@ -50,7 +50,7 @@ namespace Elwig.Windows {
.Where(_cultIds.ContainsKey)
.Select(c => {
c.CultId = _cultIds[c];
ctx.Entry(c).State = EntityState.Added;
ctx.Entry(c).State = EntityState.Modified;
return c;
}));
await ctx.SaveChangesAsync();
+22 -5
View File
@@ -24,6 +24,7 @@ namespace Elwig.Windows {
BranchIdInput, BranchNameInput, BranchPlzInput, BranchOrtInput,
BranchAddressInput, BranchPhoneNrInput, BranchFaxNrInput, BranchMobileNrInput,
WineAttributeIdInput, WineAttributeNameInput, WineAttributeActiveInput,
WineAttributeMinQualityLevelInput, WineAttributeMaxQualityLevelInput,
WineAttributeMaxKgPerHaInput, WineAttributeStrictInput, WineAttributeFillLowerInput,
WineCultivationIdInput, WineCultivationNameInput, WineCultivationDescriptionInput, WineCultivationOrganicInput,
AreaCommitmentTypeIdInput, AreaCommitmentTypeWineVariantInput, AreaCommitmentTypeWineAttributeInput,
@@ -60,6 +61,8 @@ namespace Elwig.Windows {
WineAttributeIdInput.IsReadOnly = true;
WineAttributeNameInput.IsReadOnly = true;
WineAttributeActiveInput.IsEnabled = false;
WineAttributeMinQualityLevelInput.IsEnabled = false;
WineAttributeMaxQualityLevelInput.IsEnabled = false;
WineAttributeMaxKgPerHaInput.IsReadOnly = true;
WineAttributeStrictInput.IsEnabled = false;
WineAttributeFillLowerInput.IsEnabled = false;
@@ -109,6 +112,8 @@ namespace Elwig.Windows {
WineAttributeIdInput.IsReadOnly = false;
WineAttributeNameInput.IsReadOnly = false;
WineAttributeActiveInput.IsEnabled = true;
WineAttributeMinQualityLevelInput.IsEnabled = true;
WineAttributeMaxQualityLevelInput.IsEnabled = true;
WineAttributeMaxKgPerHaInput.IsReadOnly = false;
WineAttributeStrictInput.IsEnabled = true;
WineAttributeFillLowerInput.IsEnabled = true;
@@ -145,20 +150,30 @@ namespace Elwig.Windows {
protected override async Task OnRenewContext(AppDbContext ctx) {
await base.OnRenewContext(ctx);
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
ControlUtils.RenewItemsSource(SeasonList, await ctx.FetchSeasons(includeModifiers: true).ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
var year = (SeasonList.SelectedItem as Season)?.Year;
ControlUtils.RenewItemsSource(BranchList, await ctx.FetchBranches().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.FetchWineAttributes().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
var qualList = await ctx.FetchWineQualityLevels(includePredicate: false).Cast<object>().ToListAsync();
var fullQualList = await ctx.FetchWineQualityLevels().Cast<object>().ToListAsync();
qualList.Insert(0, new NullItem("- Keine -"));
fullQualList.Insert(0, new NullItem("- Keine -"));
ControlUtils.RenewItemsSource(WineAttributeMinQualityLevelInput, fullQualList);
ControlUtils.RenewItemsSource(WineAttributeMaxQualityLevelInput, fullQualList);
ControlUtils.RenewItemsSource(ParameterReceiptMaxQualityLevelInput, qualList);
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineVariantInput, await ctx.FetchWineVarieties().ToListAsync());
var attrList = await ctx.FetchWineAttributes().Cast<object>().ToListAsync();
attrList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(AreaCommitmentTypeWineAttributeInput, attrList);
ControlUtils.RenewItemsSource(SeasonList, await ctx.FetchSeasons(includeModifiers: true).ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
var year = (SeasonList.SelectedItem as Season)?.Year;
ControlUtils.RenewItemsSource(BranchList, await ctx.FetchBranches().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineAttributeList, await ctx.FetchWineAttributes().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, await ctx.AreaCommitmentTypes
.OrderBy(t => t.VtrgId)
.ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineCultivationList, await ctx.FetchWineCultivations().ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(SeasonModifierList, await ctx.FetchModifiers(year ?? 0).ToListAsync(), null, ControlUtils.RenewSourceDefault.First);
FillInputs(App.Client, await ctx.FetchSeasons(Utils.CurrentLastSeason).SingleOrDefaultAsync());
}
protected override void UpdateButtons() {
@@ -351,6 +366,7 @@ namespace Elwig.Windows {
ParameterBusinessShareModeInput.SelectedIndex = p.ModeBusinessShares;
ParameterBusinessShareHistoryInput.IsChecked = p.EnableMemberHistory;
ControlUtils.SelectItemWithPk(ParameterReceiptMaxQualityLevelInput, p.ReceiptMaxQualId);
ParameterAllowAttrIntoLowerInput.IsChecked = s?.Billing_AllowAttrsIntoLower ?? false;
ParameterAvoidUnderDeliveriesInput.IsChecked = s?.Billing_AvoidUnderDeliveries ?? false;
ParameterHonorContractedInput.IsChecked = s?.Billing_HonorContracted ?? false;
@@ -390,6 +406,7 @@ namespace Elwig.Windows {
p.ExportEbicsVersion = ParameterExportEbicsVersion.SelectedIndex + 3;
p.ExportEbicsAddress = ParameterExportEbicsAddress.SelectedIndex;
p.ReceiptMaxQualId = (ParameterReceiptMaxQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
await p.UpdateValues();
}
+1 -1
View File
@@ -514,7 +514,7 @@
<ComboBox x:Name="AttributeInput" SelectedItem="{Binding WineAttrObj, Mode=TwoWay}" ItemsSource="{Binding WineAttrSource, Mode=TwoWay}"
Grid.Row="1" Grid.Column="1" Margin="0,40,5,10"
DisplayMemberPath="Name"
KeyUp="Input_KeyUp"/>
SelectionChanged="AttributeInput_SelectionChanged" KeyUp="Input_KeyUp"/>
<ComboBox x:Name="CultivationInput" SelectedItem="{Binding WineCultObj, Mode=TwoWay}" ItemsSource="{Binding WineCultSource, Mode=TwoWay}"
Grid.Row="1" Grid.Column="2" Margin="0,40,10,10"
DisplayMemberPath="Name"
+21 -16
View File
@@ -1313,33 +1313,44 @@ namespace Elwig.Windows {
}
}
private WineQualLevel GetWineQualityLevel(double kmw, string? maxQualId = null) {
private void AttributeInput_SelectionChanged(object sender, SelectionChangedEventArgs evt) {
UpdateWineQualityLevels();
}
private WineQualLevel? GetWineQualityLevel(double kmw, string? minQualId, string? maxQualId) {
double? min = WineQualityLevels.Where(q => q.QualId == minQualId).Min(q => q.MinKmw);
double? max = WineQualityLevels.Where(q => q.QualId == maxQualId).Max(q => q.MinKmw) ??
WineQualityLevels.Where(q => q.QualId == App.Client.ReceiptMaxQualId).Max(q => q.MinKmw);
if (kmw < min || max < min) return null;
return WineQualityLevels
.Where(q => !q.IsPredicate && (q.MinKmw == null || q.MinKmw <= kmw))
.Where(q => maxQualId == null || q.QualId == "WEI" || q.QualId == maxQualId)
.Where(q => (!q.IsPredicate || q.QualId == maxQualId) && (q.MinKmw == null || kmw >= q.MinKmw))
.Where(q => max == null || q.MinKmw == null || q.MinKmw <= max)
.OrderBy(q => q.MinKmw)
.Last();
.LastOrDefault();
}
private void UpdateWineQualityLevels() {
if (!GetInputValid(GradationKmwInput)) {
if (!GetInputValid(GradationKmwInput) || !ViewModel.GradationKmw.HasValue) {
UnsetDefaultValue(WineQualityLevelInput);
ComboBox_SelectionChanged(WineQualityLevelInput, null);
WineQualityLevelInput.ItemsSource = WineQualityLevels;
WineQualityLevelInput.SelectedItem = null;
return;
}
var kmw = (double)ViewModel.GradationKmw!;
var max = ViewModel.WineVar?.MaxQualId;
var kmw = (double)ViewModel.GradationKmw;
var minA = ViewModel.WineAttr?.MinQualId;
var maxA = ViewModel.WineAttr?.MaxQualId;
var maxV = ViewModel.WineVar?.MaxQualId;
var quw = ViewModel.WineVar?.IsQuw ?? true;
WineQualityLevelInput.ItemsSource = WineQualityLevels
.Where(q => q.MinKmw == null || q.MinKmw <= kmw)
.Where(q => quw || q.QualId == "WEI" || q.QualId == max)
.Where(q => quw || q.MinKmw == null || q.QualId == maxV)
.ToList();
var qual = GetWineQualityLevel(kmw, !quw ? max : null);
var qual = GetWineQualityLevel(kmw, minA, !quw ? maxV : maxA);
SetDefaultValue(WineQualityLevelInput, qual);
if (WineQualityLevelInput.SelectedItem == null || (WineQualityLevelInput.SelectedItem is WineQualLevel selected && !selected.IsPredicate)) {
ControlUtils.SelectItem(WineQualityLevelInput, qual);
ValidateRequiredInputs();
}
}
@@ -1504,13 +1515,7 @@ namespace Elwig.Windows {
private void UpdateAbgewertet() {
if (!GetInputValid(GradationKmwInput))
return;
var qual = WineQualityLevelInput.SelectedItem as WineQualLevel;
if (qual == null) {
AbgewertetInput.IsChecked = false;
return;
}
var defQual = GetWineQualityLevel(ViewModel.GradationKmw!.Value, !(ViewModel.WineVar?.IsQuw ?? true) ? ViewModel.WineVar?.MaxQualId : null);
AbgewertetInput.IsChecked = !qual.IsPredicate && defQual != qual;
AbgewertetInput.IsChecked = WineQualityLevelInput.SelectedItem is WineQualLevel { QualId: "WEI" };
}
private void WeightInput_TextChanged(object sender, TextChangedEventArgs evt) {
+1 -1
View File
@@ -1 +1 @@
curl --fail -s -L "https://elwig.at/files/create.sql?v=42" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
curl --fail -s -L "https://elwig.at/files/create.sql?v=43" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"