AppDbContext: Use records instead of unnamed tuples for buckets
This commit is contained in:
@ -41,7 +41,7 @@ namespace Elwig.Helpers.Billing {
|
||||
var attrVals = Context.WineAttributes.ToDictionary(a => a.AttrId, a => (a.IsStrict, a.FillLower));
|
||||
var attrForced = attrVals.Where(a => a.Value.IsStrict && a.Value.FillLower == 0).Select(a => a.Key).ToArray();
|
||||
using var cnx = await AppDbContext.ConnectAsync();
|
||||
await Context.GetMemberRightsAndObligations(Year, 0, cnx);
|
||||
await Context.GetMemberAreaCommitmentBuckets(Year, 0, cnx);
|
||||
var inserts = new List<(int, int, int, string, int)>();
|
||||
|
||||
var deliveries = new List<(int, int, int, string, int, double, string, string?, string[], bool?)>();
|
||||
@ -66,11 +66,11 @@ namespace Elwig.Helpers.Billing {
|
||||
}
|
||||
|
||||
int lastMgNr = 0;
|
||||
Dictionary<string, (int, int)>? rightsAndObligations = null;
|
||||
Dictionary<string, AreaComBucket>? rightsAndObligations = null;
|
||||
Dictionary<string, int> used = new();
|
||||
foreach (var (mgnr, did, dpnr, sortid, weight, kmw, qualid, attrid, modifiers, gebunden) in deliveries) {
|
||||
if (lastMgNr != mgnr) {
|
||||
rightsAndObligations = await Context.GetMemberRightsAndObligations(Year, mgnr);
|
||||
rightsAndObligations = await Context.GetMemberAreaCommitmentBuckets(Year, mgnr);
|
||||
used = new();
|
||||
}
|
||||
if ((honorGebunden && gebunden == false) ||
|
||||
@ -94,8 +94,8 @@ namespace Elwig.Helpers.Billing {
|
||||
if (rightsAndObligations.ContainsKey(key)) {
|
||||
int i = (c == 0) ? 1 : 2;
|
||||
var u = used.GetValueOrDefault(key, 0);
|
||||
var vr = Math.Max(0, Math.Min(rightsAndObligations[key].Item1 - u, w));
|
||||
var vo = Math.Max(0, Math.Min(rightsAndObligations[key].Item2 - u, w));
|
||||
var vr = Math.Max(0, Math.Min(rightsAndObligations[key].Right - u, w));
|
||||
var vo = Math.Max(0, Math.Min(rightsAndObligations[key].Obligation - u, w));
|
||||
var v = (attributes.Length == c || attributes.Select(a => !attrVals[a].IsStrict ? 2 : attrVals[a].FillLower).Min() == 2) ? vr : vo;
|
||||
used[key] = u + v;
|
||||
if (key.Length > 2 && !isStrict) used[key[..2]] = used.GetValueOrDefault(key[..2], 0) + v;
|
||||
|
Reference in New Issue
Block a user