From ae1586fcc6c9601b7d54a4740d45bc2649cb1f86 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 26 Apr 2021 10:48:50 +0200 Subject: [PATCH] FIX : We must not be able to delete sociale charge, vat or salary if there are payments --- htdocs/compta/sociales/card.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 0f38181e284..7454f61f6de 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -134,12 +134,17 @@ if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { // Delete social contribution if ($action == 'confirm_delete' && $confirm == 'yes') { $object->fetch($id); - $result = $object->delete($user); - if ($result > 0) { - header("Location: list.php"); - exit; + $totalpaye = $object->getSommePaiement(); + if (empty($totalpaye)) { + $result = $object->delete($user); + if ($result > 0) { + header("Location: list.php"); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors'); } } @@ -771,8 +776,10 @@ if ($id > 0) { } // Delete - if ($user->rights->tax->charges->supprimer) { + if ($user->rights->tax->charges->supprimer && empty($totalpaye)) { print '
'.$langs->trans("Delete").'
'; + } else { + print '
'.$langs->trans("Delete").'
'; } print "";