AbbDbContext: Move SqliteConnection extensions to Extensions class
All checks were successful
Test / Run tests (push) Successful in 2m25s
All checks were successful
Test / Run tests (push) Successful in 2m25s
This commit is contained in:
@@ -47,7 +47,7 @@ namespace Elwig.Helpers.Billing {
|
||||
public async Task Commit() {
|
||||
await Revert();
|
||||
using var cnx = await AppDbContext.ConnectAsync();
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
INSERT INTO credit (year, tgnr, mgnr, avnr, net_amount, prev_net_amount, vat, modifiers, prev_modifiers)
|
||||
SELECT s.year,
|
||||
COALESCE(t.tgnr, 0) + ROW_NUMBER() OVER(ORDER BY m.mgnr) AS tgnr,
|
||||
@@ -82,27 +82,27 @@ namespace Elwig.Helpers.Billing {
|
||||
LEFT JOIN payment_custom x ON (x.year, x.mgnr) = (s.year, m.mgnr)
|
||||
WHERE s.year = {Year} AND v.avnr = {AvNr};
|
||||
""");
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
UPDATE payment_variant SET test_variant = FALSE WHERE (year, avnr) = ({Year}, {AvNr});
|
||||
""");
|
||||
}
|
||||
|
||||
public async Task Revert() {
|
||||
using var cnx = await AppDbContext.ConnectAsync();
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
DELETE FROM credit WHERE (year, avnr) = ({Year}, {AvNr});
|
||||
UPDATE payment_variant SET test_variant = TRUE WHERE (year, avnr) = ({Year}, {AvNr});
|
||||
""");
|
||||
}
|
||||
|
||||
protected async Task SetCalcTime(SqliteConnection cnx) {
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
UPDATE payment_variant SET calc_time = UNIXEPOCH() WHERE (year, avnr) = ({Year}, {AvNr})
|
||||
""");
|
||||
}
|
||||
|
||||
protected async Task DeleteInDb(SqliteConnection cnx) {
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
DELETE FROM payment_delivery_part_bucket WHERE (year, avnr) = ({Year}, {AvNr});
|
||||
DELETE FROM payment_delivery_part WHERE (year, avnr) = ({Year}, {AvNr});
|
||||
DELETE FROM payment_member WHERE (year, avnr) = ({Year}, {AvNr});
|
||||
@@ -116,7 +116,7 @@ namespace Elwig.Helpers.Billing {
|
||||
var multiplier = 0.50;
|
||||
var includePredecessor = true;
|
||||
var modName = "Treue%";
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
INSERT INTO payment_member (year, avnr, mgnr, net_amount, mod_abs, mod_rel)
|
||||
SELECT c.year, {AvNr}, s.mgnr, 0,
|
||||
ROUND(s.sum * COALESCE(m.abs, 0)),
|
||||
@@ -138,7 +138,7 @@ namespace Elwig.Helpers.Billing {
|
||||
mod_rel = mod_rel + excluded.mod_rel
|
||||
""");
|
||||
}
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
INSERT INTO payment_member (year, avnr, mgnr, net_amount, mod_abs, mod_rel)
|
||||
SELECT x.year, {AvNr}, x.mgnr, 0, COALESCE(x.mod_abs * POW(10, s.precision - 2), 0), COALESCE(x.mod_rel, 0)
|
||||
FROM payment_custom x
|
||||
@@ -194,7 +194,7 @@ namespace Elwig.Helpers.Billing {
|
||||
var msg = invalid.Count == 0 ? null : "Für folgende Sorten wurde noch keine Preiskurve festgelegt: " + string.Join(", ", invalid);
|
||||
if (msg != null && strict)
|
||||
throw new KeyNotFoundException(msg);
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
INSERT INTO payment_delivery_part_bucket (year, did, dpnr, bktnr, avnr, price, amount)
|
||||
VALUES {string.Join(",\n ", inserts.Select(i => $"({i.Year}, {i.DId}, {i.DPNr}, {i.BktNr}, {AvNr}, {i.Price}, {i.Amount})"))};
|
||||
""");
|
||||
@@ -205,7 +205,7 @@ namespace Elwig.Helpers.Billing {
|
||||
protected async Task CalculateDeliveryModifiers(SqliteConnection cnx) {
|
||||
var netMod = Data.NetWeightModifier.ToString().Replace(',', '.');
|
||||
var grossMod = Data.GrossWeightModifier.ToString().Replace(',', '.');
|
||||
await AppDbContext.ExecuteBatch(cnx, $"""
|
||||
await cnx.ExecuteBatch($"""
|
||||
INSERT INTO payment_delivery_part (year, did, dpnr, avnr, net_amount, mod_abs, mod_rel)
|
||||
SELECT d.year, d.did, d.dpnr, {AvNr}, 0, 0, IIF(d.net_weight, {netMod}, {grossMod})
|
||||
FROM delivery_part d
|
||||
|
||||
Reference in New Issue
Block a user