Add Fuchs_Database SSDT project (schema source of truth)

Adds the SQL Server Data Tools project for the fuchs_fds database — tables,
table types, functions and stored procedures that the backend calls (e.g.
fds__getInvoice, fds__merge_bankingtransactions, fds__tt__bankingtransactions,
fds__admin_getReportCatalog, fis_* auth). Build/model caches (bin, obj,
*.dbmdl, *.jfm, *.user) are git-ignored.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 14:50:54 +02:00
parent 1376779224
commit 10ecdfa2e4
359 changed files with 22603 additions and 0 deletions
@@ -0,0 +1,120 @@
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[fds__merge_bankingtransactions]
@tblname as nvarchar(50)
,@authuser varchar(25)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @now datetime = GETUTCDATE();
DECLARE @tmp [dbo].[fds__tt__bankingtransactions];
DECLARE @tmp_cmd nvarchar(1000) = N'SELECT DISTINCT * FROM ' + @tblname
INSERT INTO @tmp EXECUTE [sp_executesql] @tmp_cmd;
INSERT INTO [dbo].[fds__admin_activity] ([activity] ,[authuser] ,[info])
VALUES ('fds__merge_bankingtransactions' ,ISNULL(@authuser,''), '');
MERGE [dbo].[fds__bankingtransactions] as TARGET
USING @tmp as SOURCE ON
TARGET.[AccountIdentification] = SOURCE.[AccountIdentification]
AND TARGET.[ValueDate] = SOURCE.[ValueDate]
AND TARGET.[Amount] = SOURCE.[Amount]
AND TARGET.[FundsCode] = SOURCE.[FundsCode]
AND TARGET.[AccountNumberOfPayer] = SOURCE.[AccountNumberOfPayer]
AND TARGET.[BankCodeOfPayer] = SOURCE.[BankCodeOfPayer]
AND TARGET.[EndToEndReference] = SOURCE.[EndToEndReference]
AND TARGET.[SepaRemittanceInformation] = SOURCE.[SepaRemittanceInformation]
WHEN NOT MATCHED BY TARGET THEN
INSERT
([taID]
,[AccountIdentification]
,[ValueDate]
,[Amount]
,[FundsCode]
,[AccountNumberOfPayer]
,[BankCodeOfPayer]
,[CompensationAmount]
,[CreditorReference]
,[CreditorsReferenceParty]
,[CustomerReference]
,[EndToEndReference]
,[JournalNumber]
,[MandateReference]
,[NameOfPayer]
,[OriginalAmount]
,[OriginatorsIdentificationCode]
,[PayersReferenceParty]
,[PostingText]
,[SepaRemittanceInformation]
,[TextKeyAddition]
,[TransactionCode]
,[IsUnstructuredData]
,[UnstructuredData]
,[UnstructuredRemittanceInformation]
,[DebitCreditMark]
,[TransactionTypeIdCode])
VALUES
( [dbo].[fds__fn_bankingtransaction_id]()
, SOURCE.[AccountIdentification]
, SOURCE.[ValueDate]
, SOURCE.[Amount]
, SOURCE.[FundsCode]
, SOURCE.[AccountNumberOfPayer]
, SOURCE.[BankCodeOfPayer]
, SOURCE.[CompensationAmount]
, SOURCE.[CreditorReference]
, SOURCE.[CreditorsReferenceParty]
, SOURCE.[CustomerReference]
, SOURCE.[EndToEndReference]
, SOURCE.[JournalNumber]
, SOURCE.[MandateReference]
, SOURCE.[NameOfPayer]
, SOURCE.[OriginalAmount]
, SOURCE.[OriginatorsIdentificationCode]
, SOURCE.[PayersReferenceParty]
, SOURCE.[PostingText]
, LEFT(SOURCE.[SepaRemittanceInformation], 200)
, SOURCE.[TextKeyAddition]
, SOURCE.[TransactionCode]
, SOURCE.[IsUnstructuredData]
, SOURCE.[UnstructuredData]
, SOURCE.[UnstructuredRemittanceInformation]
, SOURCE.[DebitCreditMark]
, SOURCE.[TransactionTypeIdCode]
)
;
MERGE [dbo].[fds__admin_settings] as TARGET
USING (VALUES('log','bankingtransaction_merge',FORMAT(@now, 'yyyy-MM-dd HH:mm:ss', 'de'), NULL)) as SRC ([type],[key],[value],[value2])
ON TARGET.[type] = SRC.[type] AND TARGET.[key] = SRC.[key]
WHEN MATCHED THEN
UPDATE SET TARGET.[value] = SRC.[Value], TARGET.[value2] = SRC.[value2]
WHEN NOT MATCHED BY TARGET THEN
INSERT ([type], [key], [value], [value2]) VALUES (SRC.[type], SRC.[key], SRC.[value], SRC.[value2]);
with b as (
SELECT *, ROW_NUMBER() OVER (PARTITION BY [AccountIdentification]
,[ValueDate]
,[Amount]
,[FundsCode]
,[AccountNumberOfPayer]
,[BankCodeOfPayer]
,[SepaRemittanceInformation]
order by [valuedate]) as [order]
FROM [dbo].[fds__bankingtransactions]
)
DELETE FROM b where [order] > 1;
--Process transactions and assignments
EXECUTE [dbo].[fds__setBankingtransaction_autoAssigns];
EXECUTE [dbo].[fds__setInvoicePaymentStatus_auto];
END