[#48] PaymentVariantsWindow: Add checkbox for custom member modifiers
All checks were successful
Test / Run tests (push) Successful in 2m22s

This commit is contained in:
2024-06-16 18:31:02 +02:00
parent 050e4f5b6f
commit 86e69e9ff8
8 changed files with 83 additions and 43 deletions

View File

@ -66,6 +66,12 @@
<th colspan="2" class="lborder">Automatische Nachzeichnung der GA:</th> <th colspan="2" class="lborder">Automatische Nachzeichnung der GA:</th>
<td class="center">@(Model.BillingData.ConsiderAutoBusinessShares ? "Ja" : "Nein")</td> <td class="center">@(Model.BillingData.ConsiderAutoBusinessShares ? "Ja" : "Nein")</td>
</tr> </tr>
<tr>
<th>Berechnung:</th>
<td colspan="3" class="center">@($"{Model.Variant.CalcTime:dd.MM.yyyy, HH:mm:ss}")</td>
<th colspan="2" class="lborder">Benutzerdef. Zu-/Abschläge pro Mitglied:</th>
<td class="center">@(Model.BillingData.ConsiderCustomModifiers ? "Ja" : "Nein")</td>
</tr>
<tr class="sectionheading"> <tr class="sectionheading">
<th colspan="4">Beträge</th> <th colspan="4">Beträge</th>
<th colspan="3" class="lborder">Statistik</th> <th colspan="3" class="lborder">Statistik</th>

View File

@ -41,6 +41,10 @@ namespace Elwig.Helpers.Billing {
get => GetConsider("consider_auto_business_shares"); get => GetConsider("consider_auto_business_shares");
set => SetConsider(value, "consider_auto_business_shares"); set => SetConsider(value, "consider_auto_business_shares");
} }
public bool ConsiderCustomModifiers {
get => GetConsider("consider_custom_modifiers");
set => SetConsider(value, "consider_custom_modifiers");
}
public double NetWeightModifier { public double NetWeightModifier {
get => GetWeightModifier("net_weight_modifier", "Rebelzuschlag"); get => GetWeightModifier("net_weight_modifier", "Rebelzuschlag");

View File

@ -17,7 +17,6 @@ namespace Elwig.Models.Entities {
[Column("date")] [Column("date")]
public required string DateString { get; set; } public required string DateString { get; set; }
[NotMapped] [NotMapped]
public DateOnly Date { public DateOnly Date {
get => DateOnly.ParseExact(DateString, "yyyy-MM-dd"); get => DateOnly.ParseExact(DateString, "yyyy-MM-dd");
@ -26,7 +25,6 @@ namespace Elwig.Models.Entities {
[Column("transfer_date")] [Column("transfer_date")]
public string? TransferDateString { get; set; } public string? TransferDateString { get; set; }
[NotMapped] [NotMapped]
public DateOnly? TransferDate { public DateOnly? TransferDate {
get => TransferDateString != null ? DateOnly.ParseExact(TransferDateString, "yyyy-MM-dd") : null; get => TransferDateString != null ? DateOnly.ParseExact(TransferDateString, "yyyy-MM-dd") : null;
@ -37,7 +35,9 @@ namespace Elwig.Models.Entities {
public bool TestVariant { get; set; } public bool TestVariant { get; set; }
[Column("calc_time")] [Column("calc_time")]
public int? CalcTime { get; set; } public int? CalcTimeUnix { get; set; }
[NotMapped]
public DateTime? CalcTime => CalcTimeUnix != null ? DateTimeOffset.FromUnixTimeSeconds((long)CalcTimeUnix).UtcDateTime.ToLocalTime() : null;
[Column("comment")] [Column("comment")]
public string? Comment { get; set; } public string? Comment { get; set; }

View File

@ -12,6 +12,7 @@
"consider_contract_penalties": {"type": "boolean"}, "consider_contract_penalties": {"type": "boolean"},
"consider_total_penalty": {"type": "boolean"}, "consider_total_penalty": {"type": "boolean"},
"consider_auto_business_shares": {"type": "boolean"}, "consider_auto_business_shares": {"type": "boolean"},
"consider_custom_modifiers": {"type": "boolean"},
"net_weight_modifier": {"type": "number"}, "net_weight_modifier": {"type": "number"},
"gross_weight_modifier": {"type": "number"}, "gross_weight_modifier": {"type": "number"},
"payment": {"$ref": "#/definitions/payment_1"}, "payment": {"$ref": "#/definitions/payment_1"},

View File

@ -76,25 +76,21 @@
Margin="0,13,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,13,0,0" VerticalAlignment="Top" HorizontalAlignment="Center"
TextChanged="SeasonInput_TextChanged"/> TextChanged="SeasonInput_TextChanged"/>
<Button x:Name="DeliveryConfirmationButton" Content="Anlieferungsbestätigung"
Click="DeliveryConfirmationButton_Click"
Margin="0,50,195,10" Width="190"/>
<Button x:Name="PaymentButton" Content="Auszahlung"
Click="PaymentButton_Click"
Margin="195,50,0,10" Width="190"/>
<Button x:Name="OverUnderDeliveryButton" Content="Über-/Unterlieferungen" <Button x:Name="OverUnderDeliveryButton" Content="Über-/Unterlieferungen"
Click="OverUnderDeliveryButton_Click" Click="OverUnderDeliveryButton_Click"
Margin="0,90,195,10" Width="190"/> Margin="0,50,195,10" Width="190"/>
<Button x:Name="PaymentAdjustmentButton" Content="Anpassung" <Button x:Name="DeliveryConfirmationButton" Content="Anlieferungsbestätigung"
Click="PaymentAdjustmentButton_Click" IsEnabled="False" Click="DeliveryConfirmationButton_Click"
Margin="195,90,0,10" Width="190"/> Margin="195,50,0,10" Width="190"/>
<Button x:Name="BreakdownButton" Content="Sorten-/Qual.aufteilung" <Button x:Name="BreakdownButton" Content="Sorten-/Qual.aufteilung"
Click="BreakdownButton_Click" Click="BreakdownButton_Click"
Margin="0,130,195,10" Width="190"/> Margin="0,90,195,10" Width="190"/>
<Button x:Name="PaymentButton" Content="Auszahlung"
Click="PaymentButton_Click"
Margin="195,90,0,10" Width="190"/>
</Grid> </Grid>
</Expander> </Expander>
</Grid> </Grid>

View File

@ -153,7 +153,7 @@ namespace Elwig.Windows {
} }
private void SeasonFinish_Expanded(object sender, RoutedEventArgs evt) { private void SeasonFinish_Expanded(object sender, RoutedEventArgs evt) {
Height = 570; Height = 530;
} }
private void SeasonFinish_Collapsed(object sender, RoutedEventArgs evt) { private void SeasonFinish_Collapsed(object sender, RoutedEventArgs evt) {
@ -166,7 +166,6 @@ namespace Elwig.Windows {
var valid = (s0 != null); var valid = (s0 != null);
DeliveryConfirmationButton.IsEnabled = valid; DeliveryConfirmationButton.IsEnabled = valid;
OverUnderDeliveryButton.IsEnabled = valid; OverUnderDeliveryButton.IsEnabled = valid;
PaymentAdjustmentButton.IsEnabled = valid && false;
PaymentButton.IsEnabled = valid; PaymentButton.IsEnabled = valid;
BreakdownButton.IsEnabled = valid; BreakdownButton.IsEnabled = valid;
} }
@ -211,27 +210,6 @@ namespace Elwig.Windows {
Mouse.OverrideCursor = null; Mouse.OverrideCursor = null;
} }
private async void PaymentAdjustmentButton_Click(object sender, RoutedEventArgs evt) {
if (SeasonInput.Value is not int year)
return;
if (false && App.Client.IsMatzen) {
PaymentAdjustmentButton.IsEnabled = false;
Mouse.OverrideCursor = Cursors.AppStarting;
var b = new Billing(year);
await b.AutoAdjustBusinessShare();
Mouse.OverrideCursor = null;
PaymentAdjustmentButton.IsEnabled = true;
} else {
MessageBox.Show(
"Es ist kein automatisches Nachzeichnen der Geschäftsanteile\n" +
"für diese Genossenschaft eingestellt!\n" +
"Bitte wenden Sie sich an die Programmierer!", "Fehler",
MessageBoxButton.OK, MessageBoxImage.Information);
}
}
private void PaymentButton_Click(object sender, RoutedEventArgs evt) { private void PaymentButton_Click(object sender, RoutedEventArgs evt) {
if (SeasonInput.Value is not int year) if (SeasonInput.Value is not int year)
return; return;

View File

@ -6,8 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Windows" xmlns:local="clr-namespace:Elwig.Windows"
xmlns:ctrl="clr-namespace:Elwig.Controls" xmlns:ctrl="clr-namespace:Elwig.Controls"
mc:Ignorable="d" Title="Auszahlungsvarianten - Elwig" Height="480" Width="850" MinHeight="400" MinWidth="830">
Title="Auszahlungsvarianten - Elwig" Height="450" Width="820" MinHeight="380" MinWidth="820">
<Window.Resources> <Window.Resources>
<Style TargetType="Label"> <Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="HorizontalAlignment" Value="Left"/>
@ -142,9 +141,12 @@
<CheckBox x:Name="ConsiderAutoInput" Content="Automatische Nachzeichnungen der GA" <CheckBox x:Name="ConsiderAutoInput" Content="Automatische Nachzeichnungen der GA"
Margin="110,155,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="110,155,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
Checked="ConsiderAutoInput_Changed" Unchecked="ConsiderAutoInput_Changed"/> Checked="ConsiderAutoInput_Changed" Unchecked="ConsiderAutoInput_Changed"/>
<Label Content="&#xF0AE;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="0" Grid.Column="1" Margin="108,175,10,10"/> <CheckBox x:Name="ConsiderCustomInput" Content="Benutzerdefinierte Zu-/Abschläge pro Mitglied"
Margin="110,175,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
Checked="ConsiderCustomInput_Changed" Unchecked="ConsiderCustomInput_Changed"/>
<Label Content="&#xF0AE;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="0" Grid.Column="1" Margin="108,195,10,10"/>
<Grid Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="50,180,10,10"> <Grid Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="50,200,10,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="110"/> <ColumnDefinition Width="110"/>
<ColumnDefinition Width="27"/> <ColumnDefinition Width="27"/>
@ -156,6 +158,8 @@
<RowDefinition Height="27"/> <RowDefinition Height="27"/>
<RowDefinition Height="5"/> <RowDefinition Height="5"/>
<RowDefinition Height="27"/> <RowDefinition Height="27"/>
<RowDefinition Height="5"/>
<RowDefinition Height="27"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.Resources> <Grid.Resources>
@ -184,6 +188,16 @@
<Button x:Name="EditButton" Content="Bearbeiten" Grid.Column="0" Grid.Row="2" <Button x:Name="EditButton" Content="Bearbeiten" Grid.Column="0" Grid.Row="2"
Click="EditButton_Click"/> Click="EditButton_Click"/>
<Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="1"/> <Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="1"/>
<Button x:Name="PaymentAdjustmentButton" Content="Anpassen" Grid.Column="0" Grid.Row="4"
Click="PaymentAdjustmentButton_Click"/>
<Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="4" Grid.Column="1" RenderTransformOrigin="0.5,0.5" >
<Label.RenderTransform>
<TransformGroup>
<RotateTransform Angle="-45"/>
<TranslateTransform Y="-5"/>
</TransformGroup>
</Label.RenderTransform>
</Label>
<Button x:Name="CalculateButton" Content="Berechnen" Grid.Column="2" Grid.Row="2" <Button x:Name="CalculateButton" Content="Berechnen" Grid.Column="2" Grid.Row="2"
Click="CalculateButton_Click"/> Click="CalculateButton_Click"/>
<Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="3" x:Name="Arrow3"/> <Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="3" x:Name="Arrow3"/>

View File

@ -91,6 +91,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties; ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty; ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares; ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
ConsiderCustomInput.IsChecked = BillingData.ConsiderCustomModifiers;
if (BillingData.NetWeightModifier != 0) { if (BillingData.NetWeightModifier != 0) {
WeightModifierInput.Text = $"{Math.Round(BillingData.NetWeightModifier * 100.0, 8)}"; WeightModifierInput.Text = $"{Math.Round(BillingData.NetWeightModifier * 100.0, 8)}";
} else if (BillingData.GrossWeightModifier != 0) { } else if (BillingData.GrossWeightModifier != 0) {
@ -105,6 +106,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsChecked = false; ConsiderPenaltiesInput.IsChecked = false;
ConsiderPenaltyInput.IsChecked = false; ConsiderPenaltyInput.IsChecked = false;
ConsiderAutoInput.IsChecked = false; ConsiderAutoInput.IsChecked = false;
ConsiderCustomInput.IsChecked = false;
WeightModifierInput.Text = ""; WeightModifierInput.Text = "";
DataInput.Text = v.Data; DataInput.Text = v.Data;
} }
@ -113,6 +115,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsEnabled = !locked; ConsiderPenaltiesInput.IsEnabled = !locked;
ConsiderPenaltyInput.IsEnabled = !locked; ConsiderPenaltyInput.IsEnabled = !locked;
ConsiderAutoInput.IsEnabled = !locked; ConsiderAutoInput.IsEnabled = !locked;
ConsiderCustomInput.IsEnabled = !locked;
DataInput.IsReadOnly = locked; DataInput.IsReadOnly = locked;
} else { } else {
EditButton.Content = "Bearbeiten"; EditButton.Content = "Bearbeiten";
@ -153,6 +156,8 @@ namespace Elwig.Windows {
ConsiderPenaltyInput.IsEnabled = false; ConsiderPenaltyInput.IsEnabled = false;
ConsiderAutoInput.IsChecked = false; ConsiderAutoInput.IsChecked = false;
ConsiderAutoInput.IsEnabled = false; ConsiderAutoInput.IsEnabled = false;
ConsiderCustomInput.IsChecked = false;
ConsiderCustomInput.IsEnabled = false;
DataInput.Text = ""; DataInput.Text = "";
DataInput.IsReadOnly = true; DataInput.IsReadOnly = true;
} }
@ -168,6 +173,7 @@ namespace Elwig.Windows {
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) || (ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) || (ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares) || (ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares) ||
(ConsiderCustomInput.IsChecked != BillingData?.ConsiderCustomModifiers) ||
WeightModifierChanged); WeightModifierChanged);
CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true }; CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true };
CommitButton.IsEnabled = CalculateButton.IsEnabled; CommitButton.IsEnabled = CalculateButton.IsEnabled;
@ -295,6 +301,26 @@ namespace Elwig.Windows {
App.FocusChartWindow(v.Year, v.AvNr); App.FocusChartWindow(v.Year, v.AvNr);
} }
private async void PaymentAdjustmentButton_Click(object sender, RoutedEventArgs evt) {
if (false && App.Client.IsMatzen) {
PaymentAdjustmentButton.IsEnabled = false;
Mouse.OverrideCursor = Cursors.AppStarting;
var b = new Billing(Year);
await b.AutoAdjustBusinessShare();
Mouse.OverrideCursor = null;
PaymentAdjustmentButton.IsEnabled = true;
} else {
MessageBox.Show(
"Es ist kein automatisches Nachzeichnen der Geschäftsanteile\n" +
"für diese Genossenschaft eingestellt!\n" +
"Bitte wenden Sie sich an die Programmierer!", "Fehler",
MessageBoxButton.OK, MessageBoxImage.Information);
}
}
private async void MailButton_Click(object sender, RoutedEventArgs evt) { private async void MailButton_Click(object sender, RoutedEventArgs evt) {
if (PaymentVariantList.SelectedItem is not PaymentVar pv) if (PaymentVariantList.SelectedItem is not PaymentVar pv)
return; return;
@ -471,6 +497,7 @@ namespace Elwig.Windows {
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false; d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false; d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
d.ConsiderAutoBusinessShares = ConsiderAutoInput.IsChecked ?? false; d.ConsiderAutoBusinessShares = ConsiderAutoInput.IsChecked ?? false;
d.ConsiderCustomModifiers = ConsiderCustomInput.IsChecked ?? false;
var modVal = WeightModifierInput.Text.Length > 0 ? double.Parse(WeightModifierInput.Text) : 0; var modVal = WeightModifierInput.Text.Length > 0 ? double.Parse(WeightModifierInput.Text) : 0;
d.NetWeightModifier = modVal > 0 ? modVal / 100.0 : 0; d.NetWeightModifier = modVal > 0 ? modVal / 100.0 : 0;
d.GrossWeightModifier = modVal < 0 ? modVal / 100.0 : 0; d.GrossWeightModifier = modVal < 0 ? modVal / 100.0 : 0;
@ -488,6 +515,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput_Changed(null, null); ConsiderPenaltiesInput_Changed(null, null);
ConsiderPenaltyInput_Changed(null, null); ConsiderPenaltyInput_Changed(null, null);
ConsiderAutoInput_Changed(null, null); ConsiderAutoInput_Changed(null, null);
ConsiderCustomInput_Changed(null, null);
WeightModifierInput_TextChanged(null, null); WeightModifierInput_TextChanged(null, null);
} catch (Exception exc) { } catch (Exception exc) {
await HintContextChange(); await HintContextChange();
@ -630,6 +658,19 @@ namespace Elwig.Windows {
UpdateSaveButton(); UpdateSaveButton();
} }
private void ConsiderCustomInput_Changed(object? sender, RoutedEventArgs? evt) {
if (BillingData == null) {
ControlUtils.ClearInputState(ConsiderCustomInput);
return;
}
if (BillingData.ConsiderCustomModifiers != ConsiderCustomInput.IsChecked) {
ControlUtils.SetInputChanged(ConsiderCustomInput);
} else {
ControlUtils.ClearInputState(ConsiderCustomInput);
}
UpdateSaveButton();
}
private void WeightModifierInput_TextChanged(object? sender, TextChangedEventArgs? evt) { private void WeightModifierInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
var res = Validator.CheckDecimal(WeightModifierInput, false, 3, 2, true); var res = Validator.CheckDecimal(WeightModifierInput, false, 3, 2, true);
if (BillingData == null) { if (BillingData == null) {