[#32] Dtos/PaymentVariantSummaryData: Allow Data to be exported as Ods
This commit is contained in:
@ -47,9 +47,9 @@
|
||||
.ToList();
|
||||
<tr class="subheading @(hdr != lastHdr && lastHdr != null ? "new" : "")">
|
||||
<th colspan="2">@hdr</th>
|
||||
<td class="number">@($"{rows.Sum(r => r.WeightUngeb):N0}")</td>
|
||||
<td class="number">@($"{rows.Sum(r => r.Ungeb.Weight):N0}")</td>
|
||||
<td></td>
|
||||
<td class="number">@($"{rows.Sum(r => r.WeightGeb):N0}")</td>
|
||||
<td class="number">@($"{rows.Sum(r => r.Geb.Weight):N0}")</td>
|
||||
<td></td>
|
||||
<td class="number">@($"{rows.Sum(r => r.Amount):N2}")</td>
|
||||
</tr>
|
||||
@ -57,10 +57,10 @@
|
||||
<tr>
|
||||
<td>@(row.QualityLevel)</td>
|
||||
<td class="center">@($"{row.Oe:N0}")</td>
|
||||
<td class="number">@(row.WeightUngeb != 0 ? $"{row.WeightUngeb:N0}" : "-")</td>
|
||||
<td class="number">@(row.PriceUngeb != null ? $"{row.PriceUngeb:N4}" : "-")</td>
|
||||
<td class="number">@(row.WeightGeb != 0 ? $"{row.WeightGeb:N0}" : "-")</td>
|
||||
<td class="number">@(row.PriceGeb != null ? $"{row.PriceGeb:N4}" : "-")</td>
|
||||
<td class="number">@(row.Ungeb.Weight != 0 ? $"{row.Ungeb.Weight:N0}" : "-")</td>
|
||||
<td class="number">@(row.Ungeb.Price != null ? $"{row.Ungeb.Price:N4}" : "-")</td>
|
||||
<td class="number">@(row.Geb.Weight != 0 ? $"{row.Geb.Weight:N0}" : "-")</td>
|
||||
<td class="number">@(row.Geb.Price != null ? $"{row.Geb.Price:N4}" : "-")</td>
|
||||
<td class="number">@($"{row.Amount:N2}")</td>
|
||||
</tr>
|
||||
lastHdr = hdr;
|
||||
|
@ -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;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -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<PaymentVariantSummaryData.PaymentRow> {
|
||||
|
||||
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<PaymentRow> rows) :
|
||||
base(PaymentVariantSummary.Name, PaymentVariantSummary.Name, v.Name, rows, FieldNames) {
|
||||
}
|
||||
|
||||
public static async Task<PaymentVariantSummaryData> ForPaymentVariant(PaymentVar v, DbSet<PaymentVariantSummaryRow> 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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user