Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
ldestailleur 2025-04-14 09:13:15 +02:00
commit 482053ee1e
8 changed files with 57 additions and 33 deletions

View file

@ -872,7 +872,7 @@ if (!empty($arrayfields['t.piece_num']['checked'])) {
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
print '<td class="liste_titre center">';
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 '</td>';
}
// Date document
@ -888,7 +888,7 @@ if (!empty($arrayfields['t.doc_date']['checked'])) {
}
// Ref document
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
print '<td class="liste_titre"><input type="text" name="search_doc_ref" class="width75" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
}
// Accountancy account
if (!empty($arrayfields['t.numero_compte']['checked'])) {

View file

@ -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;
}

View file

@ -765,7 +765,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name'];
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $accountingaccount->label, 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -801,7 +801,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount")) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $langs->trans("SubledgerAccount"), 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -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 "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($userstatic->getNomUrl(0, 'user'), '', $labelvatrate, 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";

View file

@ -1173,7 +1173,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount")) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("SubledgerAccount"), 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -1216,7 +1216,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $accountingaccount->label, 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -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 "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $labelvatrate, 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -1309,7 +1309,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)") . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'supplier'), $invoicestatic->ref_supplier, $langs->trans("VAT")." NPR (counterpart)", 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";

View file

@ -1265,7 +1265,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty")) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans("RetainedWarranty"), 1) . "</td>";
print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>";
print "</tr>";
@ -1296,7 +1296,7 @@ if (empty($action) || $action == 'view') {
print $accountoshow;
}
print '</td>';
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount")) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("SubledgerAccount"), 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print "</tr>";
@ -1339,7 +1339,7 @@ if (empty($action) || $action == 'view') {
print '</td>';
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $accountingaccount->label, 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -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 "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $labelvatrate, 1) . "</td>";
print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
print "</tr>";
@ -1411,7 +1411,7 @@ if (empty($action) || $action == 'view') {
// Subledger account
print "<td>";
print '</td>';
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp")) . "</td>";
print "<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0, 'customer'), $invoicestatic->ref, $langs->trans("RevenueStamp"), 1) . "</td>";
print '<td class="right nowraponall amount">' . ($mt < 0 ? price(-$mt) : '') . "</td>";
print '<td class="right nowraponall amount">' . ($mt >= 0 ? price($mt) : '') . "</td>";
print "</tr>";

View file

@ -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++;
@ -1449,6 +1452,7 @@ if (empty($action) || $action == 'view') {
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];
@ -1513,6 +1517,11 @@ if (empty($action) || $action == 'view') {
}
}
if (!$i) {
$colspan = 8;
print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
}
print "</table>";
print '</div>';

View file

@ -673,15 +673,16 @@ class FormAccounting extends Form
$out .= '<td>';
$accounttoshow = length_accountg($accountAccounting);
if (empty($accounttoshow) || $accounttoshow == 'NotDefined') {
$out .= '<span class="error">'.$langs->trans('BankAccountNotDefined').'</span>';
// Could be ProductAccountNotDefined, VATAccountNotDefined, ...
$out .= '<span class="error">'.$langs->trans('AccountNotDefined').'</span>';
} else {
$out .= $accounttoshow;
}
$out .= '</td>';
$out .= '<td>'.$labelOperation.'</td>';
$out .= '<td>'.$paymentMode.'</td>';
$out .= '<td class="nowrap right">'.($amount >= 0 ? price($amount) : '').'</td>';
$out .= '<td class="nowrap right">'.($amount < 0 ? price(-$amount) : '').'</td>';
$out .= '<td class="center">'.$paymentMode.'</td>';
$out .= '<td class="nowraponall right amount">'.($amount >= 0 ? price($amount) : '').'</td>';
$out .= '<td class="nowraponall right amount">'.($amount < 0 ? price(-$amount) : '').'</td>';
$out .= '</tr>';
print $out;

View file

@ -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