Billing: Fix BIO billing and update method parameters

This commit is contained in:
2024-02-03 00:32:42 +01:00
parent befe6a753b
commit 0591d91f49
3 changed files with 16 additions and 14 deletions

View File

@ -45,7 +45,15 @@ namespace Elwig.Helpers.Billing {
""");
}
public async Task CalculateBuckets(bool allowAttrsIntoLower, bool avoidUnderDeliveries, bool honorGebunden, SqliteConnection? cnx = null) {
public async Task CalculateBuckets(
bool? honorGebundenField = null,
bool? allowAttributesIntoLower = null,
bool? avoidUnderDeliveries = null,
SqliteConnection? cnx = null
) {
var honorGebunden = honorGebundenField ?? Season.Billing_HonorGebunden;
var allowAttrsIntoLower = allowAttributesIntoLower ?? Season.Billing_AllowAttrsIntoLower;
var avoidUnderDlvrs = avoidUnderDeliveries ?? Season.Billing_AvoidUnderDeliveries;
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();
var ownCnx = cnx == null;
@ -125,7 +133,7 @@ namespace Elwig.Helpers.Billing {
SET discr = excluded.discr, value = value + excluded.value;
""");
if (!avoidUnderDeliveries) {
if (!avoidUnderDlvrs) {
if (ownCnx) await cnx.DisposeAsync();
return;
}