espace-paie-odentas/migrations/fix_structure_field_from_production.sql
odentas 266eb3598a feat: Implémenter store global Zustand + calcul total quantités + fix structure field + montants personnalisés virements
- Créer hook useStaffOrgSelection avec persistence localStorage
- Ajouter badge StaffOrgBadge dans Sidebar
- Synchroniser filtres org dans toutes les pages (contrats, cotisations, facturation, etc.)
- Fix calcul cachets: utiliser totalQuantities au lieu de dates.length
- Fix structure field bug: ne plus écraser avec production_name
- Ajouter création note lors modification contrat
- Implémenter montants personnalisés pour virements salaires
- Migrations SQL: custom_amount + fix_structure_field
- Réorganiser boutons ContractEditor en carte flottante droite
2025-12-01 21:51:57 +01:00

33 lines
1.1 KiB
SQL

-- Migration pour corriger les contrats où structure = production_name
-- Ces contrats ont été créés/modifiés avec un bug qui mettait la production dans structure
-- Mettre à jour le contrat "La Nuit avant Noël" spécifique
UPDATE cddu_contracts
SET structure = organizations.name
FROM organizations
WHERE cddu_contracts.org_id = organizations.id
AND cddu_contracts.id = '9240863d-be8a-449a-918f-68a77eff3bed'
AND cddu_contracts.structure = 'La Nuit avant Noël';
-- Corriger tous les autres contrats potentiellement affectés
-- (où structure = production_name et structure != organization.name)
UPDATE cddu_contracts
SET structure = organizations.name
FROM organizations
WHERE cddu_contracts.org_id = organizations.id
AND cddu_contracts.structure = cddu_contracts.production_name
AND cddu_contracts.structure != organizations.name;
-- Vérification: afficher les contrats mis à jour
SELECT
id,
contract_number,
structure,
production_name,
org_id,
employee_name,
start_date
FROM cddu_contracts
WHERE structure != (SELECT name FROM organizations WHERE id = cddu_contracts.org_id)
ORDER BY created_at DESC
LIMIT 20;