From ba458ddfd647a2f670a1fa798ba7d57ded31e5f3 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 1 Nov 2023 15:00:48 +0100 Subject: [PATCH] Review of ledger display (#26423) * Review of ledger display * typo * Update listbyaccount.php * Update listbyaccount.php --------- Co-authored-by: Laurent Destailleur --- .../accountancy/bookkeeping/listbyaccount.php | 90 ++++++++++++------- htdocs/product/class/product.class.php | 4 +- 2 files changed, 60 insertions(+), 34 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 7135044ef09..3e4055510cd 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -2,7 +2,7 @@ /* Copyright (C) 2016 Neil Orley * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2020 Florian Henry - * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2013-2023 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -164,12 +164,13 @@ $arrayfields = array( 't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1), 't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1), 't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1), + 't.lettering_code'=>array('label'=>$langs->trans("Lettering"), 'checked'=>1), 't.debit'=>array('label'=>$langs->trans("AccountingDebit"), 'checked'=>1), 't.credit'=>array('label'=>$langs->trans("AccountingCredit"), 'checked'=>1), - 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), - 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), - 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), + 't.balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1), + 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>-1), + 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>-1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), + 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>-1, 'position'=>1100), ); if (!getDolGlobalString('ACCOUNTING_ENABLE_LETTERING')) { @@ -260,9 +261,9 @@ if (empty($reshook)) { $search_date_validation_endyear = ''; $search_date_validation_endmonth = ''; $search_date_validation_endday = ''; + $search_lettering_code = ''; $search_debit = ''; $search_credit = ''; - $search_lettering_code = ''; $search_not_reconciled = ''; $search_import_key = ''; $toselect = array(); @@ -339,6 +340,10 @@ if (empty($reshook)) { $param .= '&search_ledger_code[]='.urlencode($code); } } + if (!empty($search_lettering_code)) { + $filter['t.lettering_code'] = $search_lettering_code; + $param .= '&search_lettering_code='.urlencode($search_lettering_code); + } if (!empty($search_debit)) { $filter['t.debit'] = $search_debit; $param .= '&search_debit='.urlencode($search_debit); @@ -347,10 +352,6 @@ if (empty($reshook)) { $filter['t.credit'] = $search_credit; $param .= '&search_credit='.urlencode($search_credit); } - if (!empty($search_lettering_code)) { - $filter['t.lettering_code'] = $search_lettering_code; - $param .= '&search_lettering_code='.urlencode($search_lettering_code); - } if (!empty($search_not_reconciled)) { $filter['t.reconciled_option'] = $search_not_reconciled; $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); @@ -679,7 +680,6 @@ if (empty($reshook)) { $newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); } - $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); } @@ -844,6 +844,13 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) { if (!empty($arrayfields['t.label_operation']['checked'])) { print ''; } +// Lettering code +if (!empty($arrayfields['t.lettering_code']['checked'])) { + print ''; + print ''; + print '
'.$langs->trans("NotReconciled").''; + print ''; +} // Debit if (!empty($arrayfields['t.debit']['checked'])) { print ''; @@ -852,12 +859,9 @@ if (!empty($arrayfields['t.debit']['checked'])) { if (!empty($arrayfields['t.credit']['checked'])) { print ''; } -// Lettering code -if (!empty($arrayfields['t.lettering_code']['checked'])) { - print ''; - print ''; - print '
'.$langs->trans("NotReconciled").''; - print ''; +// Balance +if (!empty($arrayfields['t.balance']['checked'])) { + print ''; } // Date export if (!empty($arrayfields['t.date_export']['checked'])) { @@ -920,14 +924,17 @@ if (!empty($arrayfields['t.doc_ref']['checked'])) { if (!empty($arrayfields['t.label_operation']['checked'])) { print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder); } +if (!empty($arrayfields['t.lettering_code']['checked'])) { + print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +} if (!empty($arrayfields['t.debit']['checked'])) { print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['t.credit']['checked'])) { print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right '); } -if (!empty($arrayfields['t.lettering_code']['checked'])) { - print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['t.balance']['checked'])) { + print_liste_field_titre($arrayfields['t.balance']['label'], "", "", "", $param, '', $sortfield, $sortorder, 'right '); } if (!empty($arrayfields['t.date_export']['checked'])) { print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center '); @@ -977,18 +984,23 @@ while ($i < min($num, $limit)) { //if (empty($accountg)) $accountg = '-'; $colspan = 0; // colspan before field 'label of operation' - $colspanend = 3; // colspan after debit/credit + $colspanend = 0; // colspan after debit/credit + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $colspan++; + } if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; } if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; } if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; } if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; } if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; } + if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspan++; } + + if (!empty($arrayfields['t.balance']['checked'])) { $colspanend++; } if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; } if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; } - if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; } - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - $colspan++; - $colspanend--; + if (!empty($arrayfields['t.import_key']['checked'])) { $colspanend++; } + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + $colspanend++; } // Is it a break ? @@ -1003,7 +1015,7 @@ while ($i < min($num, $limit)) { } print ''.price(price2num($sous_total_debit, 'MT')).''; print ''.price(price2num($sous_total_credit, 'MT')).''; - print ''; + if ($colspanend > 0) print ''; print ''; // Show balance of last shown account $balance = $sous_total_debit - $sous_total_credit; @@ -1020,7 +1032,7 @@ while ($i < min($num, $limit)) { print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print ''; } - print ''; + if ($colspanend > 0) print ''; print ''; } @@ -1189,6 +1201,14 @@ while ($i < min($num, $limit)) { } } + // Lettering code + if (!empty($arrayfields['t.lettering_code']['checked'])) { + print ''.$line->lettering_code.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount debit if (!empty($arrayfields['t.debit']['checked'])) { print ''.($line->debit != 0 ? price($line->debit) : '').''; @@ -1213,12 +1233,16 @@ while ($i < min($num, $limit)) { $totalarray['val']['totalcredit'] += $line->credit; } - // Lettering code - if (!empty($arrayfields['t.lettering_code']['checked'])) { - print ''.$line->lettering_code.''; + // Amount balance + if (!empty($arrayfields['t.balance']['checked'])) { + print ''.price(price2num($sous_total_debit + $line->debit - $sous_total_credit - $line->credit, 'MT')).''; if (!$i) { $totalarray['nbfield']++; } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalbalance'; + }; + $totalarray['val']['totalbalance'] += $line->debit - $line->credit; } // Exported operation date @@ -1279,7 +1303,7 @@ if ($num > 0 && $colspan > 0) { print ''.$langs->trans("TotalForAccount").' '.$accountg.':'; print ''.price(price2num($sous_total_debit, 'MT')).''; print ''.price(price2num($sous_total_credit, 'MT')).''; - print ''; + if ($colspanend > 0) print ''; print ''; // Show balance of last shown account $balance = $sous_total_debit - $sous_total_credit; @@ -1296,7 +1320,7 @@ if ($num > 0 && $colspan > 0) { print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print ''; } - print ''; + if ($colspanend > 0) print ''; print ''; } @@ -1308,7 +1332,9 @@ if (!empty($totalarray['val']['totaldebit'])) { if (!empty($totalarray['val']['totalcredit'])) { $totalarray['val']['totalcredit'] = price2num($totalarray['val']['totalcredit'], 'MT'); } - +if (!empty($totalarray['val']['totalbalance'])) { + $totalarray['val']['totalbalance'] = price2num($totalarray['val']['totaldebit'] - $totalarray['val']['totalcredit'], 'MT'); +} // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index beaf69dcfa4..8b6c4704a3b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5247,12 +5247,12 @@ class Product extends CommonObject } /** - * Return clicable link of object (with eventually picto) + * Return clickable link of object (with eventually picto) * * @param int $withpicto Add picto into link * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '') * @param int $maxlength Maxlength of ref - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values when clicking * @param int $notooltip No tooltip * @param string $morecss ''=Add more css on link * @param int $add_label 0=Default, 1=Add label into string, >1=Add first chars into string