DeliveryAdminWindow: Only show active modifiers in receipt mode
All checks were successful
Test / Run tests (push) Successful in 1m53s

This commit is contained in:
2024-07-06 18:45:15 +02:00
parent daf83c4bbc
commit 658a1f4dc1
12 changed files with 34 additions and 23 deletions

View File

@ -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 = 23;
public static readonly int RequiredSchemaVersion = 24;
private static int VersionOffset = 0;

View File

@ -13,6 +13,9 @@ namespace Elwig.Models.Entities {
[Column("modid")]
public required string ModId { get; set; }
[Column("active")]
public bool IsActive { get; set; }
[Column("ordering")]
public int Ordering { get; set; }
@ -21,7 +24,6 @@ namespace Elwig.Models.Entities {
[Column("abs")]
public long? AbsValue { get; set; }
[NotMapped]
public decimal? Abs {
get => AbsValue != null ? Season.DecFromDb(AbsValue.Value) : null;
@ -30,19 +32,12 @@ namespace Elwig.Models.Entities {
[Column("rel")]
public double? RelValue { get; set; }
[NotMapped]
public decimal? Rel {
get => (decimal?)RelValue;
set => RelValue = (double?)value;
}
[Column("standard")]
public bool IsStandard { get; set; }
[Column("quick_select")]
public bool IsQuickSelect { get; set; }
[ForeignKey("Year")]
public virtual Season Season { get; private set; } = null!;

View File

@ -1,4 +1,4 @@
-- schema version 20 to 21
-- schema version 21 to 22
CREATE VIEW v_penalty_business_shares AS
SELECT u.year, u.mgnr,

View File

@ -1,4 +1,4 @@
-- schema version 20 to 21
-- schema version 22 to 23
CREATE VIEW v_stat_modifier AS
SELECT v.year, v.avnr, m.modid, m.name, m.abs, m.rel,

View File

@ -0,0 +1,5 @@
-- schema version 23 to 24
ALTER TABLE modifier DROP COLUMN standard;
ALTER TABLE modifier DROP COLUMN quick_select;
ALTER TABLE modifier ADD COLUMN active INTEGER NOT NULL CHECK (active IN (TRUE, FALSE)) DEFAULT TRUE;

View File

@ -521,6 +521,10 @@
<Label Content="Absolut:" Grid.Column="1" Margin="10,100,10,10"/>
<ctrl:UnitTextBox x:Name="SeasonModifierAbsInput" Unit="€/kg" TextChanged="SeasonModifierAbsInput_TextChanged"
Grid.Column="2" Width="86" Margin="0,100,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<CheckBox x:Name="SeasonModifierActiveInput" Content="In Übernahme-Fenster anzeigen"
Grid.Column="1" Grid.ColumnSpan="2" Margin="10,134,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
Checked="SeasonModifier_Changed" Unchecked="SeasonModifier_Changed"/>
</Grid>
</GroupBox>
</Grid>

View File

@ -134,11 +134,13 @@ namespace Elwig.Windows {
SeasonModifierNameInput.Text = "";
SeasonModifierRelInput.Text = "";
SeasonModifierAbsInput.Text = "";
SeasonModifierActiveInput.IsChecked = false;
} else {
SeasonModifierIdInput.Text = mod.ModId;
SeasonModifierNameInput.Text = mod.Name;
SeasonModifierRelInput.Text = (mod.Rel * 100)?.ToString() ?? "";
SeasonModifierAbsInput.Text = mod.Abs?.ToString() ?? "";
SeasonModifierActiveInput.IsChecked = mod.IsActive;
}
_modUpdate = false;
}
@ -154,6 +156,7 @@ namespace Elwig.Windows {
mod.Name = SeasonModifierNameInput.Text;
mod.Rel = decimal.TryParse(SeasonModifierRelInput.Text, out var vRel) ? vRel / 100 : null;
mod.AbsValue = decimal.TryParse(SeasonModifierAbsInput.Text, out var vAbs) ? Utils.DecToDb(vAbs, s.Precision) : null;
mod.IsActive = SeasonModifierActiveInput.IsChecked ?? false;
CollectionViewSource.GetDefaultView(_modList).Refresh();
UpdateButtons();

View File

@ -187,8 +187,7 @@ namespace Elwig.Windows {
Name = m.Name,
AbsValue = m.AbsValue * mult / div,
RelValue = m.RelValue,
IsStandard = m.IsStandard,
IsQuickSelect = m.IsQuickSelect,
IsActive = m.IsActive,
}));
}
await ctx.SaveChangesAsync();

View File

@ -1084,7 +1084,7 @@ namespace Elwig.Windows {
ControlUtils.RenewItemsSource(CultivationInput, cultList, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(WineQualityLevelInput, await ctx.WineQualityLevels.ToListAsync());
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
.Where(m => m.Year == y)
.Where(m => m.Year == y && (!IsCreating || m.IsActive))
.OrderBy(m => m.Ordering)
.Include(m => m.Season.Currency)
.ToListAsync());
@ -1116,14 +1116,14 @@ namespace Elwig.Windows {
using var ctx = new AppDbContext();
if (DeliveryList.SelectedItem is Delivery d) {
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
.Where(m => m.Year == d.Year)
.Where(m => m.Year == d.Year && (!IsCreating || m.IsActive))
.OrderBy(m => m.Ordering)
.Include(m => m.Season.Currency)
.ToListAsync());
ControlUtils.RenewItemsSource(DeliveryPartList, d.FilteredParts.OrderBy(p => p.DPNr).ToList(), DeliveryPartList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
} else {
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
.Where(m => m.Year == SeasonInput.Value)
.Where(m => m.Year == SeasonInput.Value && (!IsCreating || m.IsActive))
.OrderBy(m => m.Ordering)
.Include(m => m.Season.Currency)
.ToListAsync());
@ -1555,6 +1555,11 @@ namespace Elwig.Windows {
var attrList = await ctx.WineAttributes.Where(a => a.IsActive).OrderBy(a => a.Name).Cast<object>().ToListAsync();
attrList.Insert(0, new NullItem(""));
ControlUtils.RenewItemsSource(AttributeInput, attrList, null, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(ModifiersInput, await ctx.Modifiers
.Where(m => m.Year == SeasonInput.Value && m.IsActive)
.OrderBy(m => m.Ordering)
.Include(m => m.Season.Currency)
.ToListAsync());
ControlUtils.RenewItemsSource(MemberInput, await ctx.Members
.Where(m => m.IsActive || !IsReceipt)
.Include(m => m.PostalDest.AtPlz!.Ort)

View File

@ -31,9 +31,9 @@ INSERT INTO season (year, currency, min_kg_per_bs, max_kg_per_bs, penalty_per_kg
(2020, 'EUR', 1000, 2000, NULL, NULL, NULL, NULL, NULL),
(2021, 'EUR', 2000, 4000, NULL, NULL, NULL, NULL, NULL);
INSERT INTO modifier (year, modid, ordering, name, abs, rel, standard, quick_select) VALUES
(2020, 'S', 0, 'Geschädigte Trauben', NULL, -0.1, FALSE, FALSE),
(2020, 'A', 0, 'Keine Voranmeldung', -1000, NULL, FALSE, FALSE);
INSERT INTO modifier (year, modid, ordering, name, abs, rel, active) VALUES
(2020, 'S', 0, 'Geschädigte Trauben', NULL, -0.1, TRUE),
(2020, 'A', 0, 'Keine Voranmeldung', -1000, NULL, TRUE);
-- Test 01
INSERT INTO delivery (mgnr, year, did, date, time, zwstid, lnr) VALUES

View File

@ -9,9 +9,9 @@ INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lo
INSERT INTO season (year, currency, min_kg_per_bs, max_kg_per_bs, penalty_per_kg, penalty_amount, penalty_none, start_date, end_date) VALUES
(2020, 'EUR', 1000, 2000, NULL, NULL, NULL, NULL, NULL);
INSERT INTO modifier (year, modid, ordering, name, abs, rel, standard, quick_select) VALUES
(2020, 'S', 0, 'Geschädigte Trauben', NULL, -0.1, FALSE, FALSE),
(2020, 'A', 0, 'Keine Voranmeldung', -1000, NULL, FALSE, FALSE);
INSERT INTO modifier (year, modid, ordering, name, abs, rel, active) VALUES
(2020, 'S', 0, 'Geschädigte Trauben', NULL, -0.1, TRUE),
(2020, 'A', 0, 'Keine Voranmeldung', -1000, NULL, TRUE);
INSERT INTO delivery (mgnr, year, did, date, time, zwstid, lnr) VALUES
(101, 2020, 1, '2020-10-01', '09:03:12', 'X', 1),

View File

@ -1 +1 @@
curl --fail -s -L "https://elwig.at/files/create.sql?v=23" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
curl --fail -s -L "https://elwig.at/files/create.sql?v=24" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"