Additional request input cleanup.
[fa-stable.git] / includes / banking.inc
index cf532ea05ec95548da9b870edbe694c8fc4e1ec4..82d78b055b65bf9ca6561b8866e56d39db93913c 100644 (file)
@@ -41,14 +41,7 @@ function is_company_currency($currency)
 
 function get_company_currency()
 {
-       $sql= "SELECT curr_default FROM ".TB_PREF."company";
-       $result = db_query($sql, "retreive company currency");
-
-       if (db_num_rows($result) == 0)
-               display_db_error("Could not find the requested currency. Fatal.", $sql);
-
-       $myrow = db_fetch_row($result);
-       return $myrow[0];
+       return get_company_pref('curr_default');
 }
 
 //----------------------------------------------------------------------------------
@@ -90,7 +83,7 @@ function get_supplier_currency($supplier_id)
 
 function get_exchange_rate_from_home_currency($currency_code, $date_)
 {
-       if ($currency_code == get_company_currency())
+       if ($currency_code == get_company_currency() || $currency_code == null)
                return 1.0000;
 
        $date = date2sql($date_);
@@ -164,7 +157,9 @@ function exchange_from_to($amount, $from_curr_code, $to_curr_code, $date_)
 
 function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $amount, $person_type, $neg=false)
 {
-       if ($person_type == payment_person_types::customer())
+       global $systypes_array;
+       
+       if ($person_type == PT_CUSTOMER)
        {
                $trans = get_customer_trans($trans_no, $type);
                $pyt_trans = get_customer_trans($pyt_no, $pyt_type);
@@ -190,20 +185,20 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am
        if ($inv_amt != $pay_amt)
        {
                $diff = $inv_amt - $pay_amt;
-               if ($person_type == payment_person_types::supplier())
+               if ($person_type == PT_SUPPLIER)
                        $diff = -$diff;
                if ($neg)
                        $diff = -$diff;
                $exc_var_act = get_company_pref('exchange_diff_act');
                if (date1_greater_date2($date, $pyt_date))
                {
-                       $memo = systypes::name($pyt_type)." ".$pyt_no;
+                       $memo = $systypes_array[$pyt_type]." ".$pyt_no;
                        add_gl_trans($type, $trans_no, $date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
                        add_gl_trans($type, $trans_no, $date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
                }
                else
                {
-                       $memo = systypes::name($type)." ".$trans_no;
+                       $memo = $systypes_array[$type]." ".$trans_no;
                        add_gl_trans($pyt_type, $pyt_no, $pyt_date, $ar_ap_act, 0, 0, $memo, -$diff, null, $person_type, $person_id);
                        add_gl_trans($pyt_type, $pyt_no, $pyt_date, $exc_var_act, 0, 0, $memo, $diff, null, $person_type, $person_id);
                }