[#46] PaymentAdjustmentWindow: Refine DataGrid
All checks were successful
Test / Run tests (push) Successful in 1m55s
All checks were successful
Test / Run tests (push) Successful in 1m55s
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Elwig.Windows"
|
||||
xmlns:ctrl="clr-namespace:Elwig.Controls"
|
||||
Title="Auszahlung anpassen - Elwig" Height="500" Width="800" MinHeight="400" MinWidth="700">
|
||||
Title="Auszahlung anpassen - Elwig" Height="500" Width="850" MinHeight="400" MinWidth="850">
|
||||
<Window.Resources>
|
||||
<Style TargetType="Label">
|
||||
<Setter Property="HorizontalAlignment" Value="Left"/>
|
||||
@ -44,7 +44,7 @@
|
||||
<RowDefinition Height="24"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="450"/>
|
||||
<ColumnDefinition Width="2.5*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
@ -52,18 +52,41 @@
|
||||
</Menu>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<ListBox x:Name="MemberList" Margin="10,10,10,10">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding MgNr}" Width="30" TextAlignment="Right" Margin="0,0,10,0"/>
|
||||
<TextBlock Text="{Binding FamilyName}" Width="100"/>
|
||||
<TextBlock Text="{Binding GivenName}" Width="60"/>
|
||||
<TextBlock Text="{Binding BusinessShares}" Width="40" TextAlignment="Right"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<DataGrid x:Name="MemberList" AutoGenerateColumns="False" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="None" SelectionMode="Single"
|
||||
CanUserDeleteRows="False" CanUserResizeRows="False" CanUserAddRows="False" Margin="10,10,10,10">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="MgNr." Binding="{Binding MgNr, StringFormat='{}{0} '}" Width="45">
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style>
|
||||
<Setter Property="TextBlock.TextAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Nachname" Binding="{Binding FamilyName}" Width="100"/>
|
||||
<DataGridTextColumn Header="Vorname" Binding="{Binding GivenName}" Width="100"/>
|
||||
<DataGridTextColumn Header="GA" Binding="{Binding BusinessShares, StringFormat='{}{0} '}" Width="35">
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style>
|
||||
<Setter Property="TextBlock.TextAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Ü.-/U.-Lfrg." Binding="{Binding OverUnder, StringFormat='{}{0} kg '}" Width="70">
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style>
|
||||
<Setter Property="TextBlock.TextAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Nachz." Binding="{Binding Adjust, StringFormat='{}{0} '}" Width="45">
|
||||
<DataGridTextColumn.CellStyle>
|
||||
<Style>
|
||||
<Setter Property="TextBlock.TextAlignment" Value="Right"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.CellStyle>
|
||||
</DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Column="1" Grid.Row="1">
|
||||
@ -86,7 +109,7 @@
|
||||
<ctrl:UnitTextBox x:Name="MinBsInput" Unit="GA" Margin="140,70,10,10" Width="50"
|
||||
TextChanged="BsInput_TextChanged"/>
|
||||
|
||||
<Button x:Name="SeasonButton" Content="GA-Wert" Margin="10,10,10,40" Width="120"
|
||||
<Button x:Name="SeasonButton" Content="GA-Wert" Margin="10,10,10,42" Width="120"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Bottom"
|
||||
Click="SeasonButton_Click"/>
|
||||
<Button x:Name="AutoAdjustBsButton" Content="Nachzeichnen" Margin="10,10,135,10" Width="120"
|
||||
|
@ -1,7 +1,9 @@
|
||||
using Elwig.Helpers;
|
||||
using Elwig.Helpers.Billing;
|
||||
using Elwig.Models.Dtos;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -24,19 +26,55 @@ namespace Elwig.Windows {
|
||||
}
|
||||
|
||||
protected override async Task OnRenewContext(AppDbContext ctx) {
|
||||
MemberList.ItemsSource = await ctx.MemberHistory
|
||||
var members = await ctx.Members
|
||||
.Select(m => new {
|
||||
m.MgNr,
|
||||
m.FamilyName,
|
||||
m.GivenName,
|
||||
m.BusinessShares,
|
||||
})
|
||||
.OrderBy(m => m.FamilyName)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToListAsync();
|
||||
var season = (await ctx.Seasons.FindAsync(Year))!;
|
||||
|
||||
var tbl = await OverUnderDeliveryData.ForSeason(ctx.OverUnderDeliveryRows, Year);
|
||||
var weight = tbl.Rows.ToDictionary(r => r.MgNr, r => r.Weight);
|
||||
|
||||
var history = await ctx.MemberHistory
|
||||
.Where(h => h.DateString.CompareTo($"{Year}-01-01") >= 0 && h.DateString.CompareTo($"{Year}-12-31") <= 0 && h.Type == "auto" && h.BusinessShares > 0)
|
||||
.GroupBy(h => h.Member)
|
||||
.Select(h => new {
|
||||
h.Key.MgNr,
|
||||
h.Key.FamilyName,
|
||||
h.Key.GivenName,
|
||||
BusinessShares = h.Sum(g => g.BusinessShares),
|
||||
.ToDictionaryAsync(h => h.Key.MgNr, h => h.Sum(g => g.BusinessShares));
|
||||
|
||||
var list = members
|
||||
.Select(m => new {
|
||||
m.MgNr,
|
||||
m.FamilyName,
|
||||
m.GivenName,
|
||||
BusinessShares = m.BusinessShares - history.GetValueOrDefault(m.MgNr, 0),
|
||||
DeliveryObligation = (m.BusinessShares - history.GetValueOrDefault(m.MgNr, 0)) * season.MinKgPerBusinessShare,
|
||||
DeliveryRight = (m.BusinessShares - history.GetValueOrDefault(m.MgNr, 0)) * season.MaxKgPerBusinessShare,
|
||||
})
|
||||
.OrderBy(h => h.FamilyName)
|
||||
.ThenBy(h => h.GivenName)
|
||||
.ThenBy(h => h.MgNr)
|
||||
.ToListAsync();
|
||||
.Select(m => new {
|
||||
m.MgNr,
|
||||
m.FamilyName,
|
||||
m.GivenName,
|
||||
m.BusinessShares,
|
||||
OverUnder = weight.TryGetValue(m.MgNr, out int v1) ?
|
||||
(v1 < m.DeliveryObligation ? (int?)v1 - m.DeliveryObligation :
|
||||
v1 > m.DeliveryRight ? (int?)v1 - m.DeliveryRight : null)
|
||||
: null,
|
||||
Adjust = history.TryGetValue(m.MgNr, out int v2) ? (int?)v2 : null
|
||||
})
|
||||
.Where(m => m.OverUnder != null || m.Adjust != null)
|
||||
.OrderByDescending(m => m.OverUnder)
|
||||
.ThenBy(m => m.FamilyName)
|
||||
.ThenBy(m => m.GivenName)
|
||||
.ThenBy(m => m.MgNr)
|
||||
.ToList();
|
||||
|
||||
MemberList.ItemsSource = list;
|
||||
}
|
||||
|
||||
private async void AutoAdjustBsButton_Click(object sender, RoutedEventArgs evt) {
|
||||
|
Reference in New Issue
Block a user