diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 02b95cfd043..535463822db 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -41,7 +41,7 @@ $ref = GETPOST('ref', 'alpha'); $rowid = GETPOST('rowid', 'int'); $cancel = GETPOST('cancel', 'alpha'); -$account_number = GETPOST('account_number', 'string'); +$account_number = GETPOST('account_number', 'alphanohtml'); $label = GETPOST('label', 'alpha'); // Security check diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 7ae48c749c2..d6e0d675a0e 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -743,7 +743,7 @@ class AccountancyCategory // extends CommonObject } $listofaccount .= "'".$cptcursor."'"; } - $sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount).")"; + $sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount, 1).")"; } else { $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; } @@ -861,20 +861,29 @@ class AccountancyCategory // extends CommonObject exit(); } + $pcgverid = $conf->global->CHARTOFACCOUNTS; + $pcgvercode = dol_getIdFromCode($this->db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version'); + if (empty($pcgvercode)) { + $pcgvercode = $pcgverid; + } + if (!empty($cat_id)) { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE t.fk_accounting_category = ".((int) $cat_id); $sql .= " AND t.entity = ".$conf->entity; + $sql .= " AND t.active = 1"; + $sql .= " AND t.fk_pcg_version = '".$this->db->escape($pcgvercode)."'"; $sql .= " ORDER BY t.account_number"; } else { $sql = "SELECT t.rowid, t.account_number, t.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " WHERE ".$predefinedgroupwhere; $sql .= " AND t.entity = ".$conf->entity; + $sql .= ' AND t.active = 1'; + $sql .= " AND t.fk_pcg_version = '".$this->db->escape($pcgvercode)."'"; $sql .= " ORDER BY t.account_number"; } - //echo $sql; $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 405a630942e..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++; } } @@ -655,7 +658,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); 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'); + } } } } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ed5e4c06b3d..774ade233bd 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -512,7 +512,7 @@ $tabcond[25] = !empty($conf->website->enabled); $tabcond[27] = !empty($conf->societe->enabled); $tabcond[28] = !empty($conf->holiday->enabled); $tabcond[29] = !empty($conf->project->enabled); -$tabcond[30] = !empty($conf->label->enabled); +$tabcond[30] = (isModEnabled('label') || isModEnabled('barcode') || isModEnabled('adherent')); // stickers format dictionary //$tabcond[31]= !empty($conf->accounting->enabled); $tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled)); $tabcond[33] = !empty($conf->hrm->enabled); diff --git a/htdocs/blockedlog/README-fr.md b/htdocs/blockedlog/README-fr.md index e92bd5a09fe..a5d709ca7a7 100644 --- a/htdocs/blockedlog/README-fr.md +++ b/htdocs/blockedlog/README-fr.md @@ -4,7 +4,7 @@ LOG INALTERABLE ## Fonctionnalité Ce module trace, en temps réel, certains évènements métiers dans une log inaltérable (que vous ne pouvez pas modifier une fois enregistrés) de type blockchain. -Ce module est requis pour la compatibilité avec les exigences légales de certains pays (comme la France avec la loi Fincance 2016 - Norme NF535). +Ce module est requis pour la compatibilité avec les exigences légales de certains pays (comme la France avec la loi Finance 2016 - Norme NF525). **Les évènements tracés de manière inaltérables sont:** diff --git a/htdocs/blockedlog/README.md b/htdocs/blockedlog/README.md index ec3174fb847..7bd9b10787e 100644 --- a/htdocs/blockedlog/README.md +++ b/htdocs/blockedlog/README.md @@ -4,7 +4,7 @@ BLOCKED LOG ## Feature This module tracks, in real time, some events into a non reversible log (that you can't modify once recorded) into a block chain. -This module provides compatibility with requirements of laws of some countries (like France with the law Fincance 2016 - Norme NF535). +This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF525). **The tracked events are:** diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 7f9a1aa09c6..5c1cf64fced 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2019 Laurent Destailleur + * Copyright (C) 2023 Benjamin Falière * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1058,8 +1059,10 @@ class BOM extends CommonObject return -1; } $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); - if (empty($line->unit_cost)) { - if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { + if ((empty($line->unit_cost)) && ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0)) { + if ($productFournisseur->fourn_remise_percent != "0") { + $line->unit_cost = $productFournisseur->fourn_unitprice_with_discount; + } else { $line->unit_cost = $productFournisseur->fourn_unitprice; } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 27a301776b8..23495e9c5c1 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -11,6 +11,7 @@ * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2022 Frédéric France + * Copyright (C) 2023 Benjamin Falière * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1463,7 +1464,7 @@ class Categorie extends CommonObject $ways = array(); $parents = $this->get_meres(); - if (!empty($parents)) { + if (is_array($parents)) { foreach ($parents as $parent) { $allways = $parent->get_all_ways(); foreach ($allways as $way) { diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 1412890b3d8..b6c71989acc 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1261,7 +1261,7 @@ if ($action == 'create') { print "\n".'