Dtos: Rename CreditNote and DeliveryConfirmation DTOs

This commit is contained in:
2024-01-28 22:52:23 +01:00
parent 8665c93702
commit 6bcb2fb406
7 changed files with 25 additions and 25 deletions

View File

@ -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;

View File

@ -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;