Files
Fuchs_Intranet/Fuchs_Database/dbo/Stored Procedures/fds__r_getBalanceTrendByMonth.sql
T
Stefan c741535aec
Playwright Tests / test (push) Canceled after 0s
feat: Implement mfr truncation fix and enhance invoice handling
- Added a new SQL script to address the "String or binary data would be truncated" error in mfr sync by widening the Note fields in service objects and companies to NVARCHAR(MAX).
- Updated the table types and associated stored procedures to accommodate the changes, ensuring compatibility with existing data.
- Queued a re-sync for previously rejected rows due to truncation issues.
- Created application logins for fuchs_fds and fuchs_web with placeholder passwords for initial setup.
- Introduced functions for invoice backdating and invoice date retrieval to streamline invoice processing.
- Developed a password generation function with customizable parameters for length and character types.
- Added a random number generation function to support password creation.
2026-09-30 16:56:08 +02:00

64 lines
2.3 KiB
Transact-SQL

-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[fds__r_getBalanceTrendByMonth]
@year int
,@month 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;
set @month = ISNULL(@month, Month(@today));
set @year= ISNULL(@year, Year(@year));
DECLARE @Admin [dbo].[fds__tt__admin_ReportAdminTable];
--Admin Table
INSERT INTO @Admin
VALUES (
'bbm'
,'UmsatzTrend für Monat ' + FORMAT(@Month, '00') + ' / ' + FORMAT(@year, '0000')
,'UmsatzTrend für Monat ' + FORMAT(@Month, '00') + ' / ' + FORMAT(@year, '0000')
,'' + FORMAT(GETDATE(), 'yyyy-MM-dd HH:mm')
,''
,'chart' --typ
, '{ "charttype": "line", "x1_label_angle": -90, "color": "e0301e", "linewidth": 2, "valuelabels": false, "marker": "none", "colorpalette": "00B050;00B050;00B050", "x1_column": "date", "y1_column": "Value", "y1_title": "Actuals", "x1_title": "", "series_column": "series", "legend_position": "bottom", "show_datalabel": true, "datalabelfontsizescale": 0.6, "height": 600, "width": 1200, "x1_labelformat": "ddd, dd/MM"}' --settings
, ''
, 0)
SELECT * FROM @Admin;
with inv as(
select
[InvoiceBalance] = SUM( ISNULL(_i.[InvoiceBalance],0) )
,[Dateofcreation] = [dbo].[fds__fn_invoiceDate]([DateFinalized], [DateCreated])
,[seq] = ROW_NUMBER() OVER (ORDER BY [dbo].[fds__fn_invoiceDate]([DateFinalized], [DateCreated]))
FROM [dbo].[fds__invoices] as _i where _i.IsFinal = 1 and MONTH([dbo].[fds__fn_invoiceDate]([DateFinalized], [DateCreated])) = @Month and YEAR([dbo].[fds__fn_invoiceDate]([DateFinalized], [DateCreated])) = @year
GROUP BY [dbo].[fds__fn_invoiceDate]([DateFinalized], [DateCreated])
)
SELECT
--[Monat] = FORMAT( inv.[Dateofcreation], 'yyyy - MM', 'de')
--,[Umsatz] = FORMAT( ISNULL(inv.[InvoiceBalance],0) , '#0.00', 'de')
[series] = 'Umsatz'
,[date] = CAST(inv.[Dateofcreation] as date)
,[value] = CAST( SUM( ISNULL(inv.[InvoiceBalance],0) ) OVER (ORDER BY [seq]) as numeric(9,2))
FROM inv
ORDER BY [seq]
END