Compare commits

...

3 Commits

Author SHA1 Message Date
e71d9516ec Billing: small fixes 2023-10-15 00:11:42 +02:00
658c10c2a4 WineAttr: Add fill_lower_bins 2023-10-14 23:56:41 +02:00
ff3defe52d Database: fix v_bucket update 2023-10-14 23:51:54 +02:00
3 changed files with 18 additions and 2 deletions

View File

@@ -173,6 +173,19 @@ namespace Elwig.Helpers {
GROUP BY p.year, p.did, p.dpnr
ORDER BY p.year, p.did, p.dpnr;
""");
ExecuteNonQuery(cnx, "DROP VIEW v_bucket");
ExecuteNonQuery(cnx, """
CREATE VIEW v_delivery_bin AS
SELECT year, mgnr,
sortid || IIF(min_quw, REPLACE(COALESCE(attributes, ''), ',', ''), '_') AS bin,
SUM(weight) AS weight
FROM v_delivery
GROUP BY year, mgnr, bin
ORDER BY year, mgnr, LENGTH(bin) DESC, bin;
""");
ExecuteNonQuery(cnx, "ALTER TABLE wine_attribute ADD COLUMN fill_lower_bins INTEGER NOT NULL CHECK (fill_lower_bins IN (TRUE, FALSE)) DEFAULT FALSE");
}
}
}

View File

@@ -154,7 +154,7 @@ namespace Elwig.Helpers.Billing {
public static async Task<(Dictionary<string, int>, Dictionary<string, int>)> GetMemberRightsObligations(SqliteConnection cnx, int year, int mgnr) {
var members = await GetMemberRightsObligations(cnx, year, (int?)mgnr);
return members[mgnr];
return members.GetValueOrDefault(mgnr, (new(), new()));
}
public static async Task<Dictionary<string, int>> GetMemberBinWeights(int mgnr, int year, SqliteConnection cnx) {
@@ -163,7 +163,7 @@ namespace Elwig.Helpers.Billing {
using var cmd = cnx.CreateCommand();
cmd.CommandText = $"""
SELECT bin, weight
FROM v_bin
FROM v_delivery_bin
WHERE (year, mgnr) = ({year}, {mgnr})
""";

View File

@@ -13,6 +13,9 @@ namespace Elwig.Models {
[Column("max_kg_per_ha")]
public int? MaxKgPerHa { get; set; }
[Column("fill_lower_bins")]
public bool FillLowerBins { get; set; }
[Column("active")]
public bool IsActive { get; set; }
public override string ToString() {