This commit is contained in:
Laurent Destailleur 2017-06-24 16:21:25 +02:00
parent ee8924e101
commit e79f3715b4

View File

@ -107,7 +107,7 @@ $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) $sortorder='ASC'; if (! $sortorder) $sortorder='ASC';
if (! $sortfield) $sortfield='b.datev'; if (! $sortfield) $sortfield='b.datev, b.dateo, b.rowid';
$mode_balance_ok=false; $mode_balance_ok=false;
//if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected //if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected
@ -902,7 +902,7 @@ if ($resql)
exit; exit;
} }
//Loop on each record // Loop on each record before
$sign = 1; $sign = 1;
$i = 0; $i = 0;
$sqlforbalance='SELECT SUM(b.amount) as balance'; $sqlforbalance='SELECT SUM(b.amount) as balance';
@ -912,7 +912,8 @@ if ($resql)
$sqlforbalance.= " WHERE b.fk_account = ba.rowid"; $sqlforbalance.= " WHERE b.fk_account = ba.rowid";
$sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")";
$sqlforbalance.= " AND b.fk_account = ".$account; $sqlforbalance.= " AND b.fk_account = ".$account;
$sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'"; //$sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "')";
$sqlforbalance.= " AND (b.datev < '" . $db->idate($db->jdate($objp->dv)) . "' OR (b.datev = '" . $db->idate($db->jdate($objp->dv)) . "' AND (b.dateo < '".$db->idate($db->jdate($objp->do))."' OR (b.dateo = '".$db->idate($db->jdate($objp->do))."' AND b.rowid < ".$objp->rowid."))))";
$resqlforbalance = $db->query($sqlforbalance); $resqlforbalance = $db->query($sqlforbalance);
//print $sqlforbalance; //print $sqlforbalance;
if ($resqlforbalance) if ($resqlforbalance)