$list = $journal->getListForCategory($type === Compta_Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null);
$tpl->assign('categorie', $cat);
-$tpl->assign('journal', $list);
$tpl->assign('type', $type);
if ($type !== Compta_Categories::AUTRES)
}
$total = 0.0;
-
-foreach ($list as $row)
+foreach ($list as &$row)
{
- $total += (float) $row['montant'];
+ $db = DB::getInstance();
+ $row['montant'] =
+ $db->simpleQuerySingle('
+ SELECT sum(CASE WHEN montant > 0 THEN montant ELSE 0 END)
+ FROM compta_flux
+ WHERE compta_flux.id_journal = ?', false, $row['id']);
+ $total += round((float) $row['montant'], 2);
}
-
+$tpl->assign('journal', $list);
$tpl->assign('total', $total);
$tpl->display('admin/compta/operations/index.tpl');
-?>
\ No newline at end of file
+?>