diff --git a/CHANGELOG.md b/CHANGELOG.md index 60519dd..3327633 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ Toutes les modifications importantes du projet sont consignées ici. Le format s’inspire de [Keep a Changelog](https://keepachangelog.com/fr/1.1.0/) et le projet suit le [versionnage sémantique](https://semver.org/lang/fr/). +## [1.0.0-rc.13] — 2026-09-08 + +### Gestion du catalogue vétérinaire + +- ajout d’une commande de modification pour les tarifs vétérinaires déjà enregistrés (`#24`) ; +- ajout d’une suppression confirmée qui conserve les montants, libellés et remises des dépenses historiques. + ## [1.0.0-rc.12] — 2026-09-08 ### Tarifs d’adoption et environnement local diff --git a/HISTORIQUE.md b/HISTORIQUE.md index b04839e..842db0b 100644 --- a/HISTORIQUE.md +++ b/HISTORIQUE.md @@ -57,3 +57,7 @@ Ajout de critères d’accueil par salle et de quatre créneaux de tournée conf ## `1.0.0-rc.12` — Tarifs par espèce Remplacement des deux montants globaux par une grille d’adoption propre à chaque espèce, avec tarif fixe ou libre. + +## `1.0.0-rc.13` — Catalogue vétérinaire + +Ajout de la modification et de la suppression sécurisée des tarifs, sans altérer les dépenses historiques. diff --git a/VERSION b/VERSION index 884b1ae..624bf34 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0-rc.12 +1.0.0-rc.13 diff --git a/app/Controllers/SettingsController.php b/app/Controllers/SettingsController.php index 6496598..8b60de1 100644 --- a/app/Controllers/SettingsController.php +++ b/app/Controllers/SettingsController.php @@ -613,6 +613,27 @@ final class SettingsController } exit(); } + public static function deleteTariff(): void + { + self::admin(); + self::postOnly(); + $id = (int) ($_POST['id'] ?? 0); + $label = PricingService::deleteTariff($id); + if ($label === null) { + http_response_code(404); + echo h(t('error.tariff_not_found')); + return; + } + AuditService::log( + 'tariff_deleted', + '/settings/pricing/tariff/delete', + 'Tarif supprimé : ' . $label, + 'clinic_tariff', + $id, + ); + header('Location: /settings/pricing?saved=1'); + exit(); + } public static function saveAdoptionFees(): void { self::admin(); diff --git a/app/Routes/web.php b/app/Routes/web.php index 8ff30b2..3205883 100644 --- a/app/Routes/web.php +++ b/app/Routes/web.php @@ -329,6 +329,9 @@ switch ($path) { case '/settings/pricing/tariff': SettingsController::saveTariff(); break; + case '/settings/pricing/tariff/delete': + SettingsController::deleteTariff(); + break; case '/settings/pricing/discount': SettingsController::saveDiscount(); break; diff --git a/app/Services/PricingService.php b/app/Services/PricingService.php index 7ab7ac8..9b41b5b 100644 --- a/app/Services/PricingService.php +++ b/app/Services/PricingService.php @@ -54,6 +54,19 @@ final class PricingService } return (int) $rule[$sterilized ? 'fee_after_sterilization' : 'fee_before_sterilization']; } + + public static function deleteTariff(int $id): ?string + { + $db = DB::pdo(); + $stmt = $db->prepare('SELECT label FROM clinic_tariffs WHERE id=:id'); + $stmt->execute([':id' => $id]); + $label = $stmt->fetchColumn(); + if ($label === false) { + return null; + } + $db->prepare('DELETE FROM clinic_tariffs WHERE id=:id')->execute([':id' => $id]); + return (string) $label; + } public static function tariffs(bool $active = false): array { $w = $active ? 'WHERE ct.active=1 AND dc.deleted_at IS NULL' : ''; diff --git a/app/Views/evolutions.php b/app/Views/evolutions.php index 4793e2e..13f7036 100644 --- a/app/Views/evolutions.php +++ b/app/Views/evolutions.php @@ -31,9 +31,9 @@
Montants avant ou après stérilisation, avec possibilité de laisser le tarif libre.
+ 1.0.0-rc.13 +Tarifs modifiables ou supprimables tout en préservant les dépenses historiques.