[#40] Billing: Add Rebelzuschlag
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
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="510" Width="820" MinHeight="500" MinWidth="820">
|
||||
<Window.Resources>
|
||||
@ -86,6 +87,11 @@
|
||||
<TextBox x:Name="TransferDateInput" Grid.Column="2" Width="77" HorizontalAlignment="Left" Margin="0,100,10,0"
|
||||
TextChanged="TransferDateInput_TextChanged"/>
|
||||
|
||||
<Label Content="Rebelzuschlag:" Margin="10,130,0,0" Grid.Column="1"/>
|
||||
<ctrl:UnitTextBox x:Name="WeightModifierInput" Grid.Column="2" Width="60" Margin="0,130,10,0" Unit="%"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
TextChanged="WeightModifierInput_TextChanged" LostFocus="WeightModifierInput_LostFocus"/>
|
||||
|
||||
<Label Content="Berücksichtigen:" Margin="90,70,10,10" Grid.Column="2"/>
|
||||
<CheckBox x:Name="ConsiderModifiersInput" Content="Zu-/Abschläge bei Lieferungen"
|
||||
Margin="110,95,10,10" Grid.Column="2" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
|
@ -20,6 +20,7 @@ namespace Elwig.Windows {
|
||||
public readonly bool SeasonLocked;
|
||||
private bool DataValid, DataChanged, NameChanged, CommentChanged, TransferDateValid, TransferDateChanged;
|
||||
private BillingData? BillingData;
|
||||
private bool WeightModifierChanged = false;
|
||||
|
||||
private static readonly JsonSerializerOptions JsonOpt = new() { WriteIndented = true };
|
||||
|
||||
@ -70,6 +71,13 @@ namespace Elwig.Windows {
|
||||
ConsiderPenaltiesInput.IsChecked = BillingData.ConsiderContractPenalties;
|
||||
ConsiderPenaltyInput.IsChecked = BillingData.ConsiderTotalPenalty;
|
||||
ConsiderAutoInput.IsChecked = BillingData.ConsiderAutoBusinessShares;
|
||||
if (BillingData.NetWeightModifier != 0) {
|
||||
WeightModifierInput.Text = $"{Math.Round(BillingData.NetWeightModifier * 100.0, 8)}";
|
||||
} else if (BillingData.GrossWeightModifier != 0) {
|
||||
WeightModifierInput.Text = $"{Math.Round(BillingData.GrossWeightModifier * 100.0, 8)}";
|
||||
} else {
|
||||
WeightModifierInput.Text = "";
|
||||
}
|
||||
DataInput.Text = JsonSerializer.Serialize(BillingData.Data, JsonOpt);
|
||||
} catch {
|
||||
BillingData = null;
|
||||
@ -77,8 +85,10 @@ namespace Elwig.Windows {
|
||||
ConsiderPenaltiesInput.IsChecked = false;
|
||||
ConsiderPenaltyInput.IsChecked = false;
|
||||
ConsiderAutoInput.IsChecked = false;
|
||||
WeightModifierInput.Text = "";
|
||||
DataInput.Text = v.Data;
|
||||
}
|
||||
WeightModifierInput.TextBox.IsReadOnly = false;
|
||||
ConsiderModifiersInput.IsEnabled = !locked;
|
||||
ConsiderPenaltiesInput.IsEnabled = !locked;
|
||||
ConsiderPenaltyInput.IsEnabled = !locked;
|
||||
@ -109,6 +119,8 @@ namespace Elwig.Windows {
|
||||
DateInput.IsReadOnly = true;
|
||||
TransferDateInput.Text = "";
|
||||
TransferDateInput.IsReadOnly = true;
|
||||
WeightModifierInput.Text = "";
|
||||
WeightModifierInput.TextBox.IsReadOnly = true;
|
||||
ConsiderModifiersInput.IsChecked = false;
|
||||
ConsiderModifiersInput.IsEnabled = false;
|
||||
ConsiderPenaltiesInput.IsChecked = false;
|
||||
@ -131,7 +143,8 @@ namespace Elwig.Windows {
|
||||
(ConsiderModifiersInput.IsChecked != BillingData?.ConsiderDelieryModifiers) ||
|
||||
(ConsiderPenaltiesInput.IsChecked != BillingData?.ConsiderContractPenalties) ||
|
||||
(ConsiderPenaltyInput.IsChecked != BillingData?.ConsiderTotalPenalty) ||
|
||||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares));
|
||||
(ConsiderAutoInput.IsChecked != BillingData?.ConsiderAutoBusinessShares) ||
|
||||
WeightModifierChanged);
|
||||
CalculateButton.IsEnabled = !SaveButton.IsEnabled && PaymentVariantList.SelectedItem is PaymentVar { TestVariant: true };
|
||||
CommitButton.IsEnabled = CalculateButton.IsEnabled;
|
||||
}
|
||||
@ -362,6 +375,10 @@ namespace Elwig.Windows {
|
||||
d.ConsiderContractPenalties = ConsiderPenaltiesInput.IsChecked ?? false;
|
||||
d.ConsiderTotalPenalty = ConsiderPenaltyInput.IsChecked ?? false;
|
||||
d.ConsiderAutoBusinessShares = ConsiderAutoInput.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;
|
||||
WeightModifierChanged = false;
|
||||
v.Data = JsonSerializer.Serialize(d.Data);
|
||||
Context.Update(v);
|
||||
await Context.SaveChangesAsync();
|
||||
@ -371,6 +388,7 @@ namespace Elwig.Windows {
|
||||
ConsiderPenaltiesInput_Changed(null, null);
|
||||
ConsiderPenaltyInput_Changed(null, null);
|
||||
ConsiderAutoInput_Changed(null, null);
|
||||
WeightModifierInput_TextChanged(null, null);
|
||||
} catch (Exception exc) {
|
||||
await HintContextChange();
|
||||
var str = "Der Eintrag konnte nicht in der Datenbank aktualisiert werden!\n\n" + exc.Message;
|
||||
@ -511,5 +529,27 @@ namespace Elwig.Windows {
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void WeightModifierInput_TextChanged(object? sender, TextChangedEventArgs? evt) {
|
||||
var res = Validator.CheckDecimal(WeightModifierInput.TextBox, false, 3, 2, true);
|
||||
if (BillingData == null) {
|
||||
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
|
||||
return;
|
||||
}
|
||||
var val = WeightModifierInput.Text.Length > 0 && res.IsValid ? double.Parse(WeightModifierInput.Text) : 0;
|
||||
WeightModifierChanged = (val != Math.Round(BillingData.NetWeightModifier * 100.0, 8) && val != Math.Round(BillingData.GrossWeightModifier * 100.0, 8)) ||
|
||||
(val == 0 && (BillingData.NetWeightModifier != 0 || BillingData.GrossWeightModifier != 0));
|
||||
if (WeightModifierChanged) {
|
||||
ControlUtils.SetInputChanged(WeightModifierInput.TextBox);
|
||||
} else {
|
||||
ControlUtils.ClearInputState(WeightModifierInput.TextBox);
|
||||
}
|
||||
UpdateSaveButton();
|
||||
}
|
||||
|
||||
private void WeightModifierInput_LostFocus(object sender, RoutedEventArgs evt) {
|
||||
if (WeightModifierInput.Text.EndsWith(','))
|
||||
WeightModifierInput.Text = WeightModifierInput.Text[..^1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user