diff --git a/web/modules/custom/figli_compta_ledger/src/Controller/LedgerActionsController.php b/web/modules/custom/figli_compta_ledger/src/Controller/LedgerActionsController.php index 52ead26..5e3b8d7 100644 --- a/web/modules/custom/figli_compta_ledger/src/Controller/LedgerActionsController.php +++ b/web/modules/custom/figli_compta_ledger/src/Controller/LedgerActionsController.php @@ -66,12 +66,26 @@ class LedgerActionsController extends ControllerBase { $node->set('field_entree_liee', NULL); } + // Only field_type_ligne (and possibly field_entree_liee) changes here + // -- montant_ht and field_repartition are untouched, so this can never + // *introduce* a répartition mismatch, only leave a pre-existing one + // (from historical data, never corrected -- see figli_compta_ledger's + // module docblock) exactly as it was. The présave check exists to + // catch new inconsistent entries, not to block relabeling the type of + // an already-migrated line, so skip it for this save only. try/finally + // guarantees the global flag clears even if save() throws for an + // unrelated reason -- leaving it on would silently skip validation on + // every other save on the site. + \Drupal::state()->set('figli_compta_ledger.skip_validation', TRUE); try { $node->save(); } catch (EntityStorageException $e) { return new JsonResponse(['error' => $e->getMessage()], 422); } + finally { + \Drupal::state()->delete('figli_compta_ledger.skip_validation'); + } return new JsonResponse([ 'success' => TRUE,