Bug 5518: Total Amount of a Journal Entry with multiple rows (>2) is wrong in Journal...
[fa-stable.git] / gl / includes / db / gl_db_trans.inc
index eed9438408ee4c2d9b1ffc5551e1f8ca4d8a6900..45067bb755a3f27a2b42a772868b71a6f126ce58 100644 (file)
@@ -289,7 +289,7 @@ function get_gl_balance_from_to($from_date, $to_date, $account, $dimension=0, $d
        $result = db_query($sql, "The starting balance for account $account could not be calculated");
 
        $row = db_fetch_row($result);
-       return $row[0];
+       return round2($row[0], user_price_dec());
 }
 
 //--------------------------------------------------------------------------------
@@ -313,7 +313,7 @@ function get_gl_trans_from_to($from_date, $to_date, $account, $dimension=0, $dim
        $result = db_query($sql, "Transactions for account $account could not be calculated");
 
        $row = db_fetch_row($result);
-       return (float)$row[0];
+       return round2($row[0], user_price_dec());
 }
 
 //----------------------------------------------------------------------------------------------------
@@ -625,8 +625,8 @@ function get_sql_for_journal_inquiry($filter, $from, $to, $ref='', $memo='', $al
          LEFT JOIN ".TB_PREF."grn_batch grn ON grn.id=gl.type_no AND gl.type=".ST_SUPPRECEIVE."
          LEFT JOIN ".TB_PREF."bank_trans bt ON bt.type=gl.type AND bt.trans_no=gl.type_no AND bt.amount!=0
                  AND (bt.person_id != '' AND !ISNULL(bt.person_id))
-         LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no AND (gl.type_no != 0 or gl.person_id=dt.debtor_no) AND gl.person_type_id=2
-         LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no AND (gl.type !=0 or gl.person_id=st.supplier_id) AND gl.person_type_id=3
+         LEFT JOIN ".TB_PREF."debtor_trans dt ON dt.type=gl.type AND gl.type_no=dt.trans_no AND gl.person_id=dt.debtor_no AND gl.person_type_id=2
+         LEFT JOIN ".TB_PREF."supp_trans st ON st.type=gl.type AND gl.type_no=st.trans_no AND gl.person_id=st.supplier_id AND gl.person_type_id=3
          WHERE gl.tran_date >= '" . date2sql($from) . "'
         AND gl.tran_date <= '" . date2sql($to) . "'
         AND gl.amount!=0";