سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 22:00 UTC
test: align D3 bypass guard contract
davoodmehraban89 committed
Oct 2, 2026 at 01:13 UTC
857d2bf963bf5ecd215d783780b70cf4a8c4a068
1 file changed
+5
-5
supabase/migrations/20261002003000_request_legacy_transition_hardening.sql
+5
-5
@@ -25,7 +25,7 @@ begin
25
raise exception 'idempotency_key is required';
26
end if;
27
28
- -- Lock and authorize the request before consulting idempotency evidence. The old
28
+ -- Lock and authorize the request before consulting idempotency evidence. The old
29
-- implementation returned an event first, which could disclose another actor's result.
30
select * into v_row
31
from public.request_instances r
@@ -39,10 +39,10 @@ begin
39
raise exception 'active requests_workflow entitlement required' using errcode='42501';
40
end if;
41
42
- -- D3 workflows are governed exclusively by request_step_decide. Keeping this legacy
42
+ -- D3 workflows are governed exclusively by request_step_decide. Keeping this legacy
43
-- endpoint usable for them would let an approver skip ordered/quorum/condition controls.
44
if exists(select 1 from private.request_step_instances s where s.request_instance_id=v_row.id) then
45
- raise exception 'legacy transition disabled for step workflow' using errcode='42501';
45
+ raise exception 'D3 workflow requires request_step_decide' using errcode='55000';
46
end if;
47
48
v_action:=lower(trim(coalesce(p_action,'')));
@@ -50,7 +50,7 @@ begin
50
raise exception 'unsupported transition action';
51
end if;
52
53
- -- Decision actions require approve. Edit alone is not an approval authority.
53
+ -- Decision actions require approve. Edit alone is not an approval authority.
54
if v_action in ('approve','reject','return') then
55
if not private.has_org_capability(v_row.organization_id,'requests_workflow','approve') then
56
raise exception 'requests_workflow approve capability required' using errcode='42501';
@@ -85,7 +85,7 @@ begin
85
raise exception 'terminal request cannot transition';
86
end if;
87
88
- -- Explicit legacy state machine. In particular, a returned request cannot be approved
88
+ -- Explicit legacy state machine. In particular, a returned request cannot be approved
89
-- without being resubmitted, and draft/returned requests cannot be rejected directly.
90
v_next:=case
91
when v_action='approve' and v_row.status='submitted' then 'approved'