X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fbanking.inc;h=54345259c889ffb9c573a96e2dbfd3ecb69431f1;hb=5ddbc6107f4823f6b3629846aba63814bf958d38;hp=2c0fa94573c09cf2a0bcb3656741f73808f64d63;hpb=f12dbe7523bb1abc6cd69b009ef8f0be838f5348;p=fa-stable.git diff --git a/includes/banking.inc b/includes/banking.inc index 2c0fa945..54345259 100644 --- a/includes/banking.inc +++ b/includes/banking.inc @@ -3,13 +3,22 @@ include_once($path_to_root . "/gl/includes/gl_db.inc"); //---------------------------------------------------------------------------------- - +// Check if given account is used by any bank_account. +// Returns id of first bank_account using account_code, null otherwise. +// +// Keep in mind that direct posting to bank account is depreciated +// because we have no way to select right bank account if +// there is more than one using given gl account. +// function is_bank_account($account_code) { - $sql= "SELECT account_code FROM ".TB_PREF."bank_accounts WHERE account_code='$account_code'"; - $result = db_query($sql, "retreive bank account currency"); - - return (db_num_rows($result) > 0); + $sql= "SELECT id FROM ".TB_PREF."bank_accounts WHERE account_code='$account_code'"; + $result = db_query($sql, "checking account is bank account"); + if (db_num_rows($result) > 0) { + $acct = db_fetch($result); + return $acct['id']; + } else + return false; } //---------------------------------------------------------------------------------- @@ -35,9 +44,9 @@ function get_company_currency() //---------------------------------------------------------------------------------- -function get_bank_account_currency($bankAccount) +function get_bank_account_currency($id) { - $sql= "SELECT bank_curr_code FROM ".TB_PREF."bank_accounts WHERE account_code='$bankAccount'"; + $sql= "SELECT bank_curr_code FROM ".TB_PREF."bank_accounts WHERE id='$id'"; $result = db_query($sql, "retreive bank account currency"); $myrow = db_fetch_row($result); @@ -85,7 +94,9 @@ function get_exchange_rate_from_home_currency($currency_code, $date_) if (db_num_rows($result) == 0) { // no stored exchange rate, just return 1 - display_error(_("Cannot retrieve currency exchange rate for this date. Please add exchange rate manually on Exchange Rates page.") ); + display_error( + sprintf(_("Cannot retrieve exchange rate for currency %s as of %s. Please add exchange rate manually on Exchange Rates page."), + $currency_code, $date_)); return 1.000; }