diff --git a/Elwig/Documents/MemberDataSheet.cshtml b/Elwig/Documents/MemberDataSheet.cshtml
index b8494dd..61be083 100644
--- a/Elwig/Documents/MemberDataSheet.cshtml
+++ b/Elwig/Documents/MemberDataSheet.cshtml
@@ -206,7 +206,7 @@
@areaCom.GstNr.Replace(",", ", ").Replace("-", "–") |
@($"{areaCom.Area:N0}") |
@areaCom.WineCult?.Name |
- @(areaCom.YearTo == null ? $"ab {areaCom.YearFrom}" : $"{areaCom.YearFrom}–{areaCom.YearTo}") |
+ @(areaCom.YearTo == null ? (areaCom.YearFrom == null ? "unbefristet" : $"ab {areaCom.YearFrom}") : (areaCom.YearFrom == null ? $"bis {areaCom.YearTo}" : $"{areaCom.YearFrom}–{areaCom.YearTo}")) |
lastContract = contractType.AreaComType.DisplayName;
}
diff --git a/Elwig/Helpers/AppDbUpdater.cs b/Elwig/Helpers/AppDbUpdater.cs
index a6606c6..9e2d676 100644
--- a/Elwig/Helpers/AppDbUpdater.cs
+++ b/Elwig/Helpers/AppDbUpdater.cs
@@ -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 = 29;
+ public static readonly int RequiredSchemaVersion = 30;
private static int VersionOffset = 0;
diff --git a/Elwig/Helpers/Export/ElwigData.cs b/Elwig/Helpers/Export/ElwigData.cs
index de4d7b0..0faf36a 100644
--- a/Elwig/Helpers/Export/ElwigData.cs
+++ b/Elwig/Helpers/Export/ElwigData.cs
@@ -565,7 +565,7 @@ namespace Elwig.Helpers.Export {
KgNr = kgnr,
GstNr = json["gstnr"]?.AsValue().GetValue() ?? "-",
RdNr = rd?.RdNr,
- YearFrom = json["year_from"]!.AsValue().GetValue(),
+ YearFrom = json["year_from"]?.AsValue().GetValue(),
YearTo = json["year_to"]?.AsValue().GetValue(),
Comment = json["comment"]?.AsValue().GetValue(),
}, newRd ? rd : null);
diff --git a/Elwig/Helpers/Utils.cs b/Elwig/Helpers/Utils.cs
index 6e3d339..e325fc3 100644
--- a/Elwig/Helpers/Utils.cs
+++ b/Elwig/Helpers/Utils.cs
@@ -560,7 +560,7 @@ namespace Elwig.Helpers {
public static Expression> ActiveAreaCommitments() => ActiveAreaCommitments(CurrentYear);
public static Expression> ActiveAreaCommitments(int year) =>
- c => (c.YearFrom <= year) && (c.YearTo == null || c.YearTo >= year);
+ c => (c.YearFrom == null || c.YearFrom <= year) && (c.YearTo == null || c.YearTo >= year);
public static IQueryable ActiveAreaCommitments(IQueryable query) => ActiveAreaCommitments(query, CurrentYear);
public static IQueryable ActiveAreaCommitments(IQueryable query, int year) =>
diff --git a/Elwig/Models/Entities/AreaCom.cs b/Elwig/Models/Entities/AreaCom.cs
index e238f97..4ff65e8 100644
--- a/Elwig/Models/Entities/AreaCom.cs
+++ b/Elwig/Models/Entities/AreaCom.cs
@@ -32,7 +32,7 @@ namespace Elwig.Models.Entities {
public int? RdNr { get; set; }
[Column("year_from")]
- public int YearFrom { get; set; }
+ public int? YearFrom { get; set; }
[Column("year_to")]
public int? YearTo { get; set; }
diff --git a/Elwig/Resources/Sql/29-30.sql b/Elwig/Resources/Sql/29-30.sql
new file mode 100644
index 0000000..08d2705
--- /dev/null
+++ b/Elwig/Resources/Sql/29-30.sql
@@ -0,0 +1,18 @@
+-- schema version 29 to 30
+
+PRAGMA writable_schema = ON;
+
+DROP VIEW v_bki_member;
+CREATE VIEW v_bki_member AS
+SELECT s.year, m.mgnr, m.lfbis_nr, m.name,
+ (COALESCE(m.prefix || ' ', '') || m.given_name || COALESCE(' ' || m.middle_names, '') || COALESCE(' ' || m.suffix, '')) AS other_names,
+ a.name AS billing_name, COALESCE(a.address, m.address) AS address,
+ COALESCE(a.country, m.country) AS country, COALESCE(a.postal_dest, m.postal_dest) AS postal_dest,
+ SUM(COALESCE(IIF((c.year_from IS NULL OR c.year_from <= s.year) AND (c.year_to IS NULL OR c.year_to >= s.year), c.area, NULL), 0)) AS area
+FROM season s, member m
+ LEFT JOIN member_billing_address a ON a.mgnr = m.mgnr
+ LEFT JOIN area_commitment c ON c.mgnr = m.mgnr
+GROUP BY s.year, m.mgnr;
+
+PRAGMA schema_version = 2901;
+PRAGMA writable_schema = OFF;
diff --git a/Elwig/Services/AreaComService.cs b/Elwig/Services/AreaComService.cs
index a1fd9ec..8e4b3d2 100644
--- a/Elwig/Services/AreaComService.cs
+++ b/Elwig/Services/AreaComService.cs
@@ -106,7 +106,7 @@ namespace Elwig.Services {
var a = new AreaCom {
FbNr = oldFbNr ?? newFbNr,
MgNr = (int)vm.MgNr!,
- YearFrom = (int)vm.YearFrom!,
+ YearFrom = vm.YearFrom,
YearTo = vm.YearTo,
VtrgId = vm.AreaComType!.VtrgId,
CultId = vm.WineCult?.CultId,
diff --git a/Tests/fetch-resources.bat b/Tests/fetch-resources.bat
index 4c62384..8092376 100644
--- a/Tests/fetch-resources.bat
+++ b/Tests/fetch-resources.bat
@@ -1 +1 @@
-curl --fail -s -L "https://elwig.at/files/create.sql?v=29" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
+curl --fail -s -L "https://elwig.at/files/create.sql?v=30" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"