[#34] Third step of not using Bio as Attribute

This commit is contained in:
2024-02-20 21:16:06 +01:00
parent f8ee478a9e
commit 56fdf62c5c
7 changed files with 215 additions and 77 deletions

View File

@ -123,10 +123,10 @@ namespace Elwig.Helpers.Billing {
}
protected async Task CalculatePrices(SqliteConnection cnx) {
var parts = new List<(int Year, int DId, int DPNr, int BktNr, string SortId, string? AttrId, string Discr, int Value, double Oe, double Kmw, string QualId)>();
var parts = new List<(int Year, int DId, int DPNr, int BktNr, string SortId, string? AttrId, string? CultId, string Discr, int Value, double Oe, double Kmw, string QualId)>();
using (var cmd = cnx.CreateCommand()) {
cmd.CommandText = $"""
SELECT d.year, d.did, d.dpnr, b.bktnr, d.sortid, d.attrid, b.discr, b.value, d.oe, d.kmw, d.qualid
SELECT d.year, d.did, d.dpnr, b.bktnr, d.sortid, d.attrid, d.cultid, b.discr, b.value, d.oe, d.kmw, d.qualid
FROM delivery_part_bucket b
JOIN v_delivery d ON (d.year, d.did, d.dpnr) = (b.year, b.did, b.dpnr)
WHERE b.year = {Year}
@ -135,8 +135,9 @@ namespace Elwig.Helpers.Billing {
while (await reader.ReadAsync()) {
parts.Add((
reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3),
reader.GetString(4), reader.IsDBNull(5) ? null : reader.GetString(5), reader.GetString(6),
reader.GetInt32(7), reader.GetDouble(8), reader.GetDouble(9), reader.GetString(10)
reader.GetString(4), reader.IsDBNull(5) ? null : reader.GetString(5),
reader.IsDBNull(6) ? null : reader.GetString(6), reader.GetString(7),
reader.GetInt32(8), reader.GetDouble(9), reader.GetDouble(10), reader.GetString(11)
));
}
}
@ -145,9 +146,9 @@ namespace Elwig.Helpers.Billing {
foreach (var part in parts) {
var ungeb = part.Discr == "_";
var payAttrId = (part.Discr is "" or "_") ? null : part.Discr;
var attrId = part.AttrId == "B" ? "B" : payAttrId; // FIXME
var attrId = payAttrId; // FIXME
var geb = !ungeb; // FIXME && payAttrId == part.AttrId;
var price = Data.CalculatePrice(part.SortId, attrId, part.QualId, geb, part.Oe, part.Kmw);
var price = Data.CalculatePrice(part.SortId, attrId, part.CultId, part.QualId, geb, part.Oe, part.Kmw);
var priceL = PaymentVariant.Season.DecToDb(price);
inserts.Add((part.Year, part.DId, part.DPNr, part.BktNr, priceL, priceL * part.Value));
}