diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php
index 0b063adb1ff..4847dfd2e9a 100644
--- a/htdocs/accountancy/bookkeeping/listbyaccount.php
+++ b/htdocs/accountancy/bookkeeping/listbyaccount.php
@@ -749,40 +749,42 @@ while ($i < min($num, $limit))
$i++;
}
-// Show sub-total of last shown account
-if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
- $colnumber = 3;
- $colnumberend = 7;
-} else {
- $colnumber = 4;
- $colnumberend = 7;
+if ($num > 0) {
+ // Show sub-total of last shown account
+ if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
+ $colnumber = 3;
+ $colnumberend = 7;
+ } else {
+ $colnumber = 4;
+ $colnumberend = 7;
+ }
+ $colspan = $totalarray['nbfield'] - $colnumber;
+ $colspanend = $totalarray['nbfield'] - $colnumberend;
+ print '
';
+ print '| '.$langs->trans("TotalForAccount").' '.$accountg.': | ';
+ print ''.price($sous_total_debit).' | ';
+ print ''.price($sous_total_credit).' | ';
+ print ' | ';
+ print '
';
+ // Show balance of last shown account
+ $balance = $sous_total_debit - $sous_total_credit;
+ print '';
+ print '| '.$langs->trans("Balance").': | ';
+ if ($balance > 0)
+ {
+ print '';
+ print price($sous_total_debit - $sous_total_credit);
+ print ' | ';
+ print ' | ';
+ } else {
+ print ' | ';
+ print '';
+ print price($sous_total_credit - $sous_total_debit);
+ print ' | ';
+ }
+ print ' | ';
+ print '
';
}
-$colspan = $totalarray['nbfield'] - $colnumber;
-$colspanend = $totalarray['nbfield'] - $colnumberend;
-print '';
-print '| '.$langs->trans("TotalForAccount").' '.$accountg.': | ';
-print ''.price($sous_total_debit).' | ';
-print ''.price($sous_total_credit).' | ';
-print ' | ';
-print '
';
-// Show balance of last shown account
-$balance = $sous_total_debit - $sous_total_credit;
-print '';
-print '| '.$langs->trans("Balance").': | ';
-if ($balance > 0)
-{
- print '';
- print price($sous_total_debit - $sous_total_credit);
- print ' | ';
- print ' | ';
-} else {
- print ' | ';
- print '';
- print price($sous_total_credit - $sous_total_debit);
- print ' | ';
-}
-print ' | ';
-print '
';
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';