From 2e0929c2e9f9a1e3b4040133224dff1b97b706f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 16:08:00 +0100 Subject: [PATCH 1/5] FIX export ledger --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- htdocs/accountancy/tpl/export_journal.tpl.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index d945513f952..46d3feae5b2 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -125,7 +125,7 @@ class AccountancyExport * @param int $type Format id * @return string Format code */ - private static function getFormatCode($type) + public static function getFormatCode($type) { $formatcode = array( self::$EXPORT_TYPE_CONFIGURABLE => 'csv', diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 0dec55630d3..4537c497ff6 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -34,8 +34,10 @@ $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); header('Content-Type: text/csv'); +include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; +$accountancyexport = new AccountancyExport($db); -if ($this->getFormatCode($formatexportset) == "fec" && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger +if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$EXPORT_TYPE_FEC && $type_export == "general_ledger") // Specific filename for FEC model export into the general ledger { // FEC format is defined here: https://www.legifrance.gouv.fr/affichCodeArticle.do?idArticle=LEGIARTI000027804775&cidTexte=LEGITEXT000006069583&dateTexte=20130802&oldAction=rechCodeArticle if (empty($search_date_end)) From f3e27695e23a6740898a8e03bbbf05e3cd684fe8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 16:30:39 +0100 Subject: [PATCH 2/5] FIX Avoid deletion of bank record if in accounting --- htdocs/compta/bank/bankentries_list.php | 7 ++++++- htdocs/compta/bank/class/account.class.php | 24 +++++++++++++++++++++- htdocs/langs/en_US/errors.lang | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index db9f9443f0e..297f0dd91d4 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -353,8 +353,13 @@ if (GETPOST('save') && !$cancel && $user->rights->banque->modifier) if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) { $accline = new AccountLine($db); - $result = $accline->fetch(GETPOST("rowid")); + $result = $accline->fetch(GETPOST("rowid", "int")); $result = $accline->delete($user); + if ($result <= 0) { + setEventMessages($accline->error, $accline->errors, 'errors'); + } else { + setEventMessages('RecordDeleted', null, 'mesgs'); + } } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 594cad56ea0..b8acb7adc63 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1883,13 +1883,15 @@ class AccountLine extends CommonObject } /** - * Delete transaction bank line record + * Delete bank transaction record * * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ public function delete(User $user = null) { + global $conf; + $nbko = 0; if ($this->rappro) @@ -1901,6 +1903,26 @@ class AccountLine extends CommonObject $this->db->begin(); + // Protection to avoid any delete of accounted lines. Protection on by default + if (empty($conf->global->BANK_ALLOW_TRANSACTION_DELETION_EVEN_IF_IN_ACCOUNTING)) + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj && $obj->nb) { + $this->error = 'ErrorRecordAlreadyInAccountingDeletionNotPossible'; + $this->db->rollback(); + return -1; + } + } + else { + $this->error = $this->db->lasterror(); + $this->db->rollback(); + return -1; + } + } + // Delete urls $result = $this->delete_urls($user); if ($result < 0) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 4edca737c66..525131b2a61 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -227,6 +227,7 @@ ErrorNoFieldWithAttributeShowoncombobox=No fields has property 'showoncombobox' ErrorFieldRequiredForProduct=Field '%s' is required for product %s ProblemIsInSetupOfTerminal=Problem is in setup of terminal %s. ErrorAddAtLeastOneLineFirst=Add at least one line first +ErrorRecordAlreadyInAccountingDeletionNotPossible=Error, record is already transferred in accounting, deletion is not possible. # Warnings WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup. WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. From 80f4e625bef47319c7020d5acac11e847828b54f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 17:07:42 +0100 Subject: [PATCH 3/5] Fix phpcs --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2e5583610db..a3771d53cff 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -213,7 +213,7 @@ function societe_prepare_head(Societe $object) } else { $sql .= " AND (n.stripe_card_ref IS NULL OR (n.stripe_card_ref IS NOT NULL AND n.status = ".$servicestatus."))"; } - + $resql = $db->query($sql); if ($resql) { From 4f3cc8707778c9eab3ed832e1acad5735da76aca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 19:23:00 +0100 Subject: [PATCH 4/5] FIX Confusion between 'bank reconciled' and 'accounted'. Show both data --- htdocs/compta/bank/class/account.class.php | 23 +++++++++++++++++----- htdocs/compta/paiement/card.php | 4 ++-- htdocs/core/lib/functions.lib.php | 8 ++++---- htdocs/langs/en_US/banks.lang | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b8acb7adc63..6fc0efbd6e0 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2272,11 +2272,11 @@ class AccountLine extends CommonObject /** - * Return clicable name (with picto eventually) + * Return clickable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $maxlen Longueur max libelle - * @param string $option Option ('showall') + * @param string $option Option ('', 'showall', 'showconciliated', 'showconciliatedandaccounted'). Options may be slow. * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ @@ -2294,7 +2294,7 @@ class AccountLine extends CommonObject if ($withpicto != 2) $result .= ($this->ref ? $this->ref : $this->rowid); $result .= $linkend; - if ($option == 'showall' || $option == 'showconciliated') $result .= ' ('; + if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') $result .= ' ('; if ($option == 'showall') { $result .= $langs->trans("BankAccount").': '; @@ -2304,12 +2304,25 @@ class AccountLine extends CommonObject $accountstatic->label = $this->bank_account_label; $result .= $accountstatic->getNomUrl(0).', '; } - if ($option == 'showall' || $option == 'showconciliated') + if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') { $result .= $langs->trans("BankLineConciliated").': '; $result .= yn($this->rappro); } - if ($option == 'showall' || $option == 'showconciliated') $result .= ')'; + if ($option == 'showall' || $option == 'showconciliatedandaccounted') + { + $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_bookkeeping WHERE doc_type = 'bank' AND fk_doc = ".$this->id; + $resql = $this->db->query($sql); + if ($resql) { + $obj = $this->db->fetch_object($resql); + if ($obj && $obj->nb) { + $result .= ' - '.$langs->trans("Accounted").': '.yn(1); + } else { + $result .= ' - '.$langs->trans("Accounted").': '.yn(0); + } + } + } + if ($option == 'showall' || $option == 'showconciliated' || $option == 'showconciliatedandaccounted') $result .= ')'; return $result; } diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index edc76de0698..887fe2ec570 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -222,7 +222,7 @@ print ''; // Payment type (VIR, LIQ, ...) $labeltype = $langs->trans("PaymentType".$object->type_code) != ("PaymentType".$object->type_code) ? $langs->trans("PaymentType".$object->type_code) : $object->type_label; print ''.$langs->trans('PaymentMode').''.$labeltype; -print $object->num_paiement ? ' - '.$object->num_paiement : ''; +print $object->num_payment? ' - '.$object->num_payment : ''; print ''; // Amount @@ -297,7 +297,7 @@ if (!empty($conf->banque->enabled)) print ''; print ''.$langs->trans('BankTransactionLine').''; print ''; - print $bankline->getNomUrl(1, 0, 'showconciliated'); + print $bankline->getNomUrl(1, 0, 'showconciliatedandaccounted'); print ''; print ''; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index a0db5c8333d..b05cc41ea5d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5344,10 +5344,10 @@ function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $id /** * Return yes or no in current language * - * @param string $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false') - * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No - * @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color. - * @return string HTML string + * @param string|int $yesno Value to test (1, 'yes', 'true' or 0, 'no', 'false') + * @param integer $case 1=Yes/No, 0=yes/no, 2=Disabled checkbox, 3=Disabled checkbox + Yes/No + * @param int $color 0=texte only, 1=Text is formated with a color font style ('ok' or 'error'), 2=Text is formated with 'ok' color. + * @return string HTML string */ function yn($yesno, $case = 1, $color = 0) { diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index c160b4ae1d2..e54239e9fb2 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -95,7 +95,7 @@ AddBankRecordLong=Add entry manually Conciliated=Reconciled ConciliatedBy=Reconciled by DateConciliating=Reconcile date -BankLineConciliated=Entry reconciled +BankLineConciliated=Entry reconciled with bank receipt Reconciled=Reconciled NotReconciled=Not reconciled CustomerInvoicePayment=Customer payment From 1ef978ccc4a0eb21ecb649e15f11ff05d5fe0070 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 5 Feb 2020 19:32:49 +0100 Subject: [PATCH 5/5] FIX #12966 --- htdocs/theme/md/style.css.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 65436182755..1681c48e4e1 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -923,7 +923,8 @@ div.fiche>form>div.div-table-responsive { flex-grow: 1; flex-shrink: 1; /* flex-basis: 140px; */ - min-width: 150px; + /* min-width: 150px; */ + width: 158px; justify-content: flex-start; align-self: flex-start; }