MailWindow: Add feature to address members with ancmts on specific day
All checks were successful
Test / Run tests (push) Successful in 2m28s
All checks were successful
Test / Run tests (push) Successful in 2m28s
This commit is contained in:
@ -29,6 +29,9 @@ namespace Elwig.Models.Entities {
|
||||
[Column("description")]
|
||||
public required string Description { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string Identifier => $"{Date:dd.MM.} - {ZwstId} - {Description}";
|
||||
|
||||
[Column("max_weight")]
|
||||
public int? MaxWeight { get; set; }
|
||||
[NotMapped]
|
||||
|
@ -167,6 +167,9 @@ namespace Elwig.Models.Entities {
|
||||
[InverseProperty(nameof(BillingAddr.Member))]
|
||||
public virtual BillingAddr? BillingAddress { get; private set; }
|
||||
|
||||
[InverseProperty(nameof(Delivery.Member))]
|
||||
public virtual ICollection<DeliveryAncmt> Announcements { get; private set; } = null!;
|
||||
|
||||
[InverseProperty(nameof(Delivery.Member))]
|
||||
public virtual ICollection<Delivery> Deliveries { get; private set; } = null!;
|
||||
|
||||
|
@ -108,36 +108,67 @@
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsAreaComMembersInput" Content="Mitglieder mit Flächenbindung"
|
||||
Margin="10,30,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="RecipientsInput_Changed" Unchecked="RecipientsInput_Changed"/>
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsDeliveryMembersInput" Content="Lieferanten der Saison"
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsDeliveryAncmtMembersInput" Content="Mitglieder mit Anmeldung"
|
||||
Margin="10,50,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="RecipientsInput_Changed" Unchecked="RecipientsInput_Changed"/>
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsNonDeliveryMembersInput" Content="Nicht-Lieferanten der Saison"
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsDeliveryMembersInput" Content="Lieferanten der Saison"
|
||||
Margin="10,70,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="RecipientsInput_Changed" Unchecked="RecipientsInput_Changed"/>
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsCustomInput" Content="Benutzerdefiniert"
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsNonDeliveryMembersInput" Content="Nicht-Lieferanten der Saison"
|
||||
Margin="10,90,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="RecipientsInput_Changed" Unchecked="RecipientsInput_Changed"/>
|
||||
<RadioButton GroupName="Recipients" x:Name="RecipientsCustomInput" Content="Benutzerdefiniert"
|
||||
Margin="10,110,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="RecipientsInput_Changed" Unchecked="RecipientsInput_Changed"/>
|
||||
|
||||
<Label Content="Zwst.:" x:Name="MemberBranchLabel" Margin="10,120,0,10"/>
|
||||
<Label Content="Zwst.:" x:Name="MemberBranchLabel" Margin="10,140,0,10"/>
|
||||
<ctrl:CheckComboBox x:Name="MemberBranchInput" AllItemsSelectedContent="Alle Stammzweigstellen" Delimiter=", " DisplayMemberPath="Name"
|
||||
Margin="50,120,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
Margin="50,140,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
SelectionChanged="MemberInput_SelectionChanged"/>
|
||||
|
||||
<Label Content="Gem.:" x:Name="MemberKgLabel" Margin="10,150,0,10"/>
|
||||
<Label Content="Gem.:" x:Name="MemberKgLabel" Margin="10,170,0,10"/>
|
||||
<ctrl:CheckComboBox x:Name="MemberKgInput" AllItemsSelectedContent="Alle Stammgemeinden" Delimiter=", " DisplayMemberPath="Name"
|
||||
IsSelectAllActive="True" SelectAllContent="Alle Stammgemeinden"
|
||||
Margin="50,150,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
Margin="50,170,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
SelectionChanged="MemberInput_SelectionChanged"/>
|
||||
|
||||
<Label Content="Vtrg.:" x:Name="MemberAreaComLabel" Margin="10,180,0,10"/>
|
||||
<Label Content="Bio-Betrieb:" x:Name="MemberOrganicLabel" Margin="10,200,0,10"/>
|
||||
<RadioButton x:Name="MemberOrganicYesInput" Content="Ja" GroupName="MemberOrganic"
|
||||
Margin="80,205,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="MemberInput_Checked"/>
|
||||
<RadioButton x:Name="MemberOrganicNoInput" Content="Nein" GroupName="MemberOrganic"
|
||||
Margin="125,205,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="MemberInput_Checked"/>
|
||||
<RadioButton x:Name="MemberOrganicIndifferentInput" Content="Egal" GroupName="MemberOrganic"
|
||||
Margin="180,205,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="MemberInput_Checked"/>
|
||||
|
||||
<Label Content="Funktionär:" x:Name="MemberFunktionärLabel" Margin="10,230,0,10"/>
|
||||
<RadioButton x:Name="MemberFunktionärYesInput" Content="Ja" GroupName="MemberFunktionär"
|
||||
Margin="80,235,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="MemberInput_Checked"/>
|
||||
<RadioButton x:Name="MemberFunktionärNoInput" Content="Nein" GroupName="MemberFunktionär"
|
||||
Margin="125,235,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="MemberInput_Checked"/>
|
||||
<RadioButton x:Name="MemberFunktionärIndifferentInput" Content="Egal" GroupName="MemberFunktionär"
|
||||
Margin="180,235,10,10" VerticalAlignment="Top" HorizontalAlignment="Left"
|
||||
Checked="MemberInput_Checked"/>
|
||||
|
||||
<Label Content="Vtrg.:" x:Name="MemberAreaComLabel" Margin="10,260,0,10"/>
|
||||
<ctrl:CheckComboBox x:Name="MemberAreaComInput" AllItemsSelectedContent="Alle Vertragsarten" Delimiter=", " DisplayMemberPath="VtrgId"
|
||||
IsSelectAllActive="True" SelectAllContent="Alle Vertragsarten"
|
||||
Margin="50,180,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
Margin="50,260,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
SelectionChanged="MemberInput_SelectionChanged"/>
|
||||
|
||||
<Label Content="Tag:" x:Name="MemberDeliveryAncmtLabel" Margin="10,260,0,10"/>
|
||||
<ctrl:CheckComboBox x:Name="MemberDeliveryAncmtInput" AllItemsSelectedContent="Alle Lesepläne" Delimiter=", " DisplayMemberPath="Identifier"
|
||||
IsSelectAllActive="True" SelectAllContent="Alle Lesepläne"
|
||||
Margin="50,260,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
SelectionChanged="MemberInput_SelectionChanged"/>
|
||||
|
||||
<ctrl:CheckComboBox x:Name="MemberCustomInput" AllItemsSelectedContent="Alle Mitglieder" Delimiter=", " DisplayMemberPath="AdministrativeName"
|
||||
IsSelectAllActive="True" SelectAllContent="Alle Mitglieder"
|
||||
Margin="10,120,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
Margin="10,140,10,10" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="25"
|
||||
SelectionChanged="MemberInput_SelectionChanged"/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
@ -116,6 +116,9 @@ namespace Elwig.Windows {
|
||||
CreditNoteFooterInput.Visibility = Visibility.Hidden;
|
||||
RecipientsActiveMembersInput.IsChecked = true;
|
||||
|
||||
MemberOrganicIndifferentInput.IsChecked = true;
|
||||
MemberFunktionärIndifferentInput.IsChecked = true;
|
||||
|
||||
DeliveryConfirmationFooterInput.Text = App.Client.TextDeliveryConfirmation;
|
||||
CreditNoteFooterInput.Text = App.Client.TextCreditNote;
|
||||
|
||||
@ -164,6 +167,17 @@ namespace Elwig.Windows {
|
||||
MemberAreaComInput.SelectAll();
|
||||
MemberAreaComInput.SelectionChanged += MemberInput_SelectionChanged;
|
||||
}
|
||||
ControlUtils.RenewItemsSource(MemberDeliveryAncmtInput, await ctx.DeliverySchedules
|
||||
.Where(s => s.Year == Year)
|
||||
.OrderBy(s => s.DateString)
|
||||
.ThenBy(s => s.Branch.Name)
|
||||
.ThenBy(s => s.Description)
|
||||
.ToListAsync(), MemberInput_SelectionChanged);
|
||||
if (MemberDeliveryAncmtInput.SelectedItems.Count == 0) {
|
||||
MemberDeliveryAncmtInput.SelectionChanged -= MemberInput_SelectionChanged;
|
||||
MemberDeliveryAncmtInput.SelectAll();
|
||||
MemberDeliveryAncmtInput.SelectionChanged += MemberInput_SelectionChanged;
|
||||
}
|
||||
ControlUtils.RenewItemsSource(MemberCustomInput, await ctx.Members
|
||||
.Where(m => m.IsActive)
|
||||
.OrderBy(m => m.Name)
|
||||
@ -291,8 +305,18 @@ namespace Elwig.Windows {
|
||||
MemberBranchInput.Visibility = vis;
|
||||
MemberKgLabel.Visibility = vis;
|
||||
MemberKgInput.Visibility = vis;
|
||||
MemberOrganicLabel.Visibility = vis;
|
||||
MemberOrganicYesInput.Visibility = vis;
|
||||
MemberOrganicNoInput.Visibility = vis;
|
||||
MemberOrganicIndifferentInput.Visibility = vis;
|
||||
MemberFunktionärLabel.Visibility = vis;
|
||||
MemberFunktionärYesInput.Visibility = vis;
|
||||
MemberFunktionärNoInput.Visibility = vis;
|
||||
MemberFunktionärIndifferentInput.Visibility = vis;
|
||||
MemberAreaComInput.Visibility = RecipientsAreaComMembersInput.IsChecked == true ? Visibility.Visible : Visibility.Hidden;
|
||||
MemberAreaComLabel.Visibility = RecipientsAreaComMembersInput.IsChecked == true ? Visibility.Visible : Visibility.Hidden;
|
||||
MemberDeliveryAncmtInput.Visibility = RecipientsDeliveryAncmtMembersInput.IsChecked == true ? Visibility.Visible : Visibility.Hidden;
|
||||
MemberDeliveryAncmtLabel.Visibility = RecipientsDeliveryAncmtMembersInput.IsChecked == true ? Visibility.Visible : Visibility.Hidden;
|
||||
MemberCustomInput.Visibility = RecipientsCustomInput.IsChecked == true ? Visibility.Visible : Visibility.Hidden;
|
||||
using var ctx = new AppDbContext();
|
||||
await UpdateRecipients(ctx);
|
||||
@ -303,6 +327,11 @@ namespace Elwig.Windows {
|
||||
await UpdateRecipients(ctx);
|
||||
}
|
||||
|
||||
private async void MemberInput_Checked(object sender, RoutedEventArgs evt) {
|
||||
using var ctx = new AppDbContext();
|
||||
await UpdateRecipients(ctx);
|
||||
}
|
||||
|
||||
private void Date_TextChanged(object sender, RoutedEventArgs evt) {
|
||||
Validator.CheckDate((TextBox)sender, true);
|
||||
}
|
||||
@ -325,10 +354,23 @@ namespace Elwig.Windows {
|
||||
var kgs = MemberKgInput.SelectedItems.Cast<AT_Kg>().Select(k => k.KgNr).ToList();
|
||||
query = query.Where(m => kgs.Contains((int)m.DefaultKgNr!));
|
||||
}
|
||||
if (MemberOrganicYesInput.IsChecked == true) {
|
||||
query = query.Where(m => m.IsOrganic);
|
||||
} else if (MemberOrganicNoInput.IsChecked == true) {
|
||||
query = query.Where(m => !m.IsOrganic);
|
||||
}
|
||||
if (MemberFunktionärYesInput.IsChecked == true) {
|
||||
query = query.Where(m => m.IsFunktionär);
|
||||
} else if (MemberFunktionärNoInput.IsChecked == true) {
|
||||
query = query.Where(m => !m.IsFunktionär);
|
||||
}
|
||||
|
||||
if (RecipientsAreaComMembersInput.IsChecked == true) {
|
||||
var vtrg = MemberAreaComInput.SelectedItems.Cast<AreaComType>().Select(a => a.VtrgId).ToList();
|
||||
query = query.Where(m => m.IsActive && m.AreaCommitments.AsQueryable().Where(Utils.ActiveAreaCommitments(Year)).Any(c => vtrg.Contains(c.VtrgId)));
|
||||
} else if (RecipientsDeliveryAncmtMembersInput.IsChecked == true) {
|
||||
var dsnrs = MemberDeliveryAncmtInput.SelectedItems.Cast<DeliverySchedule>().Select(s => s.DsNr).ToList();
|
||||
query = query.Where(m => m.Announcements.Any(a => a.Year == Year && dsnrs.Contains(a.DsNr)));
|
||||
} else if (RecipientsDeliveryMembersInput.IsChecked == true) {
|
||||
query = query.Where(m => m.Deliveries.Any(d => d.Year == Year));
|
||||
} else if (RecipientsNonDeliveryMembersInput.IsChecked == true) {
|
||||
|
Reference in New Issue
Block a user