Compare commits

...

7 Commits

Author SHA1 Message Date
lorenz.stechauner b76c5ea874 [#46] CreditNote: Show number of added business shares
Test / Run tests (push) Successful in 1m57s
2024-06-16 23:54:53 +02:00
lorenz.stechauner 86e69e9ff8 [#48] PaymentVariantsWindow: Add checkbox for custom member modifiers
Test / Run tests (push) Successful in 2m22s
2024-06-16 18:31:02 +02:00
lorenz.stechauner 050e4f5b6f ControlUtils: Allow RenewItemsSource for ListBox to reselect all items
Test / Run tests (push) Successful in 2m21s
2024-06-14 17:02:25 +02:00
lorenz.stechauner 01f055ee17 Test: Fix DocumentTests again?
Test / Run tests (push) Successful in 1m42s
2024-06-14 12:15:05 +02:00
lorenz.stechauner da9df5cbeb Export/Ebics: Warn user if no client IBAN is set
Test / Run tests (push) Failing after 2m22s
2024-06-14 12:11:49 +02:00
lorenz.stechauner cc0aa6046f Export/Ebics: Also export Ctry in address line mode
Test / Run tests (push) Successful in 2m25s
2024-06-13 10:00:49 +02:00
lorenz.stechauner 5cb7d2cbb0 Export/Ebics: Escape address properly
Test / Run tests (push) Successful in 1m47s
2024-06-13 01:48:37 +02:00
13 changed files with 124 additions and 65 deletions
+4 -2
View File
@@ -18,7 +18,8 @@ namespace Elwig.Documents {
public string MemberModifier;
public IEnumerable<(string Name, int Kg, decimal Amount)>? MemberUnderDeliveries;
public decimal MemberTotalUnderDelivery;
public decimal MemberAutoBusinessShares;
public int MemberAutoBusinessShares;
public decimal MemberAutoBusinessSharesAmount;
public CreditNote(
AppDbContext ctx,
@@ -66,7 +67,8 @@ namespace Elwig.Documents {
MemberAutoBusinessShares = ctx.MemberHistory
.Where(h => h.MgNr == p.Member.MgNr && h.Type == "auto")
.Where(h => h.DateString.CompareTo(fromDate) >= 0 && h.DateString.CompareTo(toDate) <= 0)
.Sum(h => h.BusinessShares) * (-season.BusinessShareValue ?? 0);
.Sum(h => h.BusinessShares);
MemberAutoBusinessSharesAmount = MemberAutoBusinessShares * (-season.BusinessShareValue ?? 0);
}
if (considerContractPenalties) {
var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
+3 -3
View File
@@ -153,9 +153,9 @@
@Raw(FormatRow("Unterlieferung (GA)", Model.MemberTotalUnderDelivery, add: true));
penalty += Model.MemberTotalUnderDelivery;
}
@if (Model.MemberAutoBusinessShares != 0) {
@Raw(FormatRow("Autom. Nachz. von GA", Model.MemberAutoBusinessShares, add: true));
penalty += Model.MemberAutoBusinessShares;
@if (Model.MemberAutoBusinessSharesAmount != 0) {
@Raw(FormatRow($"Autom. Nachz. von GA ({Model.MemberAutoBusinessShares})", Model.MemberAutoBusinessSharesAmount, add: true));
penalty += Model.MemberAutoBusinessSharesAmount;
}
@if (Model.Credit == null) {
@@ -66,6 +66,12 @@
<th colspan="2" class="lborder">Automatische Nachzeichnung der GA:</th>
<td class="center">@(Model.BillingData.ConsiderAutoBusinessShares ? "Ja" : "Nein")</td>
</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">
<th colspan="4">Beträge</th>
<th colspan="3" class="lborder">Statistik</th>
+4
View File
@@ -41,6 +41,10 @@ namespace Elwig.Helpers.Billing {
get => GetConsider("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 {
get => GetWeightModifier("net_weight_modifier", "Rebelzuschlag");
+23 -11
View File
@@ -134,19 +134,31 @@ namespace Elwig.Helpers {
public static void RenewItemsSource(ListBox listBox, IEnumerable? source, SelectionChangedEventHandler? handler = null, RenewSourceDefault def = RenewSourceDefault.None) {
if (listBox.ItemsSource == source)
return;
var selectedId = Utils.GetEntityIdentifier(listBox.SelectedItem);
object? selItem = null;
if (selectedId != 0 && source != null)
selItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(Utils.GetEntityIdentifier(i)));
if (source != null && selItem == null) {
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
selItem = source.Cast<object>().FirstOrDefault();
if (listBox.SelectionMode == SelectionMode.Single) {
var selectedId = Utils.GetEntityIdentifier(listBox.SelectedItem);
object? selItem = null;
if (selectedId != 0 && source != null)
selItem = source.Cast<object>().FirstOrDefault(i => selectedId.Equals(Utils.GetEntityIdentifier(i)));
if (source != null && selItem == null) {
if ((def == RenewSourceDefault.IfOnly && source.Cast<object>().Count() == 1) || def == RenewSourceDefault.First) {
selItem = source.Cast<object>().FirstOrDefault();
}
}
if (handler != null && selItem != null) listBox.SelectionChanged -= handler;
listBox.ItemsSource = source;
if (handler != null && selItem != null) listBox.SelectionChanged += handler;
listBox.SelectedItem = selItem;
} else {
var selectedIds = listBox.SelectedItems.Cast<object>().Select(Utils.GetEntityIdentifier).ToList();
if (handler != null && selectedIds != null) listBox.SelectionChanged -= handler;
listBox.ItemsSource = source;
if (source != null && selectedIds != null) {
listBox.SelectedItems.Clear();
foreach (var i in source.Cast<object>().Where(i => selectedIds.Contains(Utils.GetEntityIdentifier(i))))
listBox.SelectedItems.Add(i);
}
if (handler != null && selectedIds != null) listBox.SelectionChanged += handler;
}
if (handler != null && selItem != null) listBox.SelectionChanged -= handler;
listBox.ItemsSource = source;
if (handler != null && selItem != null) listBox.SelectionChanged += handler;
listBox.SelectedItem = selItem;
}
public static object? GetItemFromSource(IEnumerable source, int? hash) {
+8 -3
View File
@@ -38,8 +38,11 @@ namespace Elwig.Helpers.Export {
}
public async Task ExportAsync(IEnumerable<Transaction> transactions, IProgress<double>? progress = null) {
if (transactions.Any(tx => tx.Amount < 0))
if (transactions.Any(tx => tx.Amount < 0)) {
throw new ArgumentException("Tranaction amount may not be negative");
} else if (App.Client.Iban == null) {
throw new ArgumentException("Client IBAN has to be set");
}
progress?.Report(0.0);
var nbOfTxs = transactions.Count();
int count = nbOfTxs + 2, i = 0;
@@ -86,9 +89,11 @@ namespace Elwig.Helpers.Export {
var full = ShowAddresses == AddressMode.Full;
await Writer.WriteLineAsync($"""
<PstlAdr>
{(full ? $"<StrtNm>{SecurityElement.Escape(a1?[..Math.Min(70, a1.Length)])}</StrtNm> <BldgNb>{SecurityElement.Escape(a2?[..Math.Min(16, a2.Length)])}</BldgNb>" : $"<AdrLine>{a.Address[..Math.Min(70, a.Address.Length)]}</AdrLine>")}
{(full ? "" : $"<Ctry>{a.PostalDest.Country.Alpha2}</Ctry>")}
{(full ? $"<StrtNm>{SecurityElement.Escape(a1?[..Math.Min(70, a1.Length)])}</StrtNm> <BldgNb>{SecurityElement.Escape(a2?[..Math.Min(16, a2.Length)])}</BldgNb>" :
$"<AdrLine>{SecurityElement.Escape(a.Address[..Math.Min(70, a.Address.Length)])}</AdrLine>")}
<{(full ? "PstCd" : "AdrLine")}>{a.PostalDest.AtPlz?.Plz}{(full ? "</PstCd> <TwnNm>" : " ")}{SecurityElement.Escape(a.PostalDest.AtPlz?.Ort.Name)}</{(full ? "TwnNm" : "AdrLine")}>
<{(full ? "" : "!--")}Ctry>{a.PostalDest.Country.Alpha2}</Ctry{(full ? "" : "--")}>
{(full ? $"<Ctry>{a.PostalDest.Country.Alpha2}</Ctry>" : "")}
</PstlAdr>
""");
}
+3 -3
View File
@@ -17,7 +17,6 @@ namespace Elwig.Models.Entities {
[Column("date")]
public required string DateString { get; set; }
[NotMapped]
public DateOnly Date {
get => DateOnly.ParseExact(DateString, "yyyy-MM-dd");
@@ -26,7 +25,6 @@ namespace Elwig.Models.Entities {
[Column("transfer_date")]
public string? TransferDateString { get; set; }
[NotMapped]
public DateOnly? TransferDate {
get => TransferDateString != null ? DateOnly.ParseExact(TransferDateString, "yyyy-MM-dd") : null;
@@ -37,7 +35,9 @@ namespace Elwig.Models.Entities {
public bool TestVariant { get; set; }
[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")]
public string? Comment { get; set; }
@@ -12,6 +12,7 @@
"consider_contract_penalties": {"type": "boolean"},
"consider_total_penalty": {"type": "boolean"},
"consider_auto_business_shares": {"type": "boolean"},
"consider_custom_modifiers": {"type": "boolean"},
"net_weight_modifier": {"type": "number"},
"gross_weight_modifier": {"type": "number"},
"payment": {"$ref": "#/definitions/payment_1"},
+9 -13
View File
@@ -76,25 +76,21 @@
Margin="0,13,0,0" VerticalAlignment="Top" HorizontalAlignment="Center"
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"
Click="OverUnderDeliveryButton_Click"
Margin="0,90,195,10" Width="190"/>
Margin="0,50,195,10" Width="190"/>
<Button x:Name="PaymentAdjustmentButton" Content="Anpassung"
Click="PaymentAdjustmentButton_Click" IsEnabled="False"
Margin="195,90,0,10" Width="190"/>
<Button x:Name="DeliveryConfirmationButton" Content="Anlieferungsbestätigung"
Click="DeliveryConfirmationButton_Click"
Margin="195,50,0,10" Width="190"/>
<Button x:Name="BreakdownButton" Content="Sorten-/Qual.aufteilung"
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>
</Expander>
</Grid>
+1 -23
View File
@@ -153,7 +153,7 @@ namespace Elwig.Windows {
}
private void SeasonFinish_Expanded(object sender, RoutedEventArgs evt) {
Height = 570;
Height = 530;
}
private void SeasonFinish_Collapsed(object sender, RoutedEventArgs evt) {
@@ -166,7 +166,6 @@ namespace Elwig.Windows {
var valid = (s0 != null);
DeliveryConfirmationButton.IsEnabled = valid;
OverUnderDeliveryButton.IsEnabled = valid;
PaymentAdjustmentButton.IsEnabled = valid && false;
PaymentButton.IsEnabled = valid;
BreakdownButton.IsEnabled = valid;
}
@@ -211,27 +210,6 @@ namespace Elwig.Windows {
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) {
if (SeasonInput.Value is not int year)
return;
+18 -4
View File
@@ -6,8 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Elwig.Windows"
xmlns:ctrl="clr-namespace:Elwig.Controls"
mc:Ignorable="d"
Title="Auszahlungsvarianten - Elwig" Height="450" Width="820" MinHeight="380" MinWidth="820">
Title="Auszahlungsvarianten - Elwig" Height="480" Width="850" MinHeight="400" MinWidth="830">
<Window.Resources>
<Style TargetType="Label">
<Setter Property="HorizontalAlignment" Value="Left"/>
@@ -142,9 +141,12 @@
<CheckBox x:Name="ConsiderAutoInput" Content="Automatische Nachzeichnungen der GA"
Margin="110,155,10,10" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top"
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>
<ColumnDefinition Width="110"/>
<ColumnDefinition Width="27"/>
@@ -156,6 +158,8 @@
<RowDefinition Height="27"/>
<RowDefinition Height="5"/>
<RowDefinition Height="27"/>
<RowDefinition Height="5"/>
<RowDefinition Height="27"/>
</Grid.RowDefinitions>
<Grid.Resources>
@@ -184,6 +188,16 @@
<Button x:Name="EditButton" Content="Bearbeiten" Grid.Column="0" Grid.Row="2"
Click="EditButton_Click"/>
<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"
Click="CalculateButton_Click"/>
<Label Content="&#xF0AF;" FontFamily="Segoe MDL2 Assets" FontSize="16" Grid.Row="2" Grid.Column="3" x:Name="Arrow3"/>
@@ -91,6 +91,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
ConsiderCustomInput.IsChecked = BillingData.ConsiderCustomModifiers;
if (BillingData.NetWeightModifier != 0) {
WeightModifierInput.Text = $"{Math.Round(BillingData.NetWeightModifier * 100.0, 8)}";
} else if (BillingData.GrossWeightModifier != 0) {
@@ -105,6 +106,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsChecked = false;
ConsiderPenaltyInput.IsChecked = false;
ConsiderAutoInput.IsChecked = false;
ConsiderCustomInput.IsChecked = false;
WeightModifierInput.Text = "";
DataInput.Text = v.Data;
}
@@ -113,6 +115,7 @@ namespace Elwig.Windows {
ConsiderPenaltiesInput.IsEnabled = !locked;
ConsiderPenaltyInput.IsEnabled = !locked;
ConsiderAutoInput.IsEnabled = !locked;
ConsiderCustomInput.IsEnabled = !locked;
DataInput.IsReadOnly = locked;
} else {
EditButton.Content = "Bearbeiten";
@@ -153,6 +156,8 @@ namespace Elwig.Windows {
ConsiderPenaltyInput.IsEnabled = false;
ConsiderAutoInput.IsChecked = false;
ConsiderAutoInput.IsEnabled = false;
ConsiderCustomInput.IsChecked = false;
ConsiderCustomInput.IsEnabled = false;
DataInput.Text = "";
DataInput.IsReadOnly = true;
}
@@ -168,6 +173,7 @@ namespace Elwig.Windows {
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares) ||
(ConsiderCustomInput.IsChecked != BillingData?.ConsiderCustomModifiers) ||
WeightModifierChanged);
CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true };
CommitButton.IsEnabled = CalculateButton.IsEnabled;
@@ -295,6 +301,26 @@ namespace Elwig.Windows {
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) {
if (PaymentVariantList.SelectedItem is not PaymentVar pv)
return;
@@ -471,6 +497,7 @@ namespace Elwig.Windows {
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
d.ConsiderAutoBusinessShares = ConsiderAutoInput.IsChecked ?? false;
d.ConsiderCustomModifiers = ConsiderCustomInput.IsChecked ?? false;
var modVal = WeightModifierInput.Text.Length > 0 ? double.Parse(WeightModifierInput.Text) : 0;
d.NetWeightModifier = 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);
ConsiderPenaltyInput_Changed(null, null);
ConsiderAutoInput_Changed(null, null);
ConsiderCustomInput_Changed(null, null);
WeightModifierInput_TextChanged(null, null);
} catch (Exception exc) {
await HintContextChange();
@@ -630,6 +658,19 @@ namespace Elwig.Windows {
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) {
var res = Validator.CheckDecimal(WeightModifierInput, false, 3, 2, true);
if (BillingData == null) {
+3 -3
View File
@@ -16,9 +16,9 @@ namespace Tests.DocumentTests {
Assert.That(text, Contains.Substring("Mitgliederliste"));
Assert.That(text, Contains.Substring("Alle Mitglieder"));
Assert.That(text, Contains.Substring("""
101 MUSTERMANN Max Winzerstraße 1 2223 Hohenruppersdorf 1472583 0 Hohenruppersdorf
102 WEINBAUER Wernhardt Winzerstraße 2 2223 Hohenruppersdorf 4725836 0 Hohenruppersdorf
W&B Weinbauer GesbR Winzerstraße 2 2223 Hohenruppersdorf
101 MUSTERMANN Max Winzerstraße 1 2223 Hohenruppersdorf 1472583 0 Hohenruppersdorf
102 WEINBAUER Wernhardt Winzerstraße 2 2223 Hohenruppersdorf 4725836 0 Hohenruppersdorf
W&B Weinbauer GesbR Winzerstraße 2 2223 Hohenruppersdorf
"""));
});
}