From 183d413b4529418a74920bb11f95077cf05f8750 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 26 Jul 2021 04:42:35 +0200 Subject: [PATCH 1/2] FIX: Accountancy - Rules to delete & modify transaction not applied in ledger & subledger --- htdocs/accountancy/bookkeeping/card.php | 4 ++-- htdocs/accountancy/bookkeeping/list.php | 2 +- htdocs/accountancy/bookkeeping/listbyaccount.php | 8 +++++--- htdocs/accountancy/bookkeeping/listbysubaccount.php | 8 +++++--- htdocs/accountancy/class/bookkeeping.class.php | 1 + 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4c7194b2255..3e74cd0c212 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -683,7 +683,7 @@ if ($action == 'create') { print ''.price($line->debit).''; print ''.price($line->credit).''; - if (empty($line->date_export) || empty($line->date_validation)) { + if (empty($line->date_export) && empty($line->date_validation)) { print ''; print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; print img_edit('', 0, 'class="marginrightonly"'); @@ -713,7 +713,7 @@ if ($action == 'create') { setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); } - if (empty($object->date_export) || empty($object->date_validation)) { + if (empty($object->date_export) && empty($object->date_validation)) { if ($action == "" || $action == 'add') { print ''; print ''; diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index a70bb710937..ebc91ae54c7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -1243,7 +1243,7 @@ while ($i < min($num, $limit)) { // Action column print ''; - if (empty($line->date_export) || empty($line->date_validation)) { + if (empty($line->date_export) && empty($line->date_validation)) { if ($user->rights->accounting->mouvements->creer) { print '' . img_edit() . ''; } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 98c3f14191b..63ecc2d420b 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -852,12 +852,14 @@ while ($i < min($num, $limit)) { // Action column print ''; - if (empty($line->date_export)) { + if (empty($line->date_export) && empty($line->date_validation)) { if ($user->rights->accounting->mouvements->creer) { - print ''.img_edit().''; + print '' . img_edit() . ''; } + } + if (empty($line->date_validation)) { if ($user->rights->accounting->mouvements->supprimer) { - print '   '.img_delete().''; + print ''.img_delete().''; } } print ''; diff --git a/htdocs/accountancy/bookkeeping/listbysubaccount.php b/htdocs/accountancy/bookkeeping/listbysubaccount.php index 20899c693c6..434867112f9 100644 --- a/htdocs/accountancy/bookkeeping/listbysubaccount.php +++ b/htdocs/accountancy/bookkeeping/listbysubaccount.php @@ -866,12 +866,14 @@ while ($i < min($num, $limit)) { // Action column print ''; - if (empty($line->date_export)) { + if (empty($line->date_export) && empty($line->date_validation)) { if ($user->rights->accounting->mouvements->creer) { - print ''.img_edit().''; + print '' . img_edit() . ''; } + } + if (empty($line->date_validation)) { if ($user->rights->accounting->mouvements->supprimer) { - print '   '.img_delete().''; + print ''.img_delete().''; } } print ''; diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 6bd39f4e227..aeaa42154d8 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -1506,6 +1506,7 @@ class BookKeeping extends CommonObject $sql = "DELETE"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE piece_num = ".(int) $piecenum; + $sql .= " AND date_validated IS NULL"; // For security, exclusion of validated entries at the time of deletion $sql .= " AND entity IN (".getEntity('accountancy').")"; $resql = $this->db->query($sql); From 35862cebfa10256e29b70255048ad164e908d4a4 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 26 Jul 2021 04:49:56 +0200 Subject: [PATCH 2/2] Fix card presentation --- htdocs/accountancy/bookkeeping/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 3e74cd0c212..c156a388735 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -637,6 +637,8 @@ if ($action == 'create') { print_liste_field_titre("Credit", "", "", "", "", 'class="right"'); if (empty($object->date_validation)) { print_liste_field_titre("Action", "", "", "", "", 'width="60" class="center"'); + } else { + print_liste_field_titre(""); } print "\n"; @@ -683,8 +685,8 @@ if ($action == 'create') { print ''.price($line->debit).''; print ''.price($line->credit).''; + print ''; if (empty($line->date_export) && empty($line->date_validation)) { - print ''; print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; print img_edit('', 0, 'class="marginrightonly"'); print '  ';