From 8f1b1b88de4939061b19e094b884860d4812c8e8 Mon Sep 17 00:00:00 2001 From: metacube Date: Mon, 18 May 2026 21:39:10 +0200 Subject: [PATCH] Align main finance comparison with probe --- .../Components/Pages/FinanceComparison.razor | 143 +++++++++++++++--- .../Services/DatabaseSeedService.cs | 8 +- 2 files changed, 127 insertions(+), 24 deletions(-) diff --git a/TrafagSalesExporter/Components/Pages/FinanceComparison.razor b/TrafagSalesExporter/Components/Pages/FinanceComparison.razor index 62f0507..80669f9 100644 --- a/TrafagSalesExporter/Components/Pages/FinanceComparison.razor +++ b/TrafagSalesExporter/Components/Pages/FinanceComparison.razor @@ -12,7 +12,7 @@
@T("Net Sales Actuals 2025 Referenz", "Net sales actuals 2025 reference") - check.xlsx / Power BI Stand 29.04.2026 + @T("Gleiche Berechnungslogik wie FinanceProbe/Testprogramm", "Same calculation logic as FinanceProbe/test program")
- @T("Firma", "Company") + @T("Ampel", "Status") + @T("Land", "Country") @T("Ist 2025", "Actual 2025") - @T("IC-Abzug", "IC deduction") - @T("Ist exkl. IC", "Actual excl. IC") @T("Referenz", "Reference") - @T("Summenfeld", "Value field") - @T("Quelle", "Source") @T("Differenz", "Difference") - @T("Diff exkl. IC", "Diff excl. IC") @T("Waehrung", "Currency") + @T("Berechnung", "Calculation") @T("Zeilen", "Rows") - @T("Status", "Status") + @T("Varianten", "Variants") - @context.Label + + + @StatusText(context.Status) + + + + @context.Label + @context.Key + @FormatAmount(context.ActualValue) - @FormatAmount(context.IntercompanyDeduction) - @FormatAmount(context.ActualValueExcludingIntercompany) @FormatAmount(context.ReferenceValue) - @(string.IsNullOrWhiteSpace(context.ValueField) ? "-" : context.ValueField) - @context.ReferenceSource @FormatAmount(context.Difference) - @FormatAmount(context.DifferenceExcludingIntercompany) - @(string.IsNullOrWhiteSpace(context.Currencies) ? "-" : context.Currencies) + @FormatCurrency(context) + + @(string.IsNullOrWhiteSpace(context.ValueField) ? "-" : context.ValueField) + @BuildCalculationHint(context) + @(context.RowCount > 0 ? context.RowCount.ToString("N0") : "-") - @if (context.Status == "OK") + @if (context.Candidates.Count > 0) { - OK - } - else if (context.Status == "Pruefen") - { - @T("Pruefen", "Check") +
+ @context.Candidates.Count @T("Varianten anzeigen", "show variants") + + + + + + + + + + + + + @foreach (var candidate in context.Candidates) + { + + + + + + + + + } + +
@T("Abgrenzung", "Scope")@T("Waehrung", "Currency")@T("Wert", "Value")@T("Diff.", "Diff.")@T("IC", "IC")@T("Diff ohne IC", "Diff excl. IC")
@candidate.Label@candidate.Currency@FormatAmount(candidate.Value)@FormatAmount(candidate.Difference)@FormatAmount(candidate.IntercompanyValue)@FormatAmount(candidate.DifferenceExcludingIntercompany)
+
} else { - @T("Keine Daten", "No data") + - }
@@ -69,10 +96,42 @@ - @T("Vergleich: Jahr 2025 aus Buchungsdatum, sonst Invoice Date, sonst Extraction Date. Das Summenfeld wird automatisch aus Sales Price/Value, DocTotalFC - VatSumFC oder DocTotal - VatSum gewaehlt; Belegkopfwerte werden pro DocEntry nur einmal gezaehlt. IC-Abzug ist eine Diagnose fuer den aktuellen Abgleich und veraendert die Originaldaten nicht.", "Comparison: year 2025 from posting date, otherwise invoice date, otherwise extraction date. The value field is selected automatically from Sales Price/Value, DocTotalFC - VatSumFC, or DocTotal - VatSum; document header values are counted only once per DocEntry. IC deduction is a diagnostic value for the current reconciliation and does not change the original data.") + @T("Diese Seite nutzt dieselbe FinanceReconciliationService-Logik wie das lokale Testprogramm. Vergleich: Jahr 2025 aus Buchungsdatum, sonst Invoice Date, sonst Extraction Date. Das Summenfeld wird automatisch aus Sales Price/Value, DocTotalFC - VatSumFC oder DocTotal - VatSum gewaehlt; Belegkopfwerte werden pro DocEntry nur einmal gezaehlt. IC-Abzug ist eine Diagnose fuer den aktuellen Abgleich und veraendert die Originaldaten nicht.", "This page uses the same FinanceReconciliationService logic as the local test program. Comparison: year 2025 from posting date, otherwise invoice date, otherwise extraction date. The value field is selected automatically from Sales Price/Value, DocTotalFC - VatSumFC, or DocTotal - VatSum; document header values are counted only once per DocEntry. IC deduction is a diagnostic value for the current reconciliation and does not change the original data.") + + @code { private List _netSalesReferenceRows = new(); private bool _loading = true; @@ -92,5 +151,43 @@ private static string FormatAmount(decimal? value) => value.HasValue ? value.Value.ToString("N2") : "-"; + private static string FormatCurrency(NetSalesReferenceRow row) + { + if (!string.IsNullOrWhiteSpace(row.ActualCurrency)) + return row.ReferenceCurrency == "LC" + ? $"{row.ActualCurrency} / Soll LC" + : row.ActualCurrency; + + return string.IsNullOrWhiteSpace(row.Currencies) ? "-" : row.Currencies; + } + + private string BuildCalculationHint(NetSalesReferenceRow row) + { + if (row.Key.Equals("UK", StringComparison.OrdinalIgnoreCase)) + return T("Sage Netto in GBP; Credit Notes negativ; Soll ist Local Currency.", "Sage net in GBP; credit notes negative; reference is local currency."); + if (row.Key.Equals("ES", StringComparison.OrdinalIgnoreCase)) + return T("Sage ImporteNeto; REC/Credit Notes negativ; Zuschlaege/Nebenkosten noch pruefen.", "Sage ImporteNeto; REC/credit notes negative; surcharges/charges still to check."); + if (row.Key.Equals("IT", StringComparison.OrdinalIgnoreCase)) + return T("B1 Arbeitsfilter 47005 ohne 4700504 plus provisorischer Kundenausschluss.", "B1 working filter 47005 excluding 4700504 plus provisional customer exclusions."); + if (row.Key.Equals("FR", StringComparison.OrdinalIgnoreCase) || + row.Key.Equals("IN", StringComparison.OrdinalIgnoreCase) || + row.Key.Equals("US", StringComparison.OrdinalIgnoreCase)) + return T("Passt gegen Soll; Sales Price/Value ist bevorzugte Variante.", "Matches reference; Sales Price/Value is the preferred variant."); + + return row.ReferenceCurrency == "LC" + ? T("Vergleich gegen Local Currency Referenz.", "Compared against local currency reference.") + : T("Vergleich gegen Check-/Sollwert.", "Compared against check/reference value."); + } + + private Color StatusColor(string status) + => status == "OK" ? Color.Success + : status == "Pruefen" ? Color.Warning + : Color.Default; + + private string StatusText(string status) + => status == "OK" ? "OK" + : status == "Pruefen" ? T("Pruefen", "Check") + : T("Keine Daten", "No data"); + private string T(string german, string english) => UiText.Text(german, english); } diff --git a/TrafagSalesExporter/Services/DatabaseSeedService.cs b/TrafagSalesExporter/Services/DatabaseSeedService.cs index 29381bf..5135c9d 100644 --- a/TrafagSalesExporter/Services/DatabaseSeedService.cs +++ b/TrafagSalesExporter/Services/DatabaseSeedService.cs @@ -620,7 +620,7 @@ public class DatabaseSeedService : IDatabaseSeedService new FinanceReference { Key = "CN", Label = "Trafag CN", Year = 2025 }, new FinanceReference { Key = "CZ", Label = "Trafag CZ", Year = 2025, LocalCurrencyValue = 95458782m }, new FinanceReference { Key = "DE", Label = "Trafag DE", Year = 2025, LocalCurrencyValue = 3635923m }, - new FinanceReference { Key = "ES", Label = "Trafag ES", Year = 2025, LocalCurrencyValue = 3102334m }, + new FinanceReference { Key = "ES", Label = "Trafag ES", Year = 2025, LocalCurrencyValue = 3102333.61m }, new FinanceReference { Key = "FR", Label = "Trafag FR", Year = 2025, LocalCurrencyValue = 1450582m, CheckValue = 1471218m }, new FinanceReference { Key = "GFS", Label = "Trafag GfS", Year = 2025, LocalCurrencyValue = 6495513m }, new FinanceReference { Key = "IN", Label = "Trafag IN", Year = 2025, LocalCurrencyValue = 747341702m, CheckValue = 750936591m }, @@ -656,6 +656,12 @@ public class DatabaseSeedService : IDatabaseSeedService } } + if (current.Key == "ES" && current.Year == 2025 && current.LocalCurrencyValue != 3102333.61m) + { + current.LocalCurrencyValue = 3102333.61m; + changed = true; + } + continue; }