diff --git a/Elwig/Documents/PaymentVariantSummary.cshtml b/Elwig/Documents/PaymentVariantSummary.cshtml index 097c6fa..a32b6e3 100644 --- a/Elwig/Documents/PaymentVariantSummary.cshtml +++ b/Elwig/Documents/PaymentVariantSummary.cshtml @@ -47,9 +47,9 @@ .ToList(); @hdr - @($"{rows.Sum(r => r.WeightUngeb):N0}") + @($"{rows.Sum(r => r.Ungeb.Weight):N0}") - @($"{rows.Sum(r => r.WeightGeb):N0}") + @($"{rows.Sum(r => r.Geb.Weight):N0}") @($"{rows.Sum(r => r.Amount):N2}") @@ -57,10 +57,10 @@ @(row.QualityLevel) @($"{row.Oe:N0}") - @(row.WeightUngeb != 0 ? $"{row.WeightUngeb:N0}" : "-") - @(row.PriceUngeb != null ? $"{row.PriceUngeb:N4}" : "-") - @(row.WeightGeb != 0 ? $"{row.WeightGeb:N0}" : "-") - @(row.PriceGeb != null ? $"{row.PriceGeb:N4}" : "-") + @(row.Ungeb.Weight != 0 ? $"{row.Ungeb.Weight:N0}" : "-") + @(row.Ungeb.Price != null ? $"{row.Ungeb.Price:N4}" : "-") + @(row.Geb.Weight != 0 ? $"{row.Geb.Weight:N0}" : "-") + @(row.Geb.Price != null ? $"{row.Geb.Price:N4}" : "-") @($"{row.Amount:N2}") lastHdr = hdr; diff --git a/Elwig/Helpers/Export/Ods.cs b/Elwig/Helpers/Export/Ods.cs index f1d83f7..41fa609 100644 --- a/Elwig/Helpers/Export/Ods.cs +++ b/Elwig/Helpers/Export/Ods.cs @@ -302,6 +302,7 @@ namespace Elwig.Helpers.Export { switch (units[0]) { case "%": n = 1; data = $"{v:N1}"; break; case "€": n = 2; data = $"{v:N2}"; break; + case "€/kg": n = 4; data = $"{v:N4}"; break; case "°KMW": n = 1; data = $"{v:N1}"; break; case "°Oe": n = 0; data = $"{v:N0}"; break; case "m²": n = 0; data = $"{v:N0}"; break; diff --git a/Elwig/Models/Dtos/OverUnderDeliveryData.cs b/Elwig/Models/Dtos/OverUnderDeliveryData.cs index 5b47b3b..030f823 100644 --- a/Elwig/Models/Dtos/OverUnderDeliveryData.cs +++ b/Elwig/Models/Dtos/OverUnderDeliveryData.cs @@ -1,5 +1,4 @@ using Microsoft.EntityFrameworkCore; -using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Threading.Tasks; diff --git a/Elwig/Models/Dtos/PaymentVariantSummaryData.cs b/Elwig/Models/Dtos/PaymentVariantSummaryData.cs index 66cd341..ceb27a2 100644 --- a/Elwig/Models/Dtos/PaymentVariantSummaryData.cs +++ b/Elwig/Models/Dtos/PaymentVariantSummaryData.cs @@ -1,4 +1,5 @@ -using Elwig.Helpers; +using Elwig.Documents; +using Elwig.Helpers; using Elwig.Models.Entities; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; @@ -8,21 +9,41 @@ using System.Linq; using System.Threading.Tasks; namespace Elwig.Models.Dtos { - public class PaymentVariantSummaryData { + public class PaymentVariantSummaryData : DataTable { - public record struct PaymentRow(string Type, string Variety, string? Attribute, string? Cultivation, string QualityLevel, double Oe, int WeightUngeb, decimal? PriceUngeb, int WeightGeb, decimal? PriceGeb, decimal Amount); + private static readonly (string, string, string?, int?)[] FieldNames = [ + ("Type", "Typ", null, 10), + ("Variety", "Sorte", null, 40), + ("Attribute", "Attribut", null, 20), + ("Cultivation", "Bewirt.", null, 20), + ("QualityLevel", "Qualitätsstufe", null, 30), + ("Oe", "Gradation", "°Oe", 20), + ("Ungeb", "ungebunden", "kg|€/kg", 40), + ("Geb", "gebunden", "kg|€/kg", 40), + ("Amount", "Gesamt", "€", 25), + ]; - public PaymentRow[] Rows; + public record struct PaymentRow( + string Type, + string Variety, + string? Attribute, + string? Cultivation, + string QualityLevel, + double Oe, + (int Weight, decimal? Price) Ungeb, + (int Weight, decimal? Price) Geb, + decimal Amount + ); - public PaymentVariantSummaryData(PaymentRow[] rows) { - Rows = rows; + public PaymentVariantSummaryData(PaymentVar v, IEnumerable rows) : + base(PaymentVariantSummary.Name, PaymentVariantSummary.Name, v.Name, rows, FieldNames) { } public static async Task ForPaymentVariant(PaymentVar v, DbSet table) { - return new((await FromDbSet(table, v.Year, v.AvNr)) + return new(v, (await FromDbSet(table, v.Year, v.AvNr)) .Select(r => new PaymentRow(r.Type, r.Variety, r.Attribute, r.Cultivation, r.QualityLevel, r.Oe, - r.WeightUngeb, r.PriceUngeb != null ? Utils.DecFromDb(r.PriceUngeb.Value, v.Season.Precision) : null, - r.WeightGeb, r.PriceGeb != null ? Utils.DecFromDb(r.PriceGeb.Value, v.Season.Precision) : null, + (r.WeightUngeb, r.PriceUngeb != null ? Utils.DecFromDb(r.PriceUngeb.Value, v.Season.Precision) : null), + (r.WeightGeb, r.PriceGeb != null ? Utils.DecFromDb(r.PriceGeb.Value, v.Season.Precision) : null), Utils.DecFromDb(r.Amount, v.Season.Precision))) .ToArray()); }