[#83] PaymentVariantsWindow: Automatically calculate when saving variant
Test / Run tests (push) Successful in 1m57s

This commit is contained in:
2026-08-03 11:26:28 +02:00
parent 668030fbff
commit cfabf99c99
2 changed files with 42 additions and 12 deletions
+14 -1
View File
@@ -5,6 +5,7 @@ using Elwig.Services;
using Elwig.ViewModels;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
@@ -239,15 +240,27 @@ namespace Elwig.Windows {
private async void SaveButton_Click(object sender, RoutedEventArgs evt) {
if (PaymentVariantList.SelectedItem is not PaymentVar v || ViewModel.BillingData == null)
return;
Mouse.OverrideCursor = Cursors.Wait;
try {
await ViewModel.UpdatePaymentVariant(v.Year, v.AvNr);
App.HintContextChange();
} catch (Exception exc) {
await ForceContextReload();
InteractionService.ShowDbException("Auszahlungsvariante aktualisieren", exc);
}
try {
await Task.Run(async () => {
var b = await BillingVariant.Create(v.Year, v.AvNr);
await b.Calculate(false);
});
} catch (KeyNotFoundException exc) {
InteractionService.ShowInformation("Noch nicht alle Preise festgelegt", exc.Message);
} catch (Exception exc) {
InteractionService.ShowException("Berechnungsfehler", exc);
}
App.HintContextChange();
Mouse.OverrideCursor = null;
await EnsureContextRenewed();
CommentInput_TextChanged(null, null);
DateInput_TextChanged(null, null);