diff --git a/Elwig/Documents/BusinessDocument.cs b/Elwig/Documents/BusinessDocument.cs
index 4c03b93..490214a 100644
--- a/Elwig/Documents/BusinessDocument.cs
+++ b/Elwig/Documents/BusinessDocument.cs
@@ -81,11 +81,11 @@ namespace Elwig.Documents {
}
private static string FormatRow(
- int obligation, int right, int delivery, int? payment = null, int? area = null,
+ int obligation, int right, int delivery, int? totalDelivery = null, int? payment = null, int? area = null,
bool isGa = false, bool showPayment = false, bool showArea = false
) {
+ totalDelivery ??= delivery;
payment ??= delivery;
- var baseline = showPayment ? payment : delivery;
if (showArea) {
return $"
{(area == null ? "" : $"{area:N0}")} | " +
@@ -95,15 +95,15 @@ namespace Elwig.Documents {
return $"{(obligation == 0 ? "-" : $"{obligation:N0}")} | " +
$"{(right == 0 ? "-" : $"{right:N0}")} | " +
- $"{(baseline < obligation ? $"{obligation - baseline:N0}" : "-")} | " +
- $"{(baseline >= obligation && delivery <= right ? $"{right - delivery:N0}" : "-")} | " +
+ $"{(totalDelivery < obligation ? $"{obligation - totalDelivery:N0}" : "-")} | " +
+ $"{(delivery <= right ? $"{right - delivery:N0}" : "-")} | " +
$"{(obligation == 0 && right == 0 ? "-" : (delivery > right ? ((isGa ? "" : "") + $"{delivery - right:N0}" + (isGa ? "" : "")) : "-"))} | " +
(showPayment ? $"{(isGa ? "" : obligation == 0 && right == 0 ? "-" : $"{payment:N0}")} | " : "") +
- $"{delivery:N0} | ";
+ $"{totalDelivery:N0} | ";
}
private static string FormatRow(MemberBucket bucket, bool isGa = false, bool showPayment = false, bool showArea = false) {
- return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.Payment, bucket.Area, isGa, showPayment, showArea);
+ return FormatRow(bucket.Obligation, bucket.Right, bucket.Delivery, bucket.DeliveryTotal, bucket.Payment, bucket.Area, isGa, showPayment, showArea);
}
public string PrintBucketTable(
diff --git a/Elwig/Helpers/AppDbContext.cs b/Elwig/Helpers/AppDbContext.cs
index 6073eab..7625fba 100644
--- a/Elwig/Helpers/AppDbContext.cs
+++ b/Elwig/Helpers/AppDbContext.cs
@@ -17,7 +17,7 @@ namespace Elwig.Helpers {
public record struct AreaComBucket(int Area, int Obligation, int Right);
public record struct UnderDelivery(int Weight, int Diff);
- public record struct MemberBucket(string Name, int Area, int Obligation, int Right, int Delivery, int DeliveryStrict, int Payment);
+ public record struct MemberBucket(string Name, int Area, int Obligation, int Right, int Delivery, int DeliveryStrict, int DeliveryTotal, int Payment);
public record struct MemberStat(string Variety, string Discr, int Weight);
public record struct ModifierStat(string ModId, string Name, int Count, decimal? Min, decimal? Max, decimal Sum);
@@ -442,6 +442,7 @@ namespace Elwig.Helpers {
rightsAndObligations.GetValueOrDefault(id).Right,
deliveryBuckets.GetValueOrDefault(id),
deliveryBucketsStrict.GetValueOrDefault(id),
+ deliveryBuckets.GetValueOrDefault(id) + deliveryBuckets.GetValueOrDefault(id + "_"),
paymentBuckets.GetValueOrDefault(id)
);
}
diff --git a/Elwig/Helpers/AppDbUpdater.cs b/Elwig/Helpers/AppDbUpdater.cs
index 9e2d676..ab734da 100644
--- a/Elwig/Helpers/AppDbUpdater.cs
+++ b/Elwig/Helpers/AppDbUpdater.cs
@@ -9,7 +9,7 @@ namespace Elwig.Helpers {
public static class AppDbUpdater {
// Don't forget to update value in Tests/fetch-resources.bat!
- public static readonly int RequiredSchemaVersion = 30;
+ public static readonly int RequiredSchemaVersion = 31;
private static int VersionOffset = 0;
diff --git a/Elwig/Resources/Sql/30-31.sql b/Elwig/Resources/Sql/30-31.sql
new file mode 100644
index 0000000..db0fa2e
--- /dev/null
+++ b/Elwig/Resources/Sql/30-31.sql
@@ -0,0 +1,14 @@
+-- schema version 30 to 31
+
+PRAGMA writable_schema = ON;
+
+DROP VIEW v_under_delivery_bucket_strict;
+CREATE VIEW v_under_delivery_bucket_strict AS
+SELECT c.year, c.mgnr, c.bucket, c.min_kg, SUM(COALESCE(p.weight, 0)) AS weight
+FROM v_area_commitment_bucket_strict c
+ LEFT JOIN v_payment_bucket_strict p ON (p.year, p.mgnr, p.bucket) = (c.year, c.mgnr, c.bucket) OR (p.year, p.mgnr, p.bucket) = (c.year, c.mgnr, c.bucket || '_')
+GROUP BY c.year, c.mgnr, c.bucket
+ORDER BY c.year, c.mgnr, c.bucket;
+
+PRAGMA schema_version = 3001;
+PRAGMA writable_schema = OFF;
diff --git a/Tests/fetch-resources.bat b/Tests/fetch-resources.bat
index 8092376..9b268ea 100644
--- a/Tests/fetch-resources.bat
+++ b/Tests/fetch-resources.bat
@@ -1 +1 @@
-curl --fail -s -L "https://elwig.at/files/create.sql?v=30" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"
+curl --fail -s -L "https://elwig.at/files/create.sql?v=31" -u "elwig:ganzGeheim123!" -o "Resources\Sql\Create.sql"