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:
@@ -0,0 +1,72 @@
|
||||
|
||||
|
||||
-- =============================================
|
||||
-- Author: <Author,,Name>
|
||||
-- Create date: <Create Date,,>
|
||||
-- Description: <Description,,>
|
||||
-- =============================================
|
||||
CREATE PROCEDURE [dbo].[fds__r_getBalanceByYearTopMaterial]
|
||||
@year int,
|
||||
|
||||
@authuser varchar(100)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
|
||||
DECLARE @today date = GETDATE()
|
||||
DECLARE @tomorrow date = DATEADD(DAY,1,@today);
|
||||
|
||||
IF [dbo].[fis_getModuleAuth]('fds_reports', @authuser) < 2
|
||||
THROW 60000, N'not authorized', 1;
|
||||
|
||||
DECLARE @Admin [dbo].[fds__tt__admin_ReportAdminTable];
|
||||
|
||||
--Admin Table
|
||||
INSERT INTO @Admin
|
||||
VALUES (
|
||||
'bbm'
|
||||
,'Umsatz der Top 10 Materialien für Jahr ' + CAST( @year as varchar(10))
|
||||
,'Umsatz der Top 10 Materialien für Jahr ' + CAST( @year as varchar(10))
|
||||
,'' + FORMAT(GETDATE(), 'yyyy-MM-dd HH:mm')
|
||||
,''
|
||||
,'table' --typ
|
||||
, '' --settings
|
||||
, ''
|
||||
, 0);
|
||||
|
||||
SELECT * FROM @Admin;
|
||||
|
||||
|
||||
WITH inv as(
|
||||
SELECT
|
||||
[itmPrice] = SUM( ISNULL(itm.[value_total],0) )
|
||||
,[Dateofcreation] = CAST(_i.[DateCreated] as date)
|
||||
,[material] = itm.[text]
|
||||
,[seq] = ROW_NUMBER() OVER (ORDER BY CAST(_i.[DateCreated] as date))
|
||||
FROM [dbo].[fds__invoices] as _i
|
||||
JOIN [fds__invoice_items] as itm on itm.[invid] = _i.[id] AND itm.[Type] like 'Material'
|
||||
where YEAR(_i.[DateCreated]) = @year and _i.[isfinal] = 1
|
||||
GROUP BY CAST(_i.[DateCreated] as date), itm.[text]
|
||||
), yr1 as (
|
||||
SELECT
|
||||
[year] = YEAR( _i.[DateCreated] )
|
||||
, [total] = SUM( ISNULL(_i.[InvoiceBalance],0) )
|
||||
FROM [dbo].[fds__invoices] as _i
|
||||
WHERE _i.[isfinal] = 1
|
||||
GROUP BY YEAR( _i.[DateCreated])
|
||||
), yr as (
|
||||
SELECT [year], [total] = SUM([total])
|
||||
from yr1 GROUP BY [year]
|
||||
)
|
||||
SELECT TOP(10)
|
||||
[Jahr] = CAST( YEAR( inv.[Dateofcreation] ) as varchar(4))
|
||||
, [Material] = [material]
|
||||
, [∑ Umsätze] = FORMAT( SUM( ISNULL(inv.[itmPrice],0) ), '#,0.00 €', 'de')
|
||||
, [style:∑ Umsätze] = 'text-align: right'
|
||||
, [% Anteil] = CASE WHEN yr.[total] > 0 THEN FORMAT( SUM( ISNULL(inv.[itmPrice],0) ) / [total], '0 %', 'de') ELSE NULL END
|
||||
, [style:% Anteil] = 'text-align: right'
|
||||
, [order] = ROW_NUMBER() OVER ( ORDER By SUM( ISNULL(inv.[itmPrice],0) ) DESC)
|
||||
FROM inv LEFT JOIN yr on YEAR( inv.[Dateofcreation] ) = yr.[year]
|
||||
GROUP BY YEAR( inv.[Dateofcreation] ), yr.[total], [material];
|
||||
|
||||
END
|
||||
Reference in New Issue
Block a user