10ecdfa2e4
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>
43 lines
1.3 KiB
Transact-SQL
43 lines
1.3 KiB
Transact-SQL
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE PROCEDURE [dbo].[backup__fds__getInvoiceReminder]
|
|
@InvId varchar(15)
|
|
, @include_drafts bit = 0
|
|
,@authuser varchar(25)
|
|
AS
|
|
BEGIN
|
|
SET NOCOUNT ON;
|
|
|
|
With inv as (
|
|
SELECT TOP(1)
|
|
[Id] = CAST([id] as varchar(15)), [InvoiceId], [DocumentName]
|
|
FROM [dbo].[fds__invoices]
|
|
WHERE [id] = @InvId
|
|
), inv2 as(
|
|
SELECT * FROM inv
|
|
UNION
|
|
SELECT TOP(1)
|
|
[Id] = CAST([id] as varchar(15)), [InvoiceId], [DocumentName]
|
|
FROM [dbo].[mfr__invoices] as mi
|
|
WHERE NOT EXISTS( SELECT 0 FROM inv )
|
|
AND TRY_CAST(@InvId as bigint) is not null
|
|
AND mi.[id] = TRY_CAST(@InvId as bigint)
|
|
)
|
|
SELECT rem.[Id]
|
|
,rem.[DateSent]
|
|
,[status] = CAST(CASE WHEN rem.[isSent] = 1 THEN 'versandt' WHEN rem.[isfinal] = 1 THEN 'fertig' WHEN rem.isfinal = 0 THEN 'Entwurf' ELSE '' END AS varchar(50))
|
|
,rem.[subject]
|
|
,rem.[DocumentName]
|
|
,rem.[amount_open]
|
|
,rem.[InvId]
|
|
,[InvoiceId] = inv2.[InvoiceId]
|
|
--,[InvoiceDocumentName] = inv2.[DocumentName]
|
|
,[hasFile] = cast( IIF(rem.[file] is null, 0, 1) as bit)
|
|
FROM [dbo].[fds__reminder] as rem
|
|
LEFT JOIN inv2 on rem.[InvId] = inv2.[Id]
|
|
WHERE [invId] = @InvId;
|
|
|
|
END |