[#14] Documents: Add DeliveryAncmtList
All checks were successful
Test / Run tests (push) Successful in 2m35s

This commit is contained in:
2024-08-10 15:44:40 +02:00
parent b091bd0ec3
commit 025ff08d84
12 changed files with 303 additions and 2 deletions

View File

@ -0,0 +1,30 @@
using Elwig.Documents;
using Elwig.Helpers;
using Elwig.Models.Dtos;
namespace Tests.DocumentTests {
[TestFixture]
public class DeliveryAncmtListTest {
[Test]
public async Task Test_01_AllAnnouncements2020() {
using var ctx = new AppDbContext();
var filter = "01.10.2020 Matzen GV Kabinettaktion";
var data = await DeliveryAncmtListData.FromQuery(ctx.DeliveryAnnouncements.Where(a => a.Year == 2020 && a.DsNr == 1), [filter]);
using var doc = new DeliveryAncmtList(filter, data);
var text = await Utils.GeneratePdfText(doc, true);
var table = Utils.ExtractTable(text);
Assert.Multiple(() => {
Assert.That(text, Contains.Substring("Anmeldeliste"));
Assert.That(text, Contains.Substring("01.10.2020 Matzen GV Kabinettaktion"));
Assert.That(table, Is.EqualTo(new string[][] {
["01.10.2020", "101 MUSTERMANN Max", "Grüner Veltliner", "5 000"],
["01.10.2020", "102 WEINBAUER Wernhardt", "Grüner Veltliner", "10 000"],
["01.10.2020", "103 MUSTERBAUER Matthäus", "Grüner Veltliner", "8 000"],
["01.10.2020", "104 WINZER Waltraud", "Grüner Veltliner", "2 000"],
["Gesamt:", "Anmeldungen: 4", "25 000"],
}));
});
}
}
}

View File

@ -21,7 +21,7 @@ namespace Tests.DocumentTests {
public static string[][] ExtractTable(string text) {
return text.Split('\n')
.Select(row => Regex.Split(row, @"\s{2,}").Select(c => c.Trim()).Where(c => c.Length > 0).ToArray())
.Where(row => row.Length > 3)
.Where(row => row.Length >= 3)
.Skip(1)
.ToArray();
}

View File

@ -1,5 +1,6 @@
-- deletes for DocumentTests
DELETE FROM delivery_schedule;
DELETE FROM payment_variant;
DELETE FROM delivery;
DELETE FROM season;

View File

@ -9,6 +9,18 @@ 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 delivery_schedule (year, dsnr, date, zwstid, description, max_weight, ancmt_from, ancmt_to) VALUES
(2020, 1, '2020-10-01', 'X', 'GV Kabinettaktion', 100000, NULL, NULL);
INSERT INTO delivery_schedule_wine_variety (year, dsnr, sortid, priority) VALUES
(2020, 1, 'GV', 1);
INSERT INTO delivery_announcement (year, dsnr, mgnr, sortid, weight, type) VALUES
(2020, 1, 101, 'GV', 5000, 'manual'),
(2020, 1, 102, 'GV', 10000, 'manual'),
(2020, 1, 103, 'GV', 8000, 'manual'),
(2020, 1, 104, 'GV', 2000, 'manual');
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);