Redundant check for negative stock removed.
[fa-stable.git] / reporting / rep101.php
index df34fe35ef8794136ede0b92b554a04092683d6b..3584a0259ecf13cc398a66d344dffea56a2bbfdb 100644 (file)
@@ -142,14 +142,13 @@ function print_customer_balances()
                $sql .= "WHERE debtor_no=".db_escape($fromcust);
        $sql .= " ORDER BY name";
        $result = db_query($sql, "The customers could not be retrieved");
-       $num_lines = 0;
 
        while ($myrow = db_fetch($result))
        {
                if (!$convert && $currency != $myrow['curr_code']) continue;
                
                $accumulate = 0;
-               $rate = $convert ? get_exchange_rate_to_home_currency($myrow['curr_code'], Today()) : 1;
+               $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1;
                $bal = get_open_balance($myrow['debtor_no'], $from, $convert);
                $init[0] = $init[1] = 0.0;
                $init[0] = round2(abs($bal['charges']*$rate), $dec);
@@ -166,7 +165,6 @@ function print_customer_balances()
                $res = get_transactions($myrow['debtor_no'], $from, $to);
                if ($no_zeros && db_num_rows($res) == 0) continue;
 
-               $num_lines++;
                $rep->fontSize += 2;
                $rep->TextCol(0, 2, $myrow['name']);
                if ($convert)
@@ -184,9 +182,11 @@ function print_customer_balances()
                        $grandtotal[$i] += $init[$i];
                }
                $rep->NewLine(1, 2);
-               if (db_num_rows($res)==0)
-                       continue;
                $rep->Line($rep->row + 4);
+               if (db_num_rows($res)==0) {
+                       $rep->NewLine(1, 2);
+                       continue;
+               }
                while ($trans = db_fetch($res))
                {
                        if ($no_zeros && floatcmp($trans['TotalAmount'], $trans['Allocated']) == 0) continue;