[#83] PaymentVariantsWindow: Automatically calculate when saving variant
Test / Run tests (push) Successful in 1m57s
Test / Run tests (push) Successful in 1m57s
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user