From aaa100d132ccd3cfd225d5a3943d0313b2ff6247 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Apr 2025 19:46:52 +0200 Subject: [PATCH 1/4] FIX HTML broken by the trunc. --- .../accountancy/class/bookkeeping.class.php | 35 +++++++++++++------ .../journal/expensereportsjournal.php | 6 ++-- .../accountancy/journal/purchasesjournal.php | 8 ++--- htdocs/accountancy/journal/sellsjournal.php | 10 +++--- 4 files changed, 36 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 52f40c64e44..42a2b14ec06 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2609,42 +2609,55 @@ class BookKeeping extends CommonObject } /** - * Generate label operation when operation is transferred into accounting + * Generate label operation when operation is transferred into accounting according to ACCOUNTING_LABEL_OPERATION_ON_TRANSFER + * If ACCOUNTING_LABEL_OPERATION_ON_TRANSFER is 0, we concat thirdparty name, ref and label. + * If ACCOUNTING_LABEL_OPERATION_ON_TRANSFER is 1, we concat thirdparty name, ref. + * If ACCOUNTING_LABEL_OPERATION_ON_TRANSFER is 2, we return just thirdparty name * * @param string $thirdpartyname Thirdparty name * @param string $reference Reference of the element * @param string $labelaccount Label of the accounting account + * @param string $full 0=Default, 1=Keep label intact (no trunc so HTML content is not corrupted) * @return string Label of the operation */ - public function accountingLabelForOperation($thirdpartyname, $reference, $labelaccount) + public function accountingLabelForOperation($thirdpartyname, $reference, $labelaccount, $full = 0) { - global $conf; - $accountingLabelOperation = ''; - if (!getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') || getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 0) { + if (!getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER')) { $truncThirdpartyName = 16; // Avoid trunc with dot in accountancy for the compatibility with another accounting software - $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (empty($full)) { + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } else { + $accountingLabelOperation = $thirdpartyname; + } if (!empty($reference)) { $accountingLabelOperation .= ' - '. $reference; } if (!empty($labelaccount)) { $accountingLabelOperation .= ' - '. $labelaccount; } - } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) { + } elseif (getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 1) { $truncThirdpartyName = 32; // Avoid trunc with dot in accountancy for the compatibility with another accounting software - $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (empty($full)) { + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } else { + $accountingLabelOperation = $thirdpartyname; + } if (!empty($reference)) { $accountingLabelOperation .= ' - '. $reference; } - } elseif (getDolGlobalString('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) { + } elseif (getDolGlobalInt('ACCOUNTING_LABEL_OPERATION_ON_TRANSFER') == 2) { $truncThirdpartyName = 64; // Avoid trunc with dot in accountancy for the compatibility with another accounting software - $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + if (empty($full)) { + $accountingLabelOperation = dol_trunc($thirdpartyname, $truncThirdpartyName, 'right', 'UTF-8', 1); + } else { + $accountingLabelOperation = $thirdpartyname; + } } - dol_syslog('label'.$accountingLabelOperation, LOG_ERR); return $accountingLabelOperation; } diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index 396b296de0e..286bfa61852 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -765,7 +765,7 @@ if (empty($action) || $action == 'view') { print ''; $userstatic->id = $tabuser[$key]['id']; $userstatic->name = $tabuser[$key]['name']; - print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -801,7 +801,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount"), 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -841,7 +841,7 @@ if (empty($action) || $action == 'view') { $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); - print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index c4c2fc50995..e4b25b33d61 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -1173,7 +1173,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount"), 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1216,7 +1216,7 @@ if (empty($action) || $action == 'view') { print ''; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1279,7 +1279,7 @@ if (empty($action) || $action == 'view') { $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate, 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1309,7 +1309,7 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)") . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)", 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 4256d72ab04..a1b96085ac6 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -1265,7 +1265,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty"), 1) . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print '' . ($mt < 0 ? price(-$mt) : '') . ""; print ""; @@ -1296,7 +1296,7 @@ if (empty($action) || $action == 'view') { print $accountoshow; } print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount"), 1) . ""; print ''.($mt >= 0 ? price($mt) : '').""; print ''.($mt < 0 ? price(-$mt) : '').""; print ""; @@ -1339,7 +1339,7 @@ if (empty($action) || $action == 'view') { print ''; $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label, 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1382,7 +1382,7 @@ if (empty($action) || $action == 'view') { $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ? '' : $arrayofvat[$key][$k]) : implode(', ', $def_tva[$key][$k])); $labelvatrate = $langs->trans("Taxes").' '.$tmpvatrate.' %'; $labelvatrate .= ($numtax ? ' - Localtax '.$numtax : ''); - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate, 1) . ""; print ''.($mt < 0 ? price(-$mt) : '').""; print ''.($mt >= 0 ? price($mt) : '').""; print ""; @@ -1411,7 +1411,7 @@ if (empty($action) || $action == 'view') { // Subledger account print ""; print ''; - print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp")) . ""; + print "" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp"), 1) . ""; print '' . ($mt < 0 ? price(-$mt) : '') . ""; print '' . ($mt >= 0 ? price($mt) : '') . ""; print ""; From 5d6942db9dafad82a8e6ff530739648800da489a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Apr 2025 19:54:17 +0200 Subject: [PATCH 2/4] css --- htdocs/accountancy/bookkeeping/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 9d099ed6805..b667057d043 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -872,7 +872,7 @@ if (!empty($arrayfields['t.piece_num']['checked'])) { // Code journal if (!empty($arrayfields['t.code_journal']['checked'])) { print ''; - print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'small maxwidth75'); + print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth75'); print ''; } // Date document @@ -888,7 +888,7 @@ if (!empty($arrayfields['t.doc_date']['checked'])) { } // Ref document if (!empty($arrayfields['t.doc_ref']['checked'])) { - print ''; + print ''; } // Accountancy account if (!empty($arrayfields['t.numero_compte']['checked'])) { From 54af0a152a9e7a0d8b153ab5c785de311c6d9355 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Apr 2025 21:32:28 +0200 Subject: [PATCH 3/4] Debug v22 --- htdocs/accountancy/journal/treasuryjournal.php | 8 ++++++-- htdocs/core/class/html.formaccounting.class.php | 9 +++++---- htdocs/langs/en_US/accountancy.lang | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/journal/treasuryjournal.php b/htdocs/accountancy/journal/treasuryjournal.php index 749ac197fd4..55c0c202ed2 100644 --- a/htdocs/accountancy/journal/treasuryjournal.php +++ b/htdocs/accountancy/journal/treasuryjournal.php @@ -1446,11 +1446,10 @@ if (empty($action) || $action == 'view') { print ''.$langs->trans("AccountingCredit").""; print "\n"; - $r = ''; - foreach ($tabpay as $payment_id => $payment) { $accountInfos = $tabaccount[$payment["fk_bank_account"]]; $date = dol_print_date($payment["date"], 'day'); + $i++; foreach ($payment['objects'] as $object_key => $object_data) { $objectInfos = $tabobject[$object_key]; @@ -1515,6 +1514,11 @@ if (empty($action) || $action == 'view') { } } + if (!$i) { + $colspan = 8; + print ''.$langs->trans("NoRecordFound").''; + } + print ""; print ''; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index d9bf2b0d800..5ece55be81c 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -673,15 +673,16 @@ class FormAccounting extends Form $out .= ''; $accounttoshow = length_accountg($accountAccounting); if (empty($accounttoshow) || $accounttoshow == 'NotDefined') { - $out .= ''.$langs->trans('BankAccountNotDefined').''; + // Could be ProductAccountNotDefined, VATAccountNotDefined, ... + $out .= ''.$langs->trans('AccountNotDefined').''; } else { $out .= $accounttoshow; } $out .= ''; $out .= ''.$labelOperation.''; - $out .= ''.$paymentMode.''; - $out .= ''.($amount >= 0 ? price($amount) : '').''; - $out .= ''.($amount < 0 ? price(-$amount) : '').''; + $out .= ''.$paymentMode.''; + $out .= ''.($amount >= 0 ? price($amount) : '').''; + $out .= ''.($amount < 0 ? price(-$amount) : '').''; $out .= ''; print $out; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 24e06f1ef55..afd5d66c777 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -251,6 +251,7 @@ FeeAccountNotDefined=Account for fee not defined BankAccountNotDefined=Account for bank not defined CustomerInvoicePayment=Payment of invoice customer ThirdPartyAccount=Third-party account +AccountNotDefined=Account not defined NewAccountingMvt=New transaction NumMvts=Numero of transaction ListeMvts=List of movements From 957199ef4c1e4544f74168b78e87d6b71586bcac Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Apr 2025 21:49:57 +0200 Subject: [PATCH 4/4] Debug v22 --- htdocs/accountancy/journal/treasuryjournal.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/journal/treasuryjournal.php b/htdocs/accountancy/journal/treasuryjournal.php index 55c0c202ed2..2721811ad84 100644 --- a/htdocs/accountancy/journal/treasuryjournal.php +++ b/htdocs/accountancy/journal/treasuryjournal.php @@ -1164,7 +1164,7 @@ if ($action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'writ // Unique key is on couple: $payment_id, $objectInfos['id'] // For record in llx_accountaing_bookkeeping, for record with doc_type = 'bank', the value of fk_doc is ID in llx_bank and fk_docdet too. Wetry a fix this way; //$result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountInfos['account_number'], $tabaccountingaccount[$accountInfos['account_number']]['label'], $accountInfos['account_ref'], $amount, $journal, $journal_label, ''); - $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $payment_id, $accountInfos['account_number'], $tabaccountingaccount[$accountInfos['account_number']]['label'], $accountInfos['account_ref'], $amount, $journal, $journal_label, ''); + $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, 0, $accountInfos['account_number'], $tabaccountingaccount[$accountInfos['account_number']]['label'], $accountInfos['account_ref'], $amount, $journal, $journal_label, ''); if ($result < 0) { $errorforline++; @@ -1210,7 +1210,8 @@ if ($action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'writ $total_check -= $amount; $bookkeepingToCreate = new BookKeeping($db); - $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountancy_code, $accountingAccountInfos['label'], (!empty($operation['label']) ? $operation['label'] : $accountingAccountInfos['label']), -$amount, $journal, $journal_label, ''); + //$result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountancy_code, $accountingAccountInfos['label'], (!empty($operation['label']) ? $operation['label'] : $accountingAccountInfos['label']), -$amount, $journal, $journal_label, ''); + $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, 0, $accountancy_code, $accountingAccountInfos['label'], (!empty($operation['label']) ? $operation['label'] : $accountingAccountInfos['label']), -$amount, $journal, $journal_label, ''); if ($result < 0) { $errorforline++; @@ -1258,7 +1259,8 @@ if ($action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'writ $total_check -= $amount; $bookkeepingToCreate = new BookKeeping($db); - $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountancy_code, $accountingAccountInfos['label'], $langs->trans('VAT').' '.price($vat_infos['tva_tx']).'%', -$amount, $journal, $journal_label, ''); + //$result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountancy_code, $accountingAccountInfos['label'], $langs->trans('VAT').' '.price($vat_infos['tva_tx']).'%', -$amount, $journal, $journal_label, ''); + $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, 0, $accountancy_code, $accountingAccountInfos['label'], $langs->trans('VAT').' '.price($vat_infos['tva_tx']).'%', -$amount, $journal, $journal_label, ''); if ($result < 0) { $errorforline++; @@ -1280,7 +1282,8 @@ if ($action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'writ $total_check += $amount; $bookkeepingToCreate = new BookKeeping($db); - $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountInfos['account_number'], $tabaccountingaccount[$accountInfos['account_number']]['label'], $accountInfos['account_ref'], $amount, $journal, $journal_label, ''); + //$result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, $objectInfos['id'], $accountInfos['account_number'], $tabaccountingaccount[$accountInfos['account_number']]['label'], $accountInfos['account_ref'], $amount, $journal, $journal_label, ''); + $result = $bookkeepingToCreate->createFromValues($payment["date"], $objectInfos['ref'], 'bank', $payment_id, 0, $accountInfos['account_number'], $tabaccountingaccount[$accountInfos['account_number']]['label'], $accountInfos['account_ref'], $amount, $journal, $journal_label, ''); if ($result < 0) { $errorforline++;