Move fis widgets SQL into scalar functions
Playwright Tests / test (push) Waiting to run

Add fis_wdg_* table functions for dashboard widgets and wire them into
FuchsDatabase.sqlproj; update the invoice list procs accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Stefan
2026-10-16 11:35:28 +02:00
co-authored by Copilot
parent a39ccb8bbc
commit 330c33e65d
20 changed files with 307 additions and 13 deletions
@@ -0,0 +1,16 @@
-- =============================================
-- Description: Dashboard widget 'wdg_bankingupload' (Bank-Buchungen).
-- Called from [dbo].[fis_widgets].[sql] as: SELECT * FROM [dbo].[fis_wdg_bankingupload]()
-- =============================================
CREATE FUNCTION [dbo].[fis_wdg_bankingupload]()
RETURNS TABLE
AS
RETURN
(
SELECT TOP (1) [label] = N'Letzte Übertragung der Bankdaten am ' + FORMAT(CAST([value] as date), 'dd.MM.', 'de')
, [value] = FORMAT(DATEDIFF(DAY, CAST([value] as date), CAST(GETDATE() as date)), '0', 'de') + ' d'
, [status] = IIF(DATEDIFF(DAY, CAST([value] as date), CAST(GETDATE() as date)) > 6, 'neg', 'pos')
FROM [dbo].[fds__admin_settings]
WHERE [type] = 'log' AND [key] = 'bankingtransaction_merge'
ORDER BY TRY_CAST([value] as date) DESC
);