From fd371cc52b517ea26f50d588cc2c8cf19bc520ce Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Fri, 24 Feb 2023 23:31:06 +0100 Subject: [PATCH 1/8] Fix member nature display in new.php --- htdocs/public/members/new.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index d3a2a556b07..aa8498a85a1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -539,6 +539,8 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); +print ''.$langs->trans('MemberNature').' *'."\n"; + if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { print ''.$langs->trans('MemberNature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); From a02e88dc281c0545150ecc7e9f2716a0787208a4 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 26 Feb 2023 22:18:30 +0100 Subject: [PATCH 2/8] Drop the double Must be displayed both in the if and else --- htdocs/public/members/new.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index aa8498a85a1..2df2ec45cbc 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -542,7 +542,6 @@ $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans('MemberNature').' *'."\n"; if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { - print ''.$langs->trans('MemberNature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); print ''."\n"; } else { From 1c57b755109a29f2dc3353d7b691287c7a090913 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:04:15 +0100 Subject: [PATCH 3/8] FIX: accountancy lettering: better error management --- htdocs/accountancy/journal/bankjournal.php | 6 ++++++ htdocs/accountancy/journal/purchasesjournal.php | 6 ++++++ htdocs/accountancy/journal/sellsjournal.php | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index a848f8505d8..85c9551b7ec 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -797,6 +797,12 @@ if (!$error && $action == 'writebookkeeping') { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); + + if ($nb_lettering < 0) { + $error++; + $errorforline++; + setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); + } } } } diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c175889357c..5f4182762dc 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -380,6 +380,12 @@ if ($action == 'writebookkeeping') { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'supplier_invoice'); + + if ($nb_lettering < 0) { + $error++; + $errorforline++; + setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); + } } } } diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index b86f138d232..cb6df055740 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -393,6 +393,13 @@ if ($action == 'writebookkeeping') { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id), 'customer_invoice'); + + if ($nb_lettering < 0) { + $error++; + $errorforline++; + $errorforinvoice[$key] = 'other'; + setEventMessages($lettering_static->error, $lettering_static->errors, 'errors'); + } } } } From 49afabd440d1db9fc68cc7ea02b285b6b927579e Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:16:04 +0100 Subject: [PATCH 4/8] FIX: accountancy lettering: prevent null results when fetching link with payments --- htdocs/accountancy/class/lettering.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 405a630942e..2f86d6e7e3a 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -655,7 +655,7 @@ class Lettering extends BookKeeping // Get payment lines $sql = "SELECT DISTINCT pe2.$fk_payment_element, pe2.$fk_element"; $sql .= " FROM " . MAIN_DB_PREFIX . "$payment_element AS pe"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element"; + $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "$payment_element AS pe2 ON pe2.$fk_element = pe.$fk_element"; $sql .= " WHERE pe.$fk_payment_element IN (" . $this->db->sanitize(implode(',', $payment_ids)) . ")"; dol_syslog(__METHOD__ . " - Get payment lines", LOG_DEBUG); From d3edbbb51bfead001c9095396a2a8418668f17d2 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 2 Mar 2023 15:56:10 +0100 Subject: [PATCH 5/8] FIX: accountancy lettering: correctly calculated number of lettering operations done --- htdocs/accountancy/class/lettering.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 2f86d6e7e3a..48e4eb56647 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -297,6 +297,7 @@ class Lettering extends BookKeeping // Update request $now = dol_now(); + $affected_rows = 0; if (!$error) { $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping SET"; @@ -309,6 +310,8 @@ class Lettering extends BookKeeping if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); + } else { + $affected_rows = $this->db->affected_rows($resql); } } @@ -320,7 +323,7 @@ class Lettering extends BookKeeping } return -1 * $error; } else { - return 1; + return $affected_rows; } } @@ -355,7 +358,7 @@ class Lettering extends BookKeeping } return -1 * $error; } else { - return 1; + return $this->db->affected_rows($resql); } } @@ -457,7 +460,7 @@ class Lettering extends BookKeeping else $result = $this->updateLettering($bookkeeping_lines); if ($result < 0) { $group_error++; - } else { + } elseif ($result > 0) { $nb_lettering++; } } From d9c47b93df3fbd2e77608899e26f07a75d385d71 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 5 Mar 2023 16:55:45 +0100 Subject: [PATCH 6/8] Revert "Drop the double " This reverts commit a02e88dc281c0545150ecc7e9f2716a0787208a4. --- htdocs/public/members/new.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 2df2ec45cbc..aa8498a85a1 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -542,6 +542,7 @@ $morphys["mor"] = $langs->trans("Moral"); print ''.$langs->trans('MemberNature').' *'."\n"; if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { + print ''.$langs->trans('MemberNature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); print ''."\n"; } else { From 7a7d1c2fb1d99d74294860efdbe5036b3b98c629 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 5 Mar 2023 16:58:45 +0100 Subject: [PATCH 7/8] Revert "Fix member nature display in new.php" This reverts commit fd371cc52b517ea26f50d588cc2c8cf19bc520ce. --- htdocs/public/members/new.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index aa8498a85a1..d3a2a556b07 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -539,8 +539,6 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCETYPE)) { // Moral/Physic attribute $morphys["phy"] = $langs->trans("Physical"); $morphys["mor"] = $langs->trans("Moral"); -print ''.$langs->trans('MemberNature').' *'."\n"; - if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { print ''.$langs->trans('MemberNature').' *'."\n"; print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); From ebac8ef1f1a07b9512ea99a276cb2626f7cc6c38 Mon Sep 17 00:00:00 2001 From: Yoan Mollard Date: Sun, 5 Mar 2023 17:06:32 +0100 Subject: [PATCH 8/8] Fix double morphy display when morphy is forced --- htdocs/public/members/new.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index d3a2a556b07..17234702e3c 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -544,7 +544,6 @@ if (empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY)) { print $form->selectarray("morphy", $morphys, GETPOST('morphy'), 1); print ''."\n"; } else { - print $morphys[$conf->global->MEMBER_NEWFORM_FORCEMORPHY]; print ''; }