From 8d3c2e34f42b8d237c75c022090052da46839cf0 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 26 Apr 2022 11:46:00 +0200 Subject: [PATCH] FIX Check field accountancy code customer is mandatory in mass action --- htdocs/compta/facture/class/facture.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 7ad0a8ed4bc..2134570ee2e 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2724,7 +2724,7 @@ class Facture extends CommonInvoice // Check for mandatory fields in thirdparty (defined into setup) if (!empty($this->thirdparty) && is_object($this->thirdparty)) { - $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL'); + $array_to_check = array('IDPROF1', 'IDPROF2', 'IDPROF3', 'IDPROF4', 'IDPROF5', 'IDPROF6', 'EMAIL', 'ACCOUNTANCY_CODE_CUSTOMER'); foreach ($array_to_check as $key) { $keymin = strtolower($key); if (!property_exists($this->thirdparty, $keymin)) { @@ -2756,6 +2756,15 @@ class Facture extends CommonInvoice return -1; } } + if ($key == 'ACCOUNTANCY_CODE_CUSTOMER') { + // Check for mandatory + if (!empty($conf->global->SOCIETE_ACCOUNTANCY_CODE_CUSTOMER_INVOICE_MANDATORY) && empty($this->thirdparty->code_compta)) { + $langs->load("errors"); + $this->error = $langs->trans("ErrorAccountancyCodeCustomerIsMandatory", $this->thirdparty->name).' ('.$langs->trans("ForbiddenBySetupRules").')'; + dol_syslog(__METHOD__.' '.$this->error, LOG_ERR); + return -1; + } + } } } }