@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / b97674f
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 00:30 UTC

fix(db): preserve posted payroll and petty cash source guards

davoodmehraban89 committed Nov 17, 2026 at 21:33 UTC b97674f1e599e7e8dd8c8993e0dccbe3c1415aa8
1 file changed +4 -1
supabase/migrations/20261117120000_wp1_stage3_canonical_source_link_projection.sql
+4 -1
@@ -102,7 +102,8 @@ DECLARE
102 'accountingPostingPending','accountingPostingPendingAt'
103 ]::text[];
104 BEGIN
105 - IF old.collection NOT IN ('invoices','purchases','payments','expenses','cheques','contractStatements') THEN
105 + IF old.collection NOT IN ('invoices','purchases','payments','expenses','cheques','contractStatements',
106 + 'payrollRuns','employeeBenefitAccruals','pettyCashTransactions') THEN
107 RETURN CASE WHEN tg_op='DELETE' THEN old ELSE new END;
108 END IF;
109
@@ -158,6 +159,8 @@ BEGIN
159 coalesce(old.data->>'accountingStatus','')='posted'
160 OR (old.collection='cheques' and coalesce(old.data->>'status','') in ('cleared','bounced','cancelled'))
161 OR (old.collection='contractStatements' and coalesce(old.data->>'status','') in ('posted','reversed'))
162 + OR (old.collection IN ('payrollRuns','employeeBenefitAccruals','pettyCashTransactions')
163 + AND coalesce(old.data->>'status','') IN ('posted','reversed'))
164 OR voucher_status in ('posted','reversed');
165
166 IF NOT source_locked THEN