X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fbanking.inc;h=cf532ea05ec95548da9b870edbe694c8fc4e1ec4;hb=40048ce06ec19e91186a38b841b03038ddd6107f;hp=39b904c8b43b3c63515e11b886c478532f57e30c;hpb=bf00f0e16df5974ecba17b59be8bc660bdf6b8a8;p=fa-stable.git diff --git a/includes/banking.inc b/includes/banking.inc index 39b904c8..cf532ea0 100644 --- a/includes/banking.inc +++ b/includes/banking.inc @@ -1,5 +1,14 @@ . +***********************************************************************/ include_once($path_to_root . "/gl/includes/gl_db.inc"); //---------------------------------------------------------------------------------- @@ -116,7 +125,7 @@ function get_exchange_rate_to_home_currency($currency_code, $date_) function to_home_currency($amount, $currency_code, $date_) { $ex_rate = get_exchange_rate_to_home_currency($currency_code, $date_); - return round($amount / $ex_rate, user_price_dec()); + return round2($amount / $ex_rate, user_price_dec()); } //---------------------------------------------------------------------------------- @@ -162,6 +171,7 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am $ar_ap_act = $trans['receivables_account']; $person_id = $trans['debtor_no']; $curr = $trans['curr_code']; + $date = sql2date($trans['tran_date']); } else { @@ -171,11 +181,12 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am $ar_ap_act = $supp_accs['payable_account']; $person_id = $trans['supplier_id']; $curr = $trans['SupplierCurrCode']; + $date = sql2date($trans['tran_date']); } if (is_company_currency($curr)) return; - $inv_amt = round($amount * $trans['rate'], user_price_dec()); - $pay_amt = round($amount * $pyt_trans['rate'], user_price_dec()); + $inv_amt = round2($amount * $trans['rate'], user_price_dec()); + $pay_amt = round2($amount * $pyt_trans['rate'], user_price_dec()); if ($inv_amt != $pay_amt) { $diff = $inv_amt - $pay_amt; @@ -184,9 +195,18 @@ function exchange_variation($pyt_type, $pyt_no, $type, $trans_no, $pyt_date, $am if ($neg) $diff = -$diff; $exc_var_act = get_company_pref('exchange_diff_act'); - $memo = systypes::name($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); + if (date1_greater_date2($date, $pyt_date)) + { + $memo = systypes::name($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; + 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); + } } }