Files
accounted/supabase/migrations/20260517105000_signature_delete_blocks_declined.sql
Mattsson a652dcae1a Skv/e2e overview (#515)
* feat(agi): refactor AGI XML generation and data handling

- Remove deprecated AGI field codes from field-codes.ts.
- Update generate-declaration.ts to include new employee fields and handle absence data with stable specification numbers.
- Enhance XML generation in xml-generator.ts to support new flags for housing benefits and adjusted benefits.
- Introduce new database migrations to support:
  - `removed_from_agi` flag for tombstoning individuppgifter.
  - `benefits_adjusted` flag for tracking adjustments to benefits.
  - `franvaro_specifikationsnummer` for stable absence event identification.
  - `housing_benefit_type` to differentiate between housing benefit types.

* feat: Implement strict validation for AGI employee data and introduce pre-flight validation schemas

- Added Zod schemas for validating employee data in AGI declarations to ensure all required fields are present and correctly typed, preventing silent errors during processing.
- Introduced AGI pre-flight validation schemas for Skatteverket endpoints to validate individual and head unit submissions before sending to the API.
- Created a new audit log table for tracking all outbound calls to Skatteverket, ensuring compliance and traceability for AGI and moms submissions.
- Implemented advisory locks in the database to manage concurrent updates to absence specification numbers, enhancing data integrity.
- Added compliance documentation for GDPR processing activities related to AGI and moms submissions, detailing data handling and retention policies.

* feat: Extend DELETE RLS policy to protect 'declined' signatures in årsredovisning

* fix: Update date handling in salary absence migrations to use immutable year-month key

* fix: Update SELECT policy in skatteverket_api_audit_log to use IN clause for company_id

* feat: Add skatteverket_api_audit_log and salary_absence_franvaro_audit tables with RLS policies and immutable triggers
2026-05-17 23:52:49 +02:00

17 lines
763 B
SQL

-- A 'declined' signature is auditable evidence: it records that a board
-- member refused to sign the årsredovisning, which is material under ABL 8
-- kap (board-member liability) and may be relevant in a Bolagsverket review.
-- The original migration (20260516170000) only blocked DELETE on 'signed'
-- rows. Extend the DELETE RLS policy to also protect 'declined' so the
-- evidence trail can't be silently wiped.
DROP POLICY IF EXISTS "arsredovisning_sigreq_delete" ON public.arsredovisning_signature_requests;
CREATE POLICY "arsredovisning_sigreq_delete" ON public.arsredovisning_signature_requests
FOR DELETE USING (
company_id IN (SELECT public.user_company_ids())
AND status NOT IN ('signed', 'declined')
);
NOTIFY pgrst, 'reload schema';