Dtos: Rename CreditNote and DeliveryConfirmation DTOs
This commit is contained in:
@ -11,7 +11,7 @@ namespace Elwig.Documents {
|
||||
|
||||
public PaymentMember? Payment;
|
||||
public Credit? Credit;
|
||||
public CreditNoteData Data;
|
||||
public CreditNoteDeliveryData Data;
|
||||
public string? Text;
|
||||
public string CurrencySymbol;
|
||||
public int Precision;
|
||||
@ -20,7 +20,7 @@ namespace Elwig.Documents {
|
||||
public decimal MemberTotalUnderDelivery;
|
||||
public decimal MemberAutoBusinessShares;
|
||||
|
||||
public CreditNote(AppDbContext ctx, PaymentMember p, CreditNoteData data, Dictionary<string, UnderDelivery>? underDeliveries = null) :
|
||||
public CreditNote(AppDbContext ctx, PaymentMember p, CreditNoteDeliveryData data, Dictionary<string, UnderDelivery>? underDeliveries = null) :
|
||||
base($"{Name} {(p.Credit != null ? $"Nr. {p.Credit.Year}/{p.Credit.TgNr:000}" : p.Member.Name)} – {p.Variant.Name}", p.Member) {
|
||||
UseBillingAddress = true;
|
||||
ShowDateAndLocation = true;
|
||||
|
@ -10,11 +10,11 @@ namespace Elwig.Documents {
|
||||
public new static string Name => "Anlieferungsbestätigung";
|
||||
|
||||
public Season Season;
|
||||
public DeliveryConfirmationData Data;
|
||||
public DeliveryConfirmationDeliveryData Data;
|
||||
public string? Text = App.Client.TextDeliveryConfirmation;
|
||||
public Dictionary<string, MemberBucket> MemberBuckets;
|
||||
|
||||
public DeliveryConfirmation(AppDbContext ctx, int year, Member m, DeliveryConfirmationData data) :
|
||||
public DeliveryConfirmation(AppDbContext ctx, int year, Member m, DeliveryConfirmationDeliveryData data) :
|
||||
base($"{Name} {year}", m) {
|
||||
Season = ctx.Seasons.Find(year) ?? throw new ArgumentException("invalid season");
|
||||
ShowDateAndLocation = true;
|
||||
|
@ -6,7 +6,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elwig.Models.Dtos {
|
||||
public class CreditNoteData : DataTable<CreditNoteRow> {
|
||||
public class CreditNoteDeliveryData : DataTable<CreditNoteDeliveryRow> {
|
||||
|
||||
private static readonly (string, string, string?)[] FieldNames = new[] {
|
||||
("", "", (string?)null), // TODO
|
||||
@ -17,7 +17,7 @@ namespace Elwig.Models.Dtos {
|
||||
private readonly int? AvNr;
|
||||
private readonly int? MgNr;
|
||||
|
||||
private CreditNoteData(IEnumerable<CreditNoteRow> rows, int year, int? tgnr, int? avnr = null, int? mgnr = null) :
|
||||
private CreditNoteDeliveryData(IEnumerable<CreditNoteDeliveryRow> rows, int year, int? tgnr, int? avnr = null, int? mgnr = null) :
|
||||
base($"Traubengutschrift {year}/{tgnr}", rows, FieldNames) {
|
||||
Year = year;
|
||||
TgNr = tgnr;
|
||||
@ -25,14 +25,14 @@ namespace Elwig.Models.Dtos {
|
||||
MgNr = mgnr;
|
||||
}
|
||||
|
||||
public static async Task<IDictionary<int, CreditNoteData>> ForPaymentVariant(DbSet<CreditNoteRowSingle> table, DbSet<Season> seasons, int year, int avnr) {
|
||||
public static async Task<IDictionary<int, CreditNoteDeliveryData>> ForPaymentVariant(DbSet<CreditNoteRowSingle> table, DbSet<Season> seasons, int year, int avnr) {
|
||||
return (await FromDbSet(table, year, avnr))
|
||||
.GroupBy(
|
||||
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr, r.DId, r.DPNr },
|
||||
(k, g) => new CreditNoteRow(g, seasons))
|
||||
(k, g) => new CreditNoteDeliveryRow(g, seasons))
|
||||
.GroupBy(
|
||||
r => new { r.Year, r.AvNr, r.MgNr, r.TgNr },
|
||||
(k, g) => new CreditNoteData(g, k.Year, k.TgNr, mgnr: k.MgNr))
|
||||
(k, g) => new CreditNoteDeliveryData(g, k.Year, k.TgNr, mgnr: k.MgNr))
|
||||
.ToDictionary(d => d.MgNr ?? 0);
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ namespace Elwig.Models.Dtos {
|
||||
}
|
||||
}
|
||||
|
||||
public class CreditNoteRow {
|
||||
public class CreditNoteDeliveryRow {
|
||||
|
||||
public int Year;
|
||||
public int? TgNr;
|
||||
@ -77,7 +77,7 @@ namespace Elwig.Models.Dtos {
|
||||
public decimal? TotalModifiers;
|
||||
public decimal? Amount;
|
||||
|
||||
public CreditNoteRow(IEnumerable<CreditNoteRowSingle> rows, DbSet<Season> seasons) {
|
||||
public CreditNoteDeliveryRow(IEnumerable<CreditNoteRowSingle> rows, DbSet<Season> seasons) {
|
||||
var f = rows.First();
|
||||
Year = f.Year;
|
||||
TgNr = f.TgNr;
|
@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Elwig.Models.Dtos {
|
||||
public class DeliveryConfirmationData : DataTable<DeliveryConfirmationRow> {
|
||||
public class DeliveryConfirmationDeliveryData : DataTable<DeliveryConfirmationDeliveryRow> {
|
||||
|
||||
private static readonly (string, string, string?, int)[] FieldNames = new[] {
|
||||
("LsNr", "LsNr.", null, 26),
|
||||
@ -21,26 +21,26 @@ namespace Elwig.Models.Dtos {
|
||||
|
||||
private readonly int MgNr;
|
||||
|
||||
private DeliveryConfirmationData(IEnumerable<DeliveryConfirmationRow> rows, int year, Member m) :
|
||||
private DeliveryConfirmationDeliveryData(IEnumerable<DeliveryConfirmationDeliveryRow> rows, int year, Member m) :
|
||||
base($"Anlieferungsbestätigung", $"Anlieferungsbestätigung {year} – {m.AdministrativeName}", rows, FieldNames) {
|
||||
MgNr = m.MgNr;
|
||||
}
|
||||
|
||||
public static DeliveryConfirmationData CreateEmpty(int year, Member m) {
|
||||
public static DeliveryConfirmationDeliveryData CreateEmpty(int year, Member m) {
|
||||
return new([], year, m);
|
||||
}
|
||||
|
||||
public static async Task<IDictionary<int, DeliveryConfirmationData>> ForSeason(DbSet<DeliveryPart> table, int year) {
|
||||
public static async Task<IDictionary<int, DeliveryConfirmationDeliveryData>> ForSeason(DbSet<DeliveryPart> table, int year) {
|
||||
return (await FromDbSet(table, year))
|
||||
.GroupBy(
|
||||
p => p.Delivery.Member,
|
||||
p => new DeliveryConfirmationRow(p),
|
||||
(k, g) => new DeliveryConfirmationData(g, year, k)
|
||||
p => new DeliveryConfirmationDeliveryRow(p),
|
||||
(k, g) => new DeliveryConfirmationDeliveryData(g, year, k)
|
||||
).ToDictionary(d => d.MgNr, d => d);
|
||||
}
|
||||
|
||||
public static async Task<DeliveryConfirmationData> ForMember(DbSet<DeliveryPart> table, int year, Member m) {
|
||||
return new DeliveryConfirmationData((await FromDbSet(table, year, m.MgNr)).Select(p => new DeliveryConfirmationRow(p)), year, m);
|
||||
public static async Task<DeliveryConfirmationDeliveryData> ForMember(DbSet<DeliveryPart> table, int year, Member m) {
|
||||
return new DeliveryConfirmationDeliveryData((await FromDbSet(table, year, m.MgNr)).Select(p => new DeliveryConfirmationDeliveryRow(p)), year, m);
|
||||
}
|
||||
|
||||
private static async Task<IEnumerable<DeliveryPart>> FromDbSet(DbSet<DeliveryPart> table, int? year = null, int? mgnr = null) {
|
||||
@ -68,7 +68,7 @@ namespace Elwig.Models.Dtos {
|
||||
}
|
||||
}
|
||||
|
||||
public class DeliveryConfirmationRow {
|
||||
public class DeliveryConfirmationDeliveryRow {
|
||||
public string LsNr;
|
||||
public int DPNr;
|
||||
public string Variety;
|
||||
@ -79,7 +79,7 @@ namespace Elwig.Models.Dtos {
|
||||
public int Weight;
|
||||
public (string Name, int Value)[] Buckets;
|
||||
|
||||
public DeliveryConfirmationRow(DeliveryPart p) {
|
||||
public DeliveryConfirmationDeliveryRow(DeliveryPart p) {
|
||||
var d = p.Delivery;
|
||||
LsNr = d.LsNr;
|
||||
DPNr = p.DPNr;
|
@ -74,9 +74,9 @@ namespace Elwig.Dialogs {
|
||||
}
|
||||
|
||||
IEnumerable<Member> list = await members.ToListAsync();
|
||||
var data = await DeliveryConfirmationData.ForSeason(Context.DeliveryParts, Year);
|
||||
var data = await DeliveryConfirmationDeliveryData.ForSeason(Context.DeliveryParts, Year);
|
||||
using var doc = Document.Merge(list.Select(m =>
|
||||
new DeliveryConfirmation(Context, Year, m, data.TryGetValue(m.MgNr, out var d) ? d : DeliveryConfirmationData.CreateEmpty(Year, m)) {
|
||||
new DeliveryConfirmation(Context, Year, m, data.TryGetValue(m.MgNr, out var d) ? d : DeliveryConfirmationDeliveryData.CreateEmpty(Year, m)) {
|
||||
//DoubleSided = true
|
||||
}
|
||||
));
|
||||
|
@ -488,7 +488,7 @@ namespace Elwig.Windows {
|
||||
members = members.OrderBy(m => m.MgNr);
|
||||
|
||||
IEnumerable<Member> list = await members.ToListAsync();
|
||||
var data = await CreditNoteData.ForPaymentVariant(Context.CreditNoteRows, Context.Seasons, v.Year, v.AvNr);
|
||||
var data = await CreditNoteDeliveryData.ForPaymentVariant(Context.CreditNoteRows, Context.Seasons, v.Year, v.AvNr);
|
||||
var payments = await Context.MemberPayments.Where(p => p.Year == v.Year && p.AvNr == v.AvNr).ToDictionaryAsync(c => c.MgNr);
|
||||
await Context.GetMemberAreaCommitmentBuckets(Year, 0);
|
||||
using var doc = Document.Merge(list.Select(m =>
|
||||
|
@ -48,7 +48,7 @@ namespace Elwig.Windows {
|
||||
private async void ZipButton_Click(object sender, RoutedEventArgs evt) {
|
||||
using var ctx = new AppDbContext();
|
||||
using var ods = new OdsFile(@"C:\Users\Lorenz\Desktop\test.ods");
|
||||
await ods.AddTable(await DeliveryConfirmationData.ForMember(ctx.DeliveryParts, 2023, ctx.Members.Find(2948)));
|
||||
await ods.AddTable(await DeliveryConfirmationDeliveryData.ForMember(ctx.DeliveryParts, 2023, ctx.Members.Find(2948)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user