Elwig: Rename (wine) variant to variety

This commit is contained in:
2024-01-27 11:36:43 +01:00
parent 519e903d1c
commit d3aca196dd
12 changed files with 30 additions and 29 deletions

View File

@ -55,13 +55,13 @@ namespace Elwig.Documents {
CurrencySymbol = season.Currency.Symbol ?? season.Currency.Code; CurrencySymbol = season.Currency.Symbol ?? season.Currency.Code;
Precision = season.Precision; Precision = season.Precision;
var variants = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v); var varieties = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a); var attributes = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
var comTypes = ctx.AreaCommitmentTypes.ToDictionary(t => t.VtrgId, t => t); var comTypes = ctx.AreaCommitmentTypes.ToDictionary(t => t.VtrgId, t => t);
MemberUnderDeliveries = underDeliveries? MemberUnderDeliveries = underDeliveries?
.OrderBy(u => u.Key) .OrderBy(u => u.Key)
.Select(u => ( .Select(u => (
variants[u.Key[..2]].Name + (u.Key.Length > 2 ? " " + attributes[u.Key[2..]].Name : ""), varieties[u.Key[..2]].Name + (u.Key.Length > 2 ? " " + attributes[u.Key[2..]].Name : ""),
u.Value.Diff, u.Value.Diff,
u.Value.Diff * (comTypes[u.Key].PenaltyPerKg ?? 0) u.Value.Diff * (comTypes[u.Key].PenaltyPerKg ?? 0)
- (comTypes[u.Key].PenaltyAmount ?? 0) - (comTypes[u.Key].PenaltyAmount ?? 0)

View File

@ -49,7 +49,7 @@
@if (i == 0) { @if (i == 0) {
<td rowspan="@rows">@p.LsNr</td> <td rowspan="@rows">@p.LsNr</td>
<td rowspan="@rows">@p.DPNr</td> <td rowspan="@rows">@p.DPNr</td>
<td class="small">@p.Variant</td> <td class="small">@p.Variety</td>
<td class="small">@p.Attribute</td> <td class="small">@p.Attribute</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td> <td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td> <td rowspan="@rows" class="center">@($"{p.Gradation.Kmw:N1}")</td>

View File

@ -42,17 +42,17 @@
</thead> </thead>
<tbody> <tbody>
@{ @{
var lastVariant = ""; var lastVariety = "";
} }
@foreach (var p in Model.Data.Rows) { @foreach (var p in Model.Data.Rows) {
var rows = Math.Max(p.Buckets.Length, p.Modifiers.Length + 1); var rows = Math.Max(p.Buckets.Length, p.Modifiers.Length + 1);
var first = true; var first = true;
@for (int i = 0; i < rows; i++) { @for (int i = 0; i < rows; i++) {
<tr class="@(first ? "first" : "") @(p.Variant != lastVariant && lastVariant != "" ? "new": "") @(rows > i + 1 ? "last" : "")"> <tr class="@(first ? "first" : "") @(p.Variety != lastVariety && lastVariety != "" ? "new": "") @(rows > i + 1 ? "last" : "")">
@if (first) { @if (first) {
<td rowspan="@rows">@p.LsNr</td> <td rowspan="@rows">@p.LsNr</td>
<td rowspan="@rows">@p.DPNr</td> <td rowspan="@rows">@p.DPNr</td>
<td class="small">@p.Variant</td> <td class="small">@p.Variety</td>
<td class="small">@p.Attribute</td> <td class="small">@p.Attribute</td>
<td class="small">@p.QualityLevel</td> <td class="small">@p.QualityLevel</td>
<td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td> <td rowspan="@rows" class="center">@($"{p.Gradation.Oe:N0}")</td>
@ -80,7 +80,7 @@
first = false; first = false;
} }
</tr> </tr>
lastVariant = p.Variant; lastVariety = p.Variety;
} }
} }
<tr class="sum bold"> <tr class="sum bold">

View File

@ -19,7 +19,7 @@ namespace Elwig.Documents {
public DeliveryJournal(string filter, IQueryable<DeliveryPart> deliveries) : public DeliveryJournal(string filter, IQueryable<DeliveryPart> deliveries) :
this(filter, deliveries this(filter, deliveries
.Include(p => p.Delivery).ThenInclude(d => d.Member) .Include(p => p.Delivery).ThenInclude(d => d.Member)
.Include(p => p.Variant) .Include(p => p.Variety)
.ToList()) { } .ToList()) { }
public DeliveryJournal(AppDbContext ctx, DateOnly date) : public DeliveryJournal(AppDbContext ctx, DateOnly date) :

View File

@ -45,7 +45,7 @@
<td class="small">@($"{p.Delivery.Time:HH:mm}")</td> <td class="small">@($"{p.Delivery.Time:HH:mm}")</td>
<td class="number">@p.Delivery.Member.MgNr</td> <td class="number">@p.Delivery.Member.MgNr</td>
<td class="small">@p.Delivery.Member.AdministrativeName</td> <td class="small">@p.Delivery.Member.AdministrativeName</td>
<td class="small">@p.Variant.Name</td> <td class="small">@p.Variety.Name</td>
<td class="center">@($"{p.Oe:N0}")</td> <td class="center">@($"{p.Oe:N0}")</td>
<td class="center">@($"{p.Kmw:N1}")</td> <td class="center">@($"{p.Kmw:N1}")</td>
<td class="number">@($"{p.Weight:N0}")</td> <td class="number">@($"{p.Weight:N0}")</td>

View File

@ -36,7 +36,7 @@
@foreach (var part in Model.Delivery.Parts.OrderBy(p => p.DPNr)) { @foreach (var part in Model.Delivery.Parts.OrderBy(p => p.DPNr)) {
<tr class="main"> <tr class="main">
<td class="center">@part.DPNr</td> <td class="center">@part.DPNr</td>
<td colspan="2">@part.Variant.Name</td> <td colspan="2">@part.Variety.Name</td>
<td colspan="2">@part.Attribute?.Name</td> <td colspan="2">@part.Attribute?.Name</td>
<td>@part.Quality.Name</td> <td>@part.Quality.Name</td>
<td class="center">@($"{part.Oe:N0}")</td> <td class="center">@($"{part.Oe:N0}")</td>

View File

@ -163,10 +163,10 @@ namespace Elwig.Helpers.Billing {
dict = []; dict = [];
} }
var variants = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length == 2); var varieties = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length == 2);
var attributes = data.Where(p => p.Key.StartsWith('/')); var attributes = data.Where(p => p.Key.StartsWith('/'));
var others = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length > 2 && p.Key != "default"); var others = data.Where(p => !p.Key.StartsWith('/') && p.Key.Length > 2 && p.Key != "default");
foreach (var (idx, v) in variants) { foreach (var (idx, v) in varieties) {
var curve = v?.AsValue() ?? throw new InvalidOperationException(); var curve = v?.AsValue() ?? throw new InvalidOperationException();
foreach (var i in vaributes.Where(e => e.StartsWith(idx[..^1]))) { foreach (var i in vaributes.Where(e => e.StartsWith(idx[..^1]))) {
dict[i] = curve; dict[i] = curve;

View File

@ -70,7 +70,11 @@ namespace Elwig.Helpers.Billing {
return (curves, dict3); return (curves, dict3);
} }
private static List<GraphEntry> CreateGraphEntries(AppDbContext ctx, int precision, Dictionary<int, Curve> curves, Dictionary<int, List<string>> entries) { private static List<GraphEntry> CreateGraphEntries(
AppDbContext ctx, int precision,
Dictionary<int, Curve> curves,
Dictionary<int, List<string>> entries
) {
var vars = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v); var vars = ctx.WineVarieties.ToDictionary(v => v.SortId, v => v);
var attrs = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a); var attrs = ctx.WineAttributes.ToDictionary(a => a.AttrId, a => a);
return entries return entries

View File

@ -4,8 +4,8 @@ using System;
namespace Elwig.Helpers.Billing { namespace Elwig.Helpers.Billing {
public class Varibute : IComparable<Varibute> { public class Varibute : IComparable<Varibute> {
public WineVar? Variety { get; } public readonly WineVar? Variety;
public WineAttr? Attribute { get; } public readonly WineAttr? Attribute;
public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}"; public string Listing => $"{Variety?.SortId}{Attribute?.AttrId}";
public string FullName => $"{Variety?.Name}" + (Variety != null && Attribute != null ? " " : "") + $"{Attribute?.Name}"; public string FullName => $"{Variety?.Name}" + (Variety != null && Attribute != null ? " " : "") + $"{Attribute?.Name}";

View File

@ -1,8 +1,5 @@
using Elwig.Helpers; using Elwig.Models.Entities;
using Elwig.Helpers.Billing;
using Elwig.Models.Entities;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
@ -46,7 +43,7 @@ namespace Elwig.Models.Dtos {
return await table.FromSqlRaw($""" return await table.FromSqlRaw($"""
SELECT d.year, c.tgnr, v.avnr, d.mgnr, d.did, d.lsnr, d.dpnr, d.weight, d.modifiers, SELECT d.year, c.tgnr, v.avnr, d.mgnr, d.did, d.lsnr, d.dpnr, d.weight, d.modifiers,
b.bktnr, d.sortid, b.discr, b.value, pb.price, pb.amount, p.net_amount, p.amount AS total_amount, b.bktnr, d.sortid, b.discr, b.value, pb.price, pb.amount, p.net_amount, p.amount AS total_amount,
s.name AS variant, a.name AS attribute, q.name AS quality_level, d.oe, d.kmw s.name AS variety, a.name AS attribute, q.name AS quality_level, d.oe, d.kmw
FROM v_delivery d FROM v_delivery d
JOIN wine_variety s ON s.sortid = d.sortid JOIN wine_variety s ON s.sortid = d.sortid
LEFT JOIN wine_attribute a ON a.attrid = d.attrid LEFT JOIN wine_attribute a ON a.attrid = d.attrid
@ -71,7 +68,7 @@ namespace Elwig.Models.Dtos {
public string LsNr; public string LsNr;
public int DPNr; public int DPNr;
public string Variant; public string Variety;
public string? Attribute; public string? Attribute;
public string[] Modifiers; public string[] Modifiers;
public string QualityLevel; public string QualityLevel;
@ -89,7 +86,7 @@ namespace Elwig.Models.Dtos {
LsNr = f.LsNr; LsNr = f.LsNr;
DPNr = f.DPNr; DPNr = f.DPNr;
Variant = f.Variant; Variety = f.Variety;
Attribute = f.Attribute; Attribute = f.Attribute;
var modifiers = (IEnumerable<Modifier>)(f.Modifiers ?? "").Split(',') var modifiers = (IEnumerable<Modifier>)(f.Modifiers ?? "").Split(',')
.Select(m => season?.Modifiers.FirstOrDefault(s => s.ModId == m)) .Select(m => season?.Modifiers.FirstOrDefault(s => s.ModId == m))
@ -148,8 +145,8 @@ namespace Elwig.Models.Dtos {
public long? NetAmount { get; set; } public long? NetAmount { get; set; }
[Column("total_amount")] [Column("total_amount")]
public long? TotalAmount { get; set; } public long? TotalAmount { get; set; }
[Column("variant")] [Column("variety")]
public string Variant { get; set; } public string Variety { get; set; }
[Column("attribute")] [Column("attribute")]
public string? Attribute { get; set; } public string? Attribute { get; set; }
[Column("quality_level")] [Column("quality_level")]

View File

@ -10,7 +10,7 @@ namespace Elwig.Models.Dtos {
private static readonly (string, string, string?, int)[] FieldNames = new[] { private static readonly (string, string, string?, int)[] FieldNames = new[] {
("LsNr", "LsNr.", null, 26), ("LsNr", "LsNr.", null, 26),
("DPNr", "Pos.", null, 8), ("DPNr", "Pos.", null, 8),
("Variant", "Sorte", null, 40), ("Variety", "Sorte", null, 40),
("Attribute", "Attribut", null, 20), ("Attribute", "Attribut", null, 20),
("Modifiers", "Zu-/Abschläge", null, 30), ("Modifiers", "Zu-/Abschläge", null, 30),
("QualityLevel", "Qualitätsstufe", null, 25), ("QualityLevel", "Qualitätsstufe", null, 25),
@ -51,7 +51,7 @@ namespace Elwig.Models.Dtos {
if (mgnr != null) q = q.Where(p => p.Delivery.MgNr == mgnr); if (mgnr != null) q = q.Where(p => p.Delivery.MgNr == mgnr);
await q await q
.Include(p => p.Delivery) .Include(p => p.Delivery)
.Include(p => p.Variant) .Include(p => p.Variety)
.Include(p => p.Attribute) .Include(p => p.Attribute)
.Include(p => p.Quality) .Include(p => p.Quality)
.Include(p => p.Buckets) .Include(p => p.Buckets)
@ -71,7 +71,7 @@ namespace Elwig.Models.Dtos {
public class DeliveryConfirmationRow { public class DeliveryConfirmationRow {
public string LsNr; public string LsNr;
public int DPNr; public int DPNr;
public string Variant; public string Variety;
public string? Attribute; public string? Attribute;
public string QualityLevel; public string QualityLevel;
public (double Oe, double Kmw) Gradation; public (double Oe, double Kmw) Gradation;
@ -83,7 +83,7 @@ namespace Elwig.Models.Dtos {
var d = p.Delivery; var d = p.Delivery;
LsNr = d.LsNr; LsNr = d.LsNr;
DPNr = p.DPNr; DPNr = p.DPNr;
Variant = p.Variant.Name; Variety = p.Variety.Name;
Attribute = p.Attribute?.Name; Attribute = p.Attribute?.Name;
QualityLevel = p.Quality.Name; QualityLevel = p.Quality.Name;
Gradation = (p.Oe, p.Kmw); Gradation = (p.Oe, p.Kmw);

View File

@ -23,7 +23,7 @@ namespace Elwig.Models.Entities {
public string SortId { get; set; } public string SortId { get; set; }
[ForeignKey("SortId")] [ForeignKey("SortId")]
public virtual WineVar Variant { get; private set; } public virtual WineVar Variety { get; private set; }
[Column("attrid")] [Column("attrid")]
public string? AttrId { get; set; } public string? AttrId { get; set; }