Billing: Always call CalculateBuckets() when Calculate() is called to avoid user confusion

This commit is contained in:
2024-01-31 11:14:56 +01:00
parent 50ac757067
commit b9287f8260
7 changed files with 83 additions and 21 deletions

View File

@ -1,8 +1,8 @@
using Elwig.Dialogs;
using Elwig.Helpers;
using Elwig.Helpers.Billing;
using Elwig.Helpers.Export;
using Elwig.Models.Dtos;
using Elwig.Models.Entities;
using Microsoft.Win32;
using System;
using System.Threading.Tasks;
@ -33,19 +33,34 @@ namespace Elwig.Windows {
OverUnderDeliveryButton.IsEnabled = valid;
AutoBusinessSharesButton.IsEnabled = valid;
PaymentButton.IsEnabled = valid;
AllowAttrIntoLowerInput.IsEnabled = valid && last;
AvoidUnderDeliveriesInput.IsEnabled = valid && last;
HonorGebundenInput.IsEnabled = valid && last;
AllowAttrIntoLowerInput.IsChecked = s0?.Billing_AllowAttrsIntoLower;
AvoidUnderDeliveriesInput.IsChecked = s0?.Billing_AvoidUnderDeliveries;
HonorGebundenInput.IsChecked = s0?.Billing_HonorGebunden;
}
private async void CalculateBucketsButton_Click(object sender, RoutedEventArgs evt) {
if (SeasonInput.Value is not int year)
if (SeasonInput.Value is not int year || await Context.Seasons.FindAsync(year) is not Season s)
return;
CalculateBucketsButton.IsEnabled = false;
Mouse.OverrideCursor = Cursors.AppStarting;
try {
s.Billing_AllowAttrsIntoLower = AllowAttrIntoLowerInput.IsChecked ?? false;
s.Billing_AvoidUnderDeliveries = AvoidUnderDeliveriesInput.IsChecked ?? false;
s.Billing_HonorGebunden = HonorGebundenInput.IsChecked ?? false;
Context.Update(s);
await Context.SaveChangesAsync();
} catch { }
var b = new Billing(year);
await b.FinishSeason();
await b.CalculateBuckets(
AllowAttrIntoLowerInput.IsChecked ?? false,
AvoidUnderDeliveriesInput.IsChecked ?? false,
HonorGebundenInput.IsChecked ?? false);
s.Billing_AllowAttrsIntoLower,
s.Billing_AvoidUnderDeliveries,
s.Billing_HonorGebunden);
Mouse.OverrideCursor = null;
CalculateBucketsButton.IsEnabled = true;
}