MemberDataSheet: Show area com buckets of current year (regardless of season)
This commit is contained in:
@ -15,7 +15,7 @@ namespace Elwig.Documents {
|
||||
public MemberDataSheet(Member m, AppDbContext ctx) : base($"{Name} {m.AdministrativeName}", m) {
|
||||
DocumentId = $"{Name} {m.MgNr}";
|
||||
Season = ctx.Seasons.ToList().MaxBy(s => s.Year) ?? throw new ArgumentException("invalid season");
|
||||
MemberBuckets = ctx.GetMemberBuckets(Season.Year, m.MgNr).GetAwaiter().GetResult();
|
||||
MemberBuckets = ctx.GetMemberBuckets(Utils.CurrentYear, m.MgNr).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 = 16;
|
||||
public static readonly int RequiredSchemaVersion = 17;
|
||||
|
||||
private static int VersionOffset = 0;
|
||||
|
||||
|
12
Elwig/Resources/Sql/16-17.sql
Normal file
12
Elwig/Resources/Sql/16-17.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- schema version 16 to 17
|
||||
|
||||
CREATE VIEW v_virtual_season AS
|
||||
SELECT year, max_kg_per_ha
|
||||
FROM season
|
||||
UNION
|
||||
SELECT strftime('%Y', date()) + 0, (SELECT max_kg_per_ha FROM season ORDER BY year DESC LIMIT 1);
|
||||
|
||||
PRAGMA writable_schema = ON;
|
||||
UPDATE sqlite_schema SET sql = REPLACE(sql, 'season s', 'v_virtual_season s')
|
||||
WHERE type = 'view' AND name = 'v_area_commitment_bucket_strict';
|
||||
PRAGMA writable_schema = OFF;
|
@ -16,21 +16,21 @@ namespace Elwig.Windows {
|
||||
public int MgNr => Member.MgNr;
|
||||
|
||||
private readonly Member Member;
|
||||
private List<string> TextFilter = new();
|
||||
private List<string> TextFilter = [];
|
||||
|
||||
public AreaComAdminWindow(int mgnr) {
|
||||
InitializeComponent();
|
||||
Member = Context.Members.Find(mgnr) ?? throw new ArgumentException("MgNr argument has invalid value");
|
||||
Title = $"Flächenbindungen - {Member.AdministrativeName} - Elwig";
|
||||
ExemptInputs = new Control[] {
|
||||
ExemptInputs = [
|
||||
MgNrInput, AreaCommitmentList, NewAreaCommitmentButton,
|
||||
EditAreaCommitmentButton, DeleteAreaCommitmentButton, AreaCommitmentSaveButton,
|
||||
AreaCommitmentResetButton, AreaCommitmentCancelButton, SearchInput, ActiveAreaCommitmentInput
|
||||
};
|
||||
RequiredInputs = new Control[] {
|
||||
];
|
||||
RequiredInputs = [
|
||||
FbNrInput, YearFromInput, KgInput, RdInput,
|
||||
GstNrInput, AreaInput.TextBox, AreaComTypeInput, WineCultivationInput
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
@ -76,10 +76,10 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
private async Task<(List<string>, IQueryable<AreaCom>, List<string>)> GetFilters() {
|
||||
List<string> filterNames = new();
|
||||
List<string> filterNames = [];
|
||||
IQueryable<AreaCom> areaComQuery = Context.AreaCommitments.Where(a => a.MgNr == Member.MgNr).OrderBy(a => a.FbNr);
|
||||
if (ActiveAreaCommitmentInput.IsChecked == true) {
|
||||
areaComQuery = areaComQuery.Where(a => (a.YearFrom <= Utils.CurrentNextSeason) && (a.YearTo == null || a.YearTo >= Utils.CurrentNextSeason));
|
||||
areaComQuery = areaComQuery.Where(a => (a.YearFrom <= Utils.CurrentYear) && (a.YearTo == null || a.YearTo >= Utils.CurrentYear));
|
||||
filterNames.Add("aktiv");
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ namespace Elwig.Windows {
|
||||
YearToInput.Text = a.YearTo.ToString();
|
||||
|
||||
KgInput.SelectedItem = a.Kg.AtKg;
|
||||
RdInput.SelectedItem = a.Rd;
|
||||
RdInput.SelectedItem = a.Rd ?? RdInput.Items[0];
|
||||
GstNrInput.Text = a.GstNr;
|
||||
AreaInput.Text = a.Area.ToString();
|
||||
|
||||
@ -230,8 +230,8 @@ namespace Elwig.Windows {
|
||||
a.RdNr = RdInput.SelectedItem.GetType() == typeof(NullItem) ? null : ((WbRd)RdInput.SelectedItem).RdNr;
|
||||
a.GstNr = GstNrInput.Text;
|
||||
a.Area = int.Parse(AreaInput.Text);
|
||||
a.VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)?.VtrgId;
|
||||
a.CultId = (WineCultivationInput.SelectedItem as WineCult)?.CultId;
|
||||
a.VtrgId = (AreaComTypeInput.SelectedItem as AreaComType)!.VtrgId;
|
||||
a.CultId = (WineCultivationInput.SelectedItem as WineCult)!.CultId;
|
||||
a.Comment = (CommentInput.Text == "") ? null : CommentInput.Text;
|
||||
|
||||
EntityEntry<AreaCom>? tr = null;
|
||||
@ -275,7 +275,7 @@ namespace Elwig.Windows {
|
||||
MessageBox.Show(str, "Flächenbindung aktualisieren", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
|
||||
return a;
|
||||
return a!;
|
||||
}
|
||||
|
||||
private async void AreaCommitmentSaveButton_Click(object sender, RoutedEventArgs evt) {
|
||||
|
@ -1 +1 @@
|
||||
curl -s -L "https://www.necronda.net/elwig/files/create.sql?v=16" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
|
||||
curl -s -L "https://www.necronda.net/elwig/files/create.sql?v=17" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
|
||||
|
Reference in New Issue
Block a user