Billing: Rename attributeVariants and contracts to vaributes
This commit is contained in:
@ -84,18 +84,18 @@ namespace Elwig.Windows {
|
||||
PaymentVar = await Context.PaymentVariants.FindAsync(Year, AvNr) ?? throw new ArgumentException("PaymentVar not found");
|
||||
Season = await Context.Seasons.FindAsync(Year) ?? throw new ArgumentException("Season not found");
|
||||
|
||||
var data = EditBillingData.FromJson(PaymentVar.Data, Utils.GetAttributeVarieties(Context, Year));
|
||||
var data = EditBillingData.FromJson(PaymentVar.Data, Utils.GetVaributes(Context, Year));
|
||||
var paymentEntries = data.GetPaymentGraphEntries(Context, Season);
|
||||
GraphEntries = [
|
||||
..paymentEntries,
|
||||
..data.GetQualityGraphEntries(Context, Season, paymentEntries.Max(e => e.Id))
|
||||
];
|
||||
|
||||
var contracts = Utils.GetContractsForYear(Context, Year);
|
||||
var vaributes = Utils.GetVaributesForYear(Context, Year);
|
||||
FillingInputs = true;
|
||||
ControlUtils.RenewItemsSource(ContractInput, contracts, g => (g as ContractSelection)?.Listing);
|
||||
ControlUtils.RenewItemsSource(VaributeInput, vaributes, g => (g as Varibute)?.Listing);
|
||||
FillingInputs = false;
|
||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.ContractsStringChange, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||
ControlUtils.RenewItemsSource(GraphList, GraphEntries, g => (g as GraphEntry)?.VaributeStringChange, GraphList_SelectionChanged, ControlUtils.RenewSourceDefault.First);
|
||||
|
||||
RefreshInputs();
|
||||
}
|
||||
@ -108,7 +108,7 @@ namespace Elwig.Windows {
|
||||
GebundenTypeFixed.IsEnabled = true;
|
||||
GebundenTypeGraph.IsEnabled = true;
|
||||
GebundenTypeNone.IsEnabled = true;
|
||||
ContractInput.IsEnabled = true;
|
||||
VaributeInput.IsEnabled = true;
|
||||
AbgewertetInput.IsEnabled = true;
|
||||
EnableOptionButtons();
|
||||
FillInputs();
|
||||
@ -127,7 +127,7 @@ namespace Elwig.Windows {
|
||||
GebundenTypeFixed.IsEnabled = false;
|
||||
GebundenTypeGraph.IsEnabled = false;
|
||||
GebundenTypeNone.IsEnabled = false;
|
||||
ContractInput.IsEnabled = false;
|
||||
VaributeInput.IsEnabled = false;
|
||||
AbgewertetInput.IsEnabled = false;
|
||||
}
|
||||
GC.Collect();
|
||||
@ -148,7 +148,7 @@ namespace Elwig.Windows {
|
||||
GebundenFlatBonus.Text = "";
|
||||
}
|
||||
|
||||
ControlUtils.SelectCheckComboBoxItems(ContractInput, SelectedGraphEntry?.Contracts ?? [], i => (i as ContractSelection)?.Listing);
|
||||
ControlUtils.SelectCheckComboBoxItems(VaributeInput, SelectedGraphEntry?.Vaributes ?? [], i => (i as Varibute)?.Listing);
|
||||
|
||||
InitPlot();
|
||||
OechslePricePlot.IsEnabled = true;
|
||||
@ -622,7 +622,7 @@ namespace Elwig.Windows {
|
||||
if (SelectedGraphEntry == null) return;
|
||||
|
||||
var r = MessageBox.Show(
|
||||
$"Soll der Graph {SelectedGraphEntry.Id} (verwendet in folgenden Verträgen: {SelectedGraphEntry.ContractsStringSimple}) wirklich gelöscht werden?",
|
||||
$"Soll der Graph {SelectedGraphEntry.Id} (verwendet in folgenden Verträgen: {SelectedGraphEntry.VaributeStringSimple}) wirklich gelöscht werden?",
|
||||
"Graph löschen", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
|
||||
if (r == MessageBoxResult.Yes) {
|
||||
@ -635,7 +635,7 @@ namespace Elwig.Windows {
|
||||
|
||||
private async void SaveButton_Click(object sender, RoutedEventArgs e) {
|
||||
var origData = BillingData.FromJson(PaymentVar.Data);
|
||||
var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetAttributeVarieties(Context, Year, withSlash: true));
|
||||
var data = BillingData.FromGraphEntries(GraphEntries, origData, Utils.GetVaributes(Context, Year, withSlash: true));
|
||||
|
||||
EntityEntry<PaymentVar>? tr = null;
|
||||
try {
|
||||
@ -715,32 +715,32 @@ namespace Elwig.Windows {
|
||||
}
|
||||
}
|
||||
|
||||
private void ContractInput_Changed(object sender, ItemSelectionChangedEventArgs e) {
|
||||
private void VaributeInput_Changed(object sender, ItemSelectionChangedEventArgs e) {
|
||||
if (FillingInputs) return;
|
||||
if (e.IsSelected == true) {
|
||||
bool success = RemoveContractFromOtherGraphEntries(e.Item.ToString());
|
||||
bool success = RemoveVaributeFromOtherGraphEntries(e.Item.ToString());
|
||||
if (!success) {
|
||||
ContractInput.SelectedItems.Remove(e.Item);
|
||||
VaributeInput.SelectedItems.Remove(e.Item);
|
||||
}
|
||||
}
|
||||
var r = ContractInput.SelectedItems.Cast<ContractSelection>();
|
||||
SelectedGraphEntry!.Contracts = r.ToList();
|
||||
var r = VaributeInput.SelectedItems.Cast<Varibute>();
|
||||
SelectedGraphEntry!.Vaributes = r.ToList();
|
||||
SetHasChanged();
|
||||
GraphList.Items.Refresh();
|
||||
}
|
||||
|
||||
private bool RemoveContractFromOtherGraphEntries(string? contract) {
|
||||
if (contract == null) return true;
|
||||
private bool RemoveVaributeFromOtherGraphEntries(string? varibute) {
|
||||
if (varibute == null) return true;
|
||||
foreach (var ge in GraphEntries) {
|
||||
if (ge != SelectedGraphEntry && ge.Abgewertet == SelectedGraphEntry?.Abgewertet) {
|
||||
var toRemove = ge.Contracts.Where(c => c.Listing.Equals(contract)).ToList();
|
||||
var toRemove = ge.Vaributes.Where(c => c.Listing.Equals(varibute)).ToList();
|
||||
if (toRemove.Count == 0) continue;
|
||||
var r = MessageBox.Show($"Achtung: {string.Join(", ", toRemove)} ist bereits in Graph {ge.Id} in Verwendung!\nSoll die Zuweisung dort entfernt werden?", "Entfernen bestätigen",
|
||||
MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No);
|
||||
if (r != MessageBoxResult.Yes) {
|
||||
return false;
|
||||
}
|
||||
ge.Contracts.RemoveAll(c => c.Listing.Equals(contract));
|
||||
ge.Vaributes.RemoveAll(c => c.Listing.Equals(varibute));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user