Billing: fix small bugs
This commit is contained in:
@ -414,7 +414,7 @@ namespace Elwig.Helpers {
|
||||
t.sortid || COALESCE(a.attrid, '') AS bucket,
|
||||
t.sortid, a.attrid,
|
||||
CAST(ROUND(SUM(area) * COALESCE(t.min_kg_per_ha, 0) / 10000.0, 0) AS INTEGER) AS min_kg,
|
||||
CAST(ROUND(SUM(area) * COALESCE(a.max_kg_per_ha, s.max_kg_per_ha) / 10000.0, 0) AS INTEGER) AS max_kg,
|
||||
CAST(ROUND(SUM(area) * MIN(COALESCE(a.max_kg_per_ha, s.max_kg_per_ha), s.max_kg_per_ha) / 10000.0, 0) AS INTEGER) AS max_kg,
|
||||
CAST(ROUND(SUM(area) * s.max_kg_per_ha / 10000.0, 0) AS INTEGER) AS upper_max_kg
|
||||
FROM season s, area_commitment c
|
||||
JOIN area_commitment_type t ON t.vtrgid = c.vtrgid
|
||||
|
@ -97,7 +97,7 @@ namespace Elwig.Helpers.Billing {
|
||||
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 v = (attributes.Length == 0 || attributes.Select(a => !attrVals[a].IsStrict ? 2 : attrVals[a].FillLower).Min() == 2) ? vr : vo;
|
||||
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;
|
||||
inserts.Add((did, dpnr, i, key[2..], v));
|
||||
|
Reference in New Issue
Block a user