Files
accounted/supabase/migrations/20260517110000_salary_run_employees_benefits_adjusted.sql
T
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

18 lines
925 B
SQL

-- Flag for AGI FK048 FormanHarJusterats — emitted on an IU when a benefit
-- value has been adjusted away from the schablon (e.g. car benefit reduced
-- because the employee uses the car less than the standard assumption, or
-- a housing benefit set below the typical jämförelsehyra). Skatteverket
-- expects the flag set whenever any förmånsvärde on the IU has been
-- justerat downward — they may follow up with questions.
--
-- We track it per salary_run_employees row because adjustments are decided
-- and recorded at run time, not on the employee master.
ALTER TABLE salary_run_employees
ADD COLUMN benefits_adjusted BOOLEAN NOT NULL DEFAULT false;
COMMENT ON COLUMN salary_run_employees.benefits_adjusted IS
'When true, the AGI XML emits FK048 FormanHarJusterats=1 on this IU. Set when any förmånsvärde on the row has been adjusted away from the standard schablon.';
NOTIFY pgrst, 'reload schema';