Compare commits

...

2 Commits

Author SHA1 Message Date
543185d48e DeliveryAdminWindow: Add weight filter
All checks were successful
Test / Run tests (push) Successful in 2m58s
2024-09-02 23:28:55 +02:00
141086673f DeliveryAncmtList: Add status to indicate late ancmts 2024-09-02 23:10:37 +02:00
7 changed files with 49 additions and 9 deletions

View File

@@ -10,8 +10,9 @@
<colgroup> <colgroup>
<col style="width: 18mm;"/> <col style="width: 18mm;"/>
<col style="width: 12mm;"/> <col style="width: 12mm;"/>
<col style="width: 81mm;"/> <col style="width: 70mm;"/>
<col style="width: 40mm;"/> <col style="width: 40mm;"/>
<col style="width: 11mm;"/>
<col style="width: 14mm;"/> <col style="width: 14mm;"/>
</colgroup> </colgroup>
<thead> <thead>
@@ -20,6 +21,7 @@
<th rowspan="2">MgNr.</th> <th rowspan="2">MgNr.</th>
<th rowspan="2" style="text-align: left;">Mitglied</th> <th rowspan="2" style="text-align: left;">Mitglied</th>
<th rowspan="2" style="text-align: left;">Sorte</th> <th rowspan="2" style="text-align: left;">Sorte</th>
<th rowspan="2">Anmldg.</th>
<th>Gewicht</th> <th>Gewicht</th>
</tr> </tr>
<tr> <tr>
@@ -33,13 +35,14 @@
<td class="number">@a.MgNr</td> <td class="number">@a.MgNr</td>
<td>@a.AdministrativeName</td> <td>@a.AdministrativeName</td>
<td>@a.Variety</td> <td>@a.Variety</td>
<td class="small">@(a.Status ?? "-")</td>
<td class="number">@($"{a.Weight:N0}")</td> <td class="number">@($"{a.Weight:N0}")</td>
</tr> </tr>
} }
<tr class="sum bold"> <tr class="sum bold">
<td colspan="2">Gesamt:</td> <td colspan="2">Gesamt:</td>
<td colspan="2">Anmeldungen: @($"{Model.Announcements.Count():N0}")</td> <td colspan="2">Anmeldungen: @($"{Model.Announcements.Count():N0}")</td>
<td class="number">@($"{Model.Announcements.Sum(a => a.Weight):N0}")</td> <td colspan="2" class="number">@($"{Model.Announcements.Sum(a => a.Weight):N0}")</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@@ -17,6 +17,9 @@ namespace Elwig.Models.Dtos {
("Name2", "Vorname", null, 40), ("Name2", "Vorname", null, 40),
("SortId", "Sorte", null, 10), ("SortId", "Sorte", null, 10),
("Weight", "Gewicht", "kg", 20), ("Weight", "Gewicht", "kg", 20),
("CreatedTimestamp", "Angemeldet", null, 35),
("ModifiedTimestamp", "Geändert", null, 35),
("Status", "Status", null, 20),
]; ];
public DeliveryAncmtListData(IEnumerable<DeliveryAncmtListRow> rows, List<string> filterNames) : public DeliveryAncmtListData(IEnumerable<DeliveryAncmtListRow> rows, List<string> filterNames) :
@@ -42,7 +45,10 @@ namespace Elwig.Models.Dtos {
public string AdministrativeName; public string AdministrativeName;
public string SortId; public string SortId;
public string Variety; public string Variety;
public DateTime CreatedTimestamp;
public DateTime? ModifiedTimestamp;
public int Weight; public int Weight;
public string? Status;
public DeliveryAncmtListRow(DeliveryAncmt a) { public DeliveryAncmtListRow(DeliveryAncmt a) {
var s = a.Schedule; var s = a.Schedule;
@@ -56,7 +62,10 @@ namespace Elwig.Models.Dtos {
AdministrativeName = m.AdministrativeName; AdministrativeName = m.AdministrativeName;
SortId = a.SortId; SortId = a.SortId;
Variety = a.Variety.Name; Variety = a.Variety.Name;
CreatedTimestamp = a.CreatedTimestamp;
ModifiedTimestamp = a.ModifiedTimestamp == a.CreatedTimestamp ? null : a.ModifiedTimestamp;
Weight = a.Weight; Weight = a.Weight;
Status = s.AncmtTo == null ? null : a.CreatedTimestamp >= s.AncmtTo ? "verspät." : "ok";
} }
} }
} }

View File

@@ -124,6 +124,7 @@ namespace Elwig.Services {
var filterNotCult = new List<string>(); var filterNotCult = new List<string>();
var filterDate = new List<(string?, string?)>(); var filterDate = new List<(string?, string?)>();
var filterTime = new List<(string?, string?)>(); var filterTime = new List<(string?, string?)>();
int filterWeightGt = 0, filterWeightLt = 0;
int filterYearGt = 0, filterYearLt = 0; int filterYearGt = 0, filterYearLt = 0;
double filterKmwGt = 0, filterKmwLt = 0; double filterKmwGt = 0, filterKmwLt = 0;
double filterOeGt = 0, filterOeLt = 0; double filterOeGt = 0, filterOeLt = 0;
@@ -250,6 +251,15 @@ namespace Elwig.Services {
filterZwst.Add(b.ZwstId); filterZwst.Add(b.ZwstId);
filter.RemoveAt(i--); filter.RemoveAt(i--);
filterNames.Add($"Zweigstelle {b.Name}"); filterNames.Add($"Zweigstelle {b.Name}");
} else if ((e.StartsWith('>') || e.StartsWith('<')) && e.EndsWith("kg")) {
if (int.TryParse(e[1..^2], out var num)) {
switch (e[0]) {
case '>': filterWeightGt = num; break;
case '<': filterWeightLt = num; break;
}
filter.RemoveAt(i--);
}
if (e.Length == 3) filter.RemoveAt(i--);
} else if (e.StartsWith('>') || e.StartsWith('<')) { } else if (e.StartsWith('>') || e.StartsWith('<')) {
if (double.TryParse(e[1..], out var num)) { if (double.TryParse(e[1..], out var num)) {
switch ((e[0], num)) { switch ((e[0], num)) {
@@ -347,6 +357,8 @@ namespace Elwig.Services {
} }
} }
if (filterWeightGt > 0) prd = prd.And(p => p.Delivery.Parts.Sum(p => p.Weight) >= filterWeightGt);
if (filterWeightLt > 0) prd = prd.And(p => p.Delivery.Parts.Sum(p => p.Weight) <= filterWeightLt);
if (filterYearGt > 0) prd = prd.And(p => p.Year >= filterYearGt); if (filterYearGt > 0) prd = prd.And(p => p.Year >= filterYearGt);
if (filterYearLt > 0) prd = prd.And(p => p.Year < filterYearLt); if (filterYearLt > 0) prd = prd.And(p => p.Year < filterYearLt);
if (filterMgNr.Count > 0) prd = prd.And(p => filterMgNr.Contains(p.Delivery.MgNr)); if (filterMgNr.Count > 0) prd = prd.And(p => filterMgNr.Contains(p.Delivery.MgNr));
@@ -376,6 +388,13 @@ namespace Elwig.Services {
if (filterOeGt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt); if (filterOeGt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) >= filterOeGt);
if (filterOeLt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) < filterOeLt); if (filterOeLt > 0) prd = prd.And(p => p.Kmw * (4.54 + 0.022 * p.Kmw) < filterOeLt);
if (filterWeightGt > 0 && filterWeightLt > 0) {
filterNames.Insert(0, $"{filterWeightGt:N0}{filterWeightLt:N0} kg");
} else if (filterWeightGt > 0) {
filterNames.Insert(0, $"ab {filterWeightGt:N0} kg");
} else if (filterWeightLt > 0) {
filterNames.Insert(0, $"unter {filterWeightLt:N0} kg");
}
if (filterYearGt > 0 && filterYearLt > 0) { if (filterYearGt > 0 && filterYearLt > 0) {
filterNames.Insert(0, $"{filterYearGt}{filterYearLt - 1}"); filterNames.Insert(0, $"{filterYearGt}{filterYearLt - 1}");
} else if (filterYearGt > 0) { } else if (filterYearGt > 0) {

View File

@@ -176,6 +176,7 @@
<Bold>Zweigstelle</Bold>: z.B. musterort, ...<LineBreak/> <Bold>Zweigstelle</Bold>: z.B. musterort, ...<LineBreak/>
<Bold>Attribut</Bold>: z.B. kabinett, !kabinett (alle außer kabinett), ...<LineBreak/> <Bold>Attribut</Bold>: z.B. kabinett, !kabinett (alle außer kabinett), ...<LineBreak/>
<Bold>Bewirtschaftung</Bold>: z.B. bio, !kip (alle außer KIP), ...<LineBreak/> <Bold>Bewirtschaftung</Bold>: z.B. bio, !kip (alle außer KIP), ...<LineBreak/>
<Bold>Gewicht</Bold>: z.B. &lt;500kg, &gt;6000kg, ... (gilt für Gewicht der gesamten Lieferung)<LineBreak/>
<Bold>Datum</Bold>: z.B. 1.9., 15.9.-10.10., -15.10.2020, ...<LineBreak/> <Bold>Datum</Bold>: z.B. 1.9., 15.9.-10.10., -15.10.2020, ...<LineBreak/>
<Bold>Uhrzeit</Bold>: z.B. 06:00-08:00, 18:00-, ...<LineBreak/> <Bold>Uhrzeit</Bold>: z.B. 06:00-08:00, 18:00-, ...<LineBreak/>
<Bold>Handwiegung</Bold>: handw[iegung], !Handw[iegung] (alle ohne Handwiegung)<LineBreak/> <Bold>Handwiegung</Bold>: handw[iegung], !Handw[iegung] (alle ohne Handwiegung)<LineBreak/>

View File

@@ -167,6 +167,13 @@
</Style> </Style>
</DataGridTextColumn.CellStyle> </DataGridTextColumn.CellStyle>
</DataGridTextColumn> </DataGridTextColumn>
<DataGridTextColumn Header="Angemeldet" Binding="{Binding CreatedTimestamp, StringFormat='{}{0:HH:mm, dd.MM.}'}" Width="100">
<DataGridTextColumn.CellStyle>
<Style>
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>

View File

@@ -85,14 +85,15 @@ namespace Elwig.Windows {
using var ctx = new AppDbContext(); using var ctx = new AppDbContext();
var deliverySchedules = await ctx.DeliverySchedules var deliverySchedules = await ctx.DeliverySchedules
.Where(s => s.Year == ViewModel.FilterSeason) .Where(s => s.Year == ViewModel.FilterSeason)
.Where(s => !ViewModel.FilterOnlyUpcoming || s.DateString.CompareTo(Utils.Today.ToString("yyyy-MM-dd")) >= 0)
.Include(s => s.Branch) .Include(s => s.Branch)
.Include(s => s.Announcements) .Include(s => s.Announcements)
.OrderBy(s => s.DateString) .OrderBy(s => s.DateString)
.ThenBy(s => s.Branch.Name) .ThenBy(s => s.Branch.Name)
.ThenBy(s => s.Description) .ThenBy(s => s.Description)
.ToListAsync(); .ToListAsync();
ControlUtils.RenewItemsSource(DeliveryScheduleList, deliverySchedules, DeliveryScheduleList_SelectionChanged, ControlUtils.RenewSourceDefault.First); ControlUtils.RenewItemsSource(DeliveryScheduleList, deliverySchedules
.Where(s => !ViewModel.FilterOnlyUpcoming || s.DateString.CompareTo(Utils.Today.ToString("yyyy-MM-dd")) >= 0)
.ToList(), DeliveryScheduleList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
ControlUtils.RenewItemsSource(DeliveryScheduleInput, deliverySchedules, DeliveryScheduleInput_SelectionChanged); ControlUtils.RenewItemsSource(DeliveryScheduleInput, deliverySchedules, DeliveryScheduleInput_SelectionChanged);
} }

View File

@@ -18,10 +18,10 @@ namespace Tests.DocumentTests {
Assert.That(text, Contains.Substring("Anmeldeliste")); Assert.That(text, Contains.Substring("Anmeldeliste"));
Assert.That(text, Contains.Substring("01.10.2020 Matzen GV Kabinettaktion")); Assert.That(text, Contains.Substring("01.10.2020 Matzen GV Kabinettaktion"));
Assert.That(table, Is.EqualTo(new string[][] { Assert.That(table, Is.EqualTo(new string[][] {
["01.10.2020", "101 MUSTERMANN Max", "Grüner Veltliner", "5 000"], ["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", "102 WEINBAUER Wernhardt", "Grüner Veltliner", "-", "10 000"],
["01.10.2020", "103 MUSTERBAUER Matthäus", "Grüner Veltliner", "8 000"], ["01.10.2020", "103 MUSTERBAUER Matthäus", "Grüner Veltliner", "-", "8 000"],
["01.10.2020", "104 WINZER Waltraud", "Grüner Veltliner", "2 000"], ["01.10.2020", "104 WINZER Waltraud", "Grüner Veltliner", "-", "2 000"],
["Gesamt:", "Anmeldungen: 4", "25 000"], ["Gesamt:", "Anmeldungen: 4", "25 000"],
})); }));
}); });