X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gl%2Fincludes%2Fdb%2Fgl_db_bank_trans.inc;h=c9f550c82419aff60614b087b662a0f417447075;hb=9b413697aa4ca30f7f336dbf5fd04bf8caf2bc43;hp=6aebe6f4a2dab753be9f0342eee334224039cd24;hpb=c09be0dad6b05131e240349a375af7a4b7bf3444;p=fa-stable.git diff --git a/gl/includes/db/gl_db_bank_trans.inc b/gl/includes/db/gl_db_bank_trans.inc index 6aebe6f4..c9f550c8 100644 --- a/gl/includes/db/gl_db_bank_trans.inc +++ b/gl/includes/db/gl_db_bank_trans.inc @@ -1,13 +1,22 @@ . +***********************************************************************/ //---------------------------------------------------------------------------------- // add a bank transaction // $amount is in $currency // $date_ is display date (non-sql) -function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_, $bank_trans_type_id, - $amount, $person_type_id, $person_id, $currency="", $err_msg="") +function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_, + $amount, $person_type_id, $person_id, $currency="", $err_msg="", $rate=0) { $sqlDate = date2sql($date_); @@ -15,7 +24,10 @@ function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_, $bank_trans_t if ($currency != "") { $bank_account_currency = get_bank_account_currency($bank_act); - $to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_); + if ($rate == 0) + $to_bank_currency = get_exchange_rate_from_to($currency, $bank_account_currency, $date_); + else + $to_bank_currency = 1 / $rate; $amount_bank = ($amount / $to_bank_currency); } else @@ -26,10 +38,10 @@ function add_bank_trans($type, $trans_no, $bank_act, $ref, $date_, $bank_trans_t //$BankToHomeCurrencyRate = get_exchange_rate_to_home_currency($bank_account_currency, $date_); $sql = "INSERT INTO ".TB_PREF."bank_trans (type, trans_no, bank_act, ref, - trans_date, bank_trans_type_id, amount, person_type_id, person_id) "; + trans_date, amount, person_type_id, person_id) "; - $sql .= "VALUES ($type, $trans_no, '$bank_act', ".db_escape($ref).", '$sqlDate', '$bank_trans_type_id', - $amount_bank, $person_type_id, '$person_id')"; + $sql .= "VALUES ($type, $trans_no, '$bank_act', ".db_escape($ref).", '$sqlDate', + $amount_bank, $person_type_id, ". db_escape($person_id).")"; if ($err_msg == "") $err_msg = "The bank transaction could not be inserted"; @@ -52,10 +64,9 @@ function exists_bank_trans($type, $type_no) function get_bank_trans($type, $trans_no=null, $person_type_id=null, $person_id=null) { - $sql = "SELECT *, bank_account_name, account_code, bank_curr_code, name AS BankTransType - FROM ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts, ".TB_PREF."bank_trans_types - WHERE ".TB_PREF."bank_trans_types.id = ".TB_PREF."bank_trans.bank_trans_type_id - AND ".TB_PREF."bank_accounts.account_code=".TB_PREF."bank_trans.bank_act "; + $sql = "SELECT *, bank_account_name, account_code, bank_curr_code + FROM ".TB_PREF."bank_trans, ".TB_PREF."bank_accounts + WHERE ".TB_PREF."bank_accounts.id=".TB_PREF."bank_trans.bank_act "; if ($type != null) $sql .= " AND type=$type "; if ($trans_no != null) @@ -103,6 +114,8 @@ function void_bank_trans($type, $type_no, $nested=false) void_supp_allocations($type, $type_no); void_supp_trans($type, $type_no); + void_trans_tax_details($type, $type_no); + if (!$nested) commit_transaction(); }