fix(drafts): serialize draft session flushes and register reminders via fds__setReminder
Playwright Tests / test (push) Canceled after 0s

Make invoice/reminder live-draft edits concurrency-safe with an explicit
DraftFlushResult, add the fds__setReminder stored procedure, and harden the
date helper functions. Includes concurrency and SQL contract tests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Stefan
2026-10-01 13:57:40 +02:00
co-authored by Claude Fable 5.1
parent d0002ccdad
commit 546648533b
21 changed files with 813 additions and 140 deletions
@@ -1,5 +1,9 @@
CREATE FUNCTION[dbo].[AddBusinessDays](@Date DATE,@n INT)
RETURNS DATE AS
-- INLINE = OFF: scalar UDF inlining of this @@DATEFIRST arithmetic (reached via date_add /
-- date_addcustom) killed dashboard widget queries with error 596 ("session is in the kill state").
CREATE FUNCTION[dbo].[AddBusinessDays](@Date DATE,@n INT)
RETURNS DATE
WITH INLINE = OFF
AS
BEGIN
DECLARE @d INT,@f INT,@DW INT;
SET @f=CAST(abs(1^SIGN(DATEPART(DW, @Date)-(7-@@DATEFIRST))) AS BIT)
@@ -2,6 +2,9 @@
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- INLINE = OFF: scalar UDF inlining of this IF/nested-UDF body (-> AddBusinessDays)
-- killed the dashboard widget queries with error 596 ("session is in the kill
-- state", class 21). Called with constant arguments, so per-row cost is negligible.
-- =============================================
CREATE FUNCTION [dbo].[date_add]
(
@@ -10,6 +13,7 @@ CREATE FUNCTION [dbo].[date_add]
,@shift_to_first bit = 1
)
RETURNS date
WITH INLINE = OFF
AS
BEGIN
DECLARE @Ret date = @date;
@@ -2,6 +2,8 @@
-- Author: <Author,,Name>
-- Create date: <Create Date, ,>
-- Description: <Description, ,>
-- INLINE = OFF: scalar UDF inlining (nested -> AddBusinessDays) killed the dashboard
-- widget queries with error 596 ("session is in the kill state", class 21).
-- =============================================
CREATE FUNCTION [dbo].[date_addcustom]
(
@@ -9,6 +11,7 @@ CREATE FUNCTION [dbo].[date_addcustom]
,@phrase varchar(10)
)
RETURNS date
WITH INLINE = OFF
AS
BEGIN
DECLARE @returndate date, @numpart integer = TRY_PARSE(left(@phrase, patindex('%[^0-9]%', @phrase + '.') - 1) as integer), @defpart varchar(10) = LOWER(RIGHT(@phrase, LEN(@phrase) - patindex('%[^0-9]%', @phrase + '.') + 1));