diff --git a/Elwig/Documents/DeliveryNote.cs b/Elwig/Documents/DeliveryNote.cs
index d6157c8..34644a7 100644
--- a/Elwig/Documents/DeliveryNote.cs
+++ b/Elwig/Documents/DeliveryNote.cs
@@ -153,6 +153,9 @@ namespace Elwig.Documents {
if (part.Cultivation != null) {
var cult = new KernedParagraph(8);
cult.Add(Italic("Bewirtschaftung:")).Add(Normal(" " + part.Cultivation.Name + (part.Cultivation.Description != null ? $" ({part.Cultivation.Description})" : "")));
+ if (part.Cultivation.IsOrganic) {
+ cult.Add(" \u2013 ").Add(Italic("Kontrollstelle:")).Add(Normal($" {Member.OrganicAuthorityCode ?? "?"}"));
+ }
sub.AddCell(NewTd())
.AddCell(NewTd(cult, colspan: 5))
.AddCell(NewTd(colspan: 3));
diff --git a/Elwig/Models/Entities/WineCult.cs b/Elwig/Models/Entities/WineCult.cs
index 62f5f4e..3feb5b1 100644
--- a/Elwig/Models/Entities/WineCult.cs
+++ b/Elwig/Models/Entities/WineCult.cs
@@ -11,6 +11,9 @@ namespace Elwig.Models.Entities {
[Column("name")]
public required string Name { get; set; }
+ [Column("organic")]
+ public bool IsOrganic { get; set; }
+
[Column("description")]
public string? Description { get; set; }
diff --git a/Elwig/Resources/Sql/41-42.sql b/Elwig/Resources/Sql/41-42.sql
index 710e01e..9575535 100644
--- a/Elwig/Resources/Sql/41-42.sql
+++ b/Elwig/Resources/Sql/41-42.sql
@@ -3,6 +3,12 @@
ALTER TABLE member ADD COLUMN ooc_id TEXT CHECK (ooc_id REGEXP '^[0-9]{3}-[0-9]{7}$') DEFAULT NULL;
ALTER TABLE member ADD COLUMN org_auth_code TEXT CHECK (org_auth_code REGEXP '^[A-Z]{2}-[A-ZÖØ]{3}-[0-9]{2,3}(-[A-Z]{2})?$') DEFAULT NULL;
+ALTER TABLE wine_cultivation ADD COLUMN organic INTEGER NOT NULL CHECK (organic IN (TRUE, FALSE)) DEFAULT FALSE;
+
UPDATE member SET org_auth_code = UPPER(SUBSTR(a.name, -11, 10)) FROM member m JOIN member_billing_address a ON a.mgnr = m.mgnr WHERE a.name LIKE '%AT-BIO-___)';
UPDATE member SET org_auth_code = UPPER(SUBSTR(a.name, -10, 10)) FROM member m JOIN member_billing_address a ON a.mgnr = m.mgnr WHERE a.name LIKE '%AT-BIO-___';
UPDATE member SET org_auth_code = UPPER(suffix) WHERE suffix LIKE 'AT-BIO-___';
+
+UPDATE wine_cultivation SET organic = TRUE WHERE name LIKE '%bio%' OR name LIKE '%org%' OR description LIKE '%AT-BIO-%';
+UPDATE wine_cultivation SET description = NULL WHERE description LIKE '%AT-BIO-%';
+UPDATE wine_cultivation SET description = 'Biologische Produktion' WHERE organic;
diff --git a/Elwig/Windows/BaseDataWindow.xaml b/Elwig/Windows/BaseDataWindow.xaml
index 8c6d87d..921a85d 100644
--- a/Elwig/Windows/BaseDataWindow.xaml
+++ b/Elwig/Windows/BaseDataWindow.xaml
@@ -320,6 +320,10 @@
+
+
diff --git a/Elwig/Windows/BaseDataWindow.xaml.WineCult.cs b/Elwig/Windows/BaseDataWindow.xaml.WineCult.cs
index d724cd9..84d51d0 100644
--- a/Elwig/Windows/BaseDataWindow.xaml.WineCult.cs
+++ b/Elwig/Windows/BaseDataWindow.xaml.WineCult.cs
@@ -72,10 +72,12 @@ namespace Elwig.Windows {
WineCultivationIdInput.Text = "";
WineCultivationNameInput.Text = "";
WineCultivationDescriptionInput.Text = "";
+ WineCultivationOrganicInput.IsChecked = false;
} else {
WineCultivationIdInput.Text = cult.CultId;
WineCultivationNameInput.Text = cult.Name;
WineCultivationDescriptionInput.Text = cult.Description;
+ WineCultivationOrganicInput.IsChecked = cult.IsOrganic;
}
_cultUpdate = false;
}
@@ -105,7 +107,8 @@ namespace Elwig.Windows {
_cultChanged = _cultChanged ||
WineCultivationIdInput.Text != cult.CultId ||
WineCultivationNameInput.Text != cult.Name ||
- WineCultivationDescriptionInput.Text != (cult.Description ?? "");
+ WineCultivationDescriptionInput.Text != (cult.Description ?? "") ||
+ WineCultivationOrganicInput.IsChecked != cult.IsOrganic;
var old = _cultIds.GetValueOrDefault(cult);
var id = WineCultivationIdInput.Text ?? "";
@@ -113,7 +116,8 @@ namespace Elwig.Windows {
cult.CultId = id;
cult.Name = WineCultivationNameInput.Text ?? "";
cult.Description = WineCultivationDescriptionInput.Text ?? "";
- if (cult.Description.Length == 0) cult.Description = null;
+ cult.IsOrganic = WineCultivationOrganicInput.IsChecked ?? false;
+ if (string.IsNullOrWhiteSpace(cult.Description)) cult.Description = null;
CollectionViewSource.GetDefaultView(_cultList).Refresh();
UpdateButtons();
diff --git a/Elwig/Windows/BaseDataWindow.xaml.cs b/Elwig/Windows/BaseDataWindow.xaml.cs
index 75a295a..7ce9d2c 100644
--- a/Elwig/Windows/BaseDataWindow.xaml.cs
+++ b/Elwig/Windows/BaseDataWindow.xaml.cs
@@ -25,7 +25,7 @@ namespace Elwig.Windows {
BranchAddressInput, BranchPhoneNrInput, BranchFaxNrInput, BranchMobileNrInput,
WineAttributeIdInput, WineAttributeNameInput, WineAttributeActiveInput,
WineAttributeMaxKgPerHaInput, WineAttributeStrictInput, WineAttributeFillLowerInput,
- WineCultivationIdInput, WineCultivationNameInput, WineCultivationDescriptionInput,
+ WineCultivationIdInput, WineCultivationNameInput, WineCultivationDescriptionInput, WineCultivationOrganicInput,
AreaCommitmentTypeIdInput, AreaCommitmentTypeWineVariantInput, AreaCommitmentTypeWineAttributeInput,
AreaCommitmentTypeMinKgPerHaInput, AreaCommitmentTypePenaltyPerKgInput,
AreaCommitmentTypePenaltyInput, AreaCommitmentTypePenaltyNoneInput,
@@ -67,6 +67,7 @@ namespace Elwig.Windows {
WineCultivationIdInput.IsReadOnly = true;
WineCultivationNameInput.IsReadOnly = true;
WineCultivationDescriptionInput.IsReadOnly = true;
+ WineCultivationOrganicInput.IsEnabled = false;
AreaCommitmentTypeWineVariantInput.IsEnabled = false;
AreaCommitmentTypeWineAttributeInput.IsEnabled = false;
@@ -115,6 +116,7 @@ namespace Elwig.Windows {
WineCultivationIdInput.IsReadOnly = false;
WineCultivationNameInput.IsReadOnly = false;
WineCultivationDescriptionInput.IsReadOnly = false;
+ WineCultivationOrganicInput.IsEnabled = true;
AreaCommitmentTypeWineVariantInput.IsEnabled = true;
AreaCommitmentTypeWineAttributeInput.IsEnabled = true;
diff --git a/Tests/E2ETests/MemberAdminWindowTest.cs b/Tests/E2ETests/MemberAdminWindowTest.cs
index 52fd655..7a4fb5b 100644
--- a/Tests/E2ETests/MemberAdminWindowTest.cs
+++ b/Tests/E2ETests/MemberAdminWindowTest.cs
@@ -84,12 +84,12 @@ namespace Tests.E2ETests {
Window.FindElement(By.WpfId("SearchInput")).SendKeys("9999");
Thread.Sleep(500);
var memberListRow = Window.FindElement(By.WpfId("MemberList")).FindElement(By.ClassName("DataGridRow"));
- Assert.Multiple(() => {
+ using (Assert.EnterMultipleScope()) {
Assert.That(memberListRow, Is.Not.Null);
Assert.That(memberListRow.FindElement(By.Name("9999 ")), Is.Not.Null);
Assert.That(memberListRow.FindElement(By.Name("Norbert")), Is.Not.Null);
Assert.That(memberListRow.FindElement(By.Name("Neuling")), Is.Not.Null);
- });
+ }
}
[Test]
@@ -128,12 +128,12 @@ namespace Tests.E2ETests {
Assert.That(memberListRows, Has.Count.EqualTo(1));
var memberListRow = memberListRows.First();
- Assert.Multiple(() => {
+ using (Assert.EnterMultipleScope()) {
Assert.That(memberListRow, Is.Not.Null);
Assert.That(memberListRow.FindElement(By.Name("9999 ")), Is.Not.Null);
Assert.That(memberListRow.FindElement(By.Name("Norbert")), Is.Not.Null);
Assert.That(memberListRow.FindElement(By.Name("Neuling")), Is.Not.Null);
- });
+ }
Window.FindElement(By.WpfId("DeleteMemberButton")).Click();
var dialog = Session.CreateWindowDriver("DeleteMemberDialog");
diff --git a/Tests/Resources/Sql/BillingInsert.sql b/Tests/Resources/Sql/BillingInsert.sql
index f9a6190..928b761 100644
--- a/Tests/Resources/Sql/BillingInsert.sql
+++ b/Tests/Resources/Sql/BillingInsert.sql
@@ -1,8 +1,8 @@
-- inserts for HelperTests.BillingTest
-INSERT INTO wine_cultivation (cultid, name, description) VALUES
-('KIP', 'KIP', 'Kontrollierte Integrierte Produktion'),
-('B', 'Bio', 'AT-BIO-302');
+INSERT INTO wine_cultivation (cultid, name, description, organic) VALUES
+('KIP', 'KIP', 'Kontrollierte Integrierte Produktion', FALSE),
+('B', 'Bio', 'Biologische Produktion', TRUE);
INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES
('K', 'Kabinett', TRUE, NULL, FALSE, 0),
diff --git a/Tests/Resources/Sql/DocumentInsert.sql b/Tests/Resources/Sql/DocumentInsert.sql
index 76afff4..c3ec10a 100644
--- a/Tests/Resources/Sql/DocumentInsert.sql
+++ b/Tests/Resources/Sql/DocumentInsert.sql
@@ -1,7 +1,7 @@
-- inserts for DocumentTests
-INSERT INTO wine_cultivation (cultid, name, description) VALUES
-('B', 'Bio', 'AT-BIO-302');
+INSERT INTO wine_cultivation (cultid, name, description, organic) VALUES
+('B', 'Bio', 'Biologische Produktion', TRUE);
INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES
('K', 'Kabinett', TRUE, NULL, FALSE, 0);
diff --git a/Tests/Resources/Sql/E2EInsert.sql b/Tests/Resources/Sql/E2EInsert.sql
index 7b716ae..c2d5ff5 100644
--- a/Tests/Resources/Sql/E2EInsert.sql
+++ b/Tests/Resources/Sql/E2EInsert.sql
@@ -1,8 +1,8 @@
-- inserts for E2ETests
-INSERT INTO wine_cultivation (cultid, name, description) VALUES
-('KIP', 'KIP', 'Kontrollierte Integrierte Produktion'),
-('B', 'Bio', 'AT-BIO-302');
+INSERT INTO wine_cultivation (cultid, name, description, organic) VALUES
+('KIP', 'KIP', 'Kontrollierte Integrierte Produktion', FALSE),
+('B', 'Bio', 'Biologische Produktion', TRUE);
INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES
('K', 'Kabinett', TRUE, NULL, FALSE, 0),
diff --git a/Tests/Resources/Sql/Insert.sql b/Tests/Resources/Sql/Insert.sql
index 792b7b8..119a05f 100644
--- a/Tests/Resources/Sql/Insert.sql
+++ b/Tests/Resources/Sql/Insert.sql
@@ -66,11 +66,11 @@ INSERT INTO wb_kg (kgnr, glnr) VALUES
(15216, 2),
(15224, 2);
-INSERT INTO member (mgnr, given_name, name, zwstid, volllieferant, buchführend, country, postal_dest, address, default_kgnr, iban, lfbis_nr, ustid_nr) VALUES
-(101, 'Max', 'Mustermann', 'X', FALSE, FALSE, 40, 222303524, 'Winzerstraße 1', 06109, 'AT811234567890123457', '0123463', NULL ),
-(102, 'Wernhardt', 'Weinbauer', 'X', FALSE, FALSE, 40, 222303524, 'Winzerstraße 2', 06109, 'AT541234567890123458', '0123471', 'ATU12345684'),
-(103, 'Matthäus', 'Musterbauer', 'X', FALSE, FALSE, 40, 212005138, 'Brünner Straße 10', 15224, 'AT271234567890123459', '0123480', NULL ),
-(104, 'Waltraud', 'Winzer', 'X', FALSE, TRUE , 40, 212005138, 'Wiener Straße 15', 15224, 'AT971234567890123460', '0123498', 'ATU12345693');
+INSERT INTO member (mgnr, given_name, name, zwstid, volllieferant, buchführend, country, postal_dest, address, default_kgnr, iban, lfbis_nr, ustid_nr, org_auth_code) VALUES
+(101, 'Max', 'Mustermann', 'X', FALSE, FALSE, 40, 222303524, 'Winzerstraße 1', 06109, 'AT811234567890123457', '0123463', NULL , NULL ),
+(102, 'Wernhardt', 'Weinbauer', 'X', FALSE, FALSE, 40, 222303524, 'Winzerstraße 2', 06109, 'AT541234567890123458', '0123471', 'ATU12345684', NULL ),
+(103, 'Matthäus', 'Musterbauer', 'X', FALSE, FALSE, 40, 212005138, 'Brünner Straße 10', 15224, 'AT271234567890123459', '0123480', NULL , 'AT-BIO-302'),
+(104, 'Waltraud', 'Winzer', 'X', FALSE, TRUE , 40, 212005138, 'Wiener Straße 15', 15224, 'AT971234567890123460', '0123498', 'ATU12345693', NULL );
INSERT INTO member_billing_address (mgnr, name, country, postal_dest, address) VALUES
(102, 'W&B Weinbauer GesbR', 40, 222303524, 'Winzerstraße 2'),
diff --git a/Tests/Resources/Sql/ServiceInsert.sql b/Tests/Resources/Sql/ServiceInsert.sql
index bc14b00..ad9b9e9 100644
--- a/Tests/Resources/Sql/ServiceInsert.sql
+++ b/Tests/Resources/Sql/ServiceInsert.sql
@@ -1,8 +1,7 @@
-- inserts for ServiceTests
-
-INSERT INTO wine_cultivation (cultid, name, description) VALUES
-('B', 'Bio', 'AT-BIO-302');
+INSERT INTO wine_cultivation (cultid, name, description, organic) VALUES
+('B', 'Bio', 'Biologische Produktion', TRUE);
INSERT INTO wine_attribute (attrid, name, active, max_kg_per_ha, strict, fill_lower) VALUES
('K', 'Kabinett', TRUE, NULL, FALSE, 0);
diff --git a/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs b/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs
index 98ab9d2..4ee68d1 100644
--- a/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs
+++ b/Tests/UnitTests/DocumentTests/DeliveryNoteTest.cs
@@ -8,7 +8,7 @@ namespace Tests.UnitTests.DocumentTests {
public async Task Test_01_OneDeliveryPart() {
using var doc = await DeliveryNote.Initialize(2020, 1);
var text = await Utils.GeneratePdfText(doc);
- Assert.Multiple(() => {
+ using (Assert.EnterMultipleScope()) {
Assert.That(text, Contains.Substring("""
MUSTERMANN Max
Winzerstraße 1
@@ -26,14 +26,14 @@ namespace Tests.UnitTests.DocumentTests {
Waage/Terminal: ?/1, ID: 321 – 09:02, 01.10.2020
Brutto: 3 219 kg – Tara: 0 kg – Netto: 3 219 kg – gerebelt gewogen
"""));
- });
+ }
}
[Test]
public async Task Test_02_TwoDeliveryParts() {
using var doc = await DeliveryNote.Initialize(2020, 4);
var text = await Utils.GeneratePdfText(doc);
- Assert.Multiple(() => {
+ using (Assert.EnterMultipleScope()) {
Assert.That(text, Contains.Substring("""
W&B Weinbauer GesbR
WEINBAUER Wernhardt
@@ -58,14 +58,14 @@ namespace Tests.UnitTests.DocumentTests {
Waage/Terminal: ?/?, ID: ? (gerebelt gewogen)
"""));
Assert.That(text, Contains.Substring("Gesamt: 81 16,5 4 483"));
- });
+ }
}
[Test]
public async Task Test_03_DeliveryPartsWithAttribute() {
using var doc = await DeliveryNote.Initialize(2020, 3);
var text = await Utils.GeneratePdfText(doc);
- Assert.Multiple(() => {
+ using (Assert.EnterMultipleScope()) {
Assert.That(text, Contains.Substring("""
MUSTERMANN Max
Winzerstraße 1
@@ -95,14 +95,14 @@ namespace Tests.UnitTests.DocumentTests {
Waage/Terminal: ?/?, ID: ? (gerebelt gewogen)
"""));
Assert.That(text, Contains.Substring("Gesamt: 81 16,5 6 970"));
- });
+ }
}
[Test]
public async Task Test_04_DeliveryPartsWithCultivation() {
using var doc = await DeliveryNote.Initialize(2020, 7);
var text = await Utils.GeneratePdfText(doc);
- Assert.Multiple(() => {
+ using (Assert.EnterMultipleScope()) {
Assert.That(text, Contains.Substring("""
MUSTERBAUER Matthäus
Brünner Straße 10
@@ -115,20 +115,20 @@ namespace Tests.UnitTests.DocumentTests {
Assert.That(text, Contains.Substring("Das Mitglied erklärt, dass die gelieferte Ware dem österreichischen Weingesetz entspricht"));
Assert.That(text, Contains.Substring("""
1 Grüner Veltliner Wein 80 16,3 3 198
- Bewirtschaftung: Bio (AT-BIO-302)
+ Bewirtschaftung: Bio (Biologische Produktion) – Kontrollstelle: AT-BIO-302
Herkunft: Österreich
/ Wolkersdorfer Hochleithen / Wolkersdorf im Weinviertel / KG Wolkersdorf
Waage/Terminal: ?/?, ID: ? (gerebelt gewogen)
"""));
Assert.That(text, Contains.Substring("""
2 Grüner Veltliner Qualitätswein 75 15,4 2 134
- Bewirtschaftung: Bio (AT-BIO-302)
+ Bewirtschaftung: Bio (Biologische Produktion) – Kontrollstelle: AT-BIO-302
Herkunft: Österreich / Weinland / Niederösterreich
/ Wolkersdorfer Hochleithen / Wolkersdorf im Weinviertel / KG Wolkersdorf
Waage/Terminal: ?/?, ID: ? (gerebelt gewogen)
"""));
Assert.That(text, Contains.Substring("Gesamt: 78 15,9 5 332"));
- });
+ }
}
[Test]