AppDbContext: Use records instead of unnamed tuples for buckets
This commit is contained in:
@ -10,7 +10,7 @@ namespace Elwig.Documents {
|
||||
public Season Season;
|
||||
public DeliveryConfirmationData Data;
|
||||
public string? Text = App.Client.TextDeliveryConfirmation;
|
||||
public Dictionary<string, (string, int, int, int, int)> MemberBuckets;
|
||||
public Dictionary<string, MemberBucket> MemberBuckets;
|
||||
|
||||
public DeliveryConfirmation(AppDbContext ctx, int year, Member m, DeliveryConfirmationData data) :
|
||||
base($"Anlieferungsbestätigung {year}", m) {
|
||||
|
@ -125,11 +125,11 @@
|
||||
$"<td>{(mode != 2 ? "" : obligation == 0 && right == 0 ? "-" : $"{payment:N0}")}</td>" +
|
||||
$"<td>{sum:N0}</td>";
|
||||
}
|
||||
var mBuckets = Model.MemberBuckets.Where(b => b.Value.Item2 > 0 || b.Value.Item3 > 0 || b.Value.Item4 > 0).ToList();
|
||||
var fbVars = mBuckets.Where(b => b.Value.Item2 > 0 || b.Value.Item3 > 0).Select(b => b.Key.Replace("_", "")).Order().ToArray();
|
||||
var fbs = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length == 2).OrderBy(b => b.Value.Item1);
|
||||
var vtr = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length > 2).OrderBy(b => b.Value.Item1);
|
||||
var rem = mBuckets.Where(b => !fbVars.Contains(b.Key)).OrderBy(b => b.Value.Item1);
|
||||
var mBuckets = Model.MemberBuckets.Where(b => b.Value.Right > 0 || b.Value.Obligation > 0 || b.Value.Delivery > 0).ToList();
|
||||
var fbVars = mBuckets.Where(b => b.Value.Right > 0 || b.Value.Obligation > 0).Select(b => b.Key.Replace("_", "")).Order().ToArray();
|
||||
var fbs = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length == 2).OrderBy(b => b.Value.Name);
|
||||
var vtr = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length > 2).OrderBy(b => b.Value.Name);
|
||||
var rem = mBuckets.Where(b => !fbVars.Contains(b.Key)).OrderBy(b => b.Value.Name);
|
||||
}
|
||||
<tr>
|
||||
<th>Gesamtlieferung lt. gez. GA</th>
|
||||
@ -143,28 +143,28 @@
|
||||
@if (rem.Any()) {
|
||||
<tr class="subheading"><th colspan="8">Sortenaufteilung:</th></tr>
|
||||
}
|
||||
@foreach (var (id, (name, right, obligation, sum, payment)) in rem) {
|
||||
@foreach (var (id, b) in rem) {
|
||||
<tr>
|
||||
<th>@name</th>
|
||||
@Raw(FormatRow(1, obligation, right, sum, payment))
|
||||
<th>@b.Name</th>
|
||||
@Raw(FormatRow(1, b.Obligation, b.Right, b.Delivery, b.Payment))
|
||||
</tr>
|
||||
}
|
||||
@if (fbs.Any()){
|
||||
<tr class="subheading"><th colspan="8">Flächenbindungen:</th></tr>
|
||||
}
|
||||
@foreach (var (id, (name, right, obligation, sum, payment)) in fbs) {
|
||||
@foreach (var (id, b) in fbs) {
|
||||
<tr>
|
||||
<th>@name</th>
|
||||
@Raw(FormatRow(2, obligation, right, sum, payment))
|
||||
<th>@b.Name</th>
|
||||
@Raw(FormatRow(2, b.Obligation, b.Right, b.Delivery, b.Payment))
|
||||
</tr>
|
||||
}
|
||||
@if (vtr.Any()) {
|
||||
<tr class="subheading"><th colspan="8">Verträge:</th></tr>
|
||||
}
|
||||
@foreach (var (id, (name, right, obligation, sum, payment)) in vtr) {
|
||||
@foreach (var (id, b) in vtr) {
|
||||
<tr>
|
||||
<th>@name</th>
|
||||
@Raw(FormatRow(2, obligation, right, sum, payment))
|
||||
<th>@b.Name</th>
|
||||
@Raw(FormatRow(2, b.Obligation, b.Right, b.Delivery, b.Payment))
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
@ -7,7 +7,7 @@ namespace Elwig.Documents {
|
||||
|
||||
public Delivery Delivery;
|
||||
public string? Text;
|
||||
public Dictionary<string, (string, int, int, int, int)> MemberBuckets;
|
||||
public Dictionary<string, MemberBucket> MemberBuckets;
|
||||
|
||||
// 0 - none
|
||||
// 1 - GA only
|
||||
|
@ -122,11 +122,11 @@
|
||||
<tr class="subheading">
|
||||
<th>Flächenbindungen:</th>
|
||||
</tr>
|
||||
@foreach (var (id, (name, right, obligation, sum, _)) in Model.MemberBuckets.OrderBy(b => b.Key)) {
|
||||
if (right > 0 || obligation > 0 || (sum > 0 && buckets[id[..2]] > 1 && !id.EndsWith('_'))) {
|
||||
@foreach (var (id, b) in Model.MemberBuckets.OrderBy(b => b.Key)) {
|
||||
if (b.Right > 0 || b.Obligation > 0 || (b.Delivery > 0 && buckets[id[..2]] > 1 && !id.EndsWith('_'))) {
|
||||
<tr class="@(sortids.Contains(id[..2]) ? "" : "optional")">
|
||||
<th>@name</th>
|
||||
@Raw(FormatRow(obligation, right, sum))
|
||||
<th>@b.Name</th>
|
||||
@Raw(FormatRow(b.Obligation, b.Right, b.Delivery))
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,12 @@ namespace Elwig.Documents {
|
||||
|
||||
public Season Season;
|
||||
public int Year = Utils.CurrentYear;
|
||||
public Dictionary<string, (string, int, int, int, int)> MemberBuckets;
|
||||
public Dictionary<string, int> BucketAreas;
|
||||
public Dictionary<string, MemberBucket> MemberBuckets;
|
||||
|
||||
public MemberDataSheet(Member m, AppDbContext ctx) : base($"Stammdatenblatt {m.AdministrativeName}", m) {
|
||||
DocumentId = $"Stammdatenblatt {m.MgNr}";
|
||||
Season = ctx.Seasons.Find(Year) ?? throw new ArgumentException("invalid season");
|
||||
MemberBuckets = ctx.GetMemberBuckets(Year, m.MgNr).GetAwaiter().GetResult();
|
||||
BucketAreas = ctx.GetMemberBucketAreas(Year, m.MgNr).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
@ -259,10 +259,10 @@
|
||||
$"<td>{(mode == 1 ? "" : obligation == 0 ? "-" : $"{obligation:N0}")}</td>" +
|
||||
$"<td>{(mode == 1 ? "" : right == 0 ? "-" : $"{right:N0}")}</td>";
|
||||
}
|
||||
var mBuckets = Model.MemberBuckets.Where(b => b.Value.Item2 > 0 || b.Value.Item3 > 0 || b.Value.Item4 > 0).ToList();
|
||||
var fbVars = mBuckets.Where(b => b.Value.Item2 > 0 || b.Value.Item3 > 0).Select(b => b.Key.Replace("_", "")).Order().ToArray();
|
||||
var fbs = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length == 2).OrderBy(b => b.Value.Item1);
|
||||
var vtr = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length > 2).OrderBy(b => b.Value.Item1);
|
||||
var mBuckets = Model.MemberBuckets.Where(b => b.Value.Right > 0 || b.Value.Obligation > 0 || b.Value.Delivery > 0).ToList();
|
||||
var fbVars = mBuckets.Where(b => b.Value.Right > 0 || b.Value.Obligation > 0).Select(b => b.Key.Replace("_", "")).Order().ToArray();
|
||||
var fbs = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length == 2).OrderBy(b => b.Value.Name);
|
||||
var vtr = mBuckets.Where(b => fbVars.Contains(b.Key) && b.Key.Length > 2).OrderBy(b => b.Value.Name);
|
||||
}
|
||||
<tr>
|
||||
<th>Laut gezeichneten GA</th>
|
||||
@ -271,24 +271,24 @@
|
||||
0,
|
||||
Model.Member.BusinessShares * Model.Season.MinKgPerBusinessShare,
|
||||
Model.Member.BusinessShares * Model.Season.MaxKgPerBusinessShare
|
||||
))
|
||||
))
|
||||
</tr>
|
||||
@if (fbs.Any()) {
|
||||
<tr class="subheading"><th colspan="8">Flächenbindungen:</th></tr>
|
||||
}
|
||||
@foreach (var (id, (name, right, obligation, _, _)) in fbs) {
|
||||
@foreach (var (id, b) in fbs) {
|
||||
<tr>
|
||||
<th>@name</th>
|
||||
@Raw(FormatRow(2, Model.BucketAreas[id], obligation, right))
|
||||
<th>@b.Name</th>
|
||||
@Raw(FormatRow(2, b.Area, b.Obligation, b.Right))
|
||||
</tr>
|
||||
}
|
||||
@if (vtr.Any()) {
|
||||
<tr class="subheading"><th colspan="8">Verträge:</th></tr>
|
||||
}
|
||||
@foreach (var (id, (name, right, obligation, _, _)) in vtr) {
|
||||
@foreach (var (id, b) in vtr) {
|
||||
<tr>
|
||||
<th>@name</th>
|
||||
@Raw(FormatRow(2, Model.BucketAreas[id], obligation, right))
|
||||
<th>@b.Name</th>
|
||||
@Raw(FormatRow(2, b.Area, b.Obligation, b.Right))
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
Reference in New Issue
Block a user