// When there is no exrate for today,
// gets it form ECB and stores in local database.
//
-function exchange_rate_display($from_currency, $to_currency, $date_, $force_edit=false)
+function exchange_rate_display($from_currency=null, $to_currency=null, $date_, $force_edit=false)
{
global $Ajax, $SysPrefs;
$rate = input_num('_ex_rate');
if (check_ui_refresh() || !$rate) { // readonly or ui context changed
$comp_currency = get_company_currency();
+
+ if (!isset($from_currency))
+ $from_currency = $comp_currency;
+ if (!isset($to_currency))
+ $to_currency = $comp_currency;
+
if ($from_currency == $comp_currency)
$currency = $to_currency;
else
$sql = "SELECT supp.supp_name, terms.terms, terms.days_before_due, supp.dimension_id, supp.dimension2_id,
terms.day_in_following_month, supp.tax_included,
supp.tax_group_id, tax_group.name AS tax_group_name,
- supp.credit_limit - Sum((ov_amount + ov_gst + ov_discount)) as cur_credit
+ supp.credit_limit - Sum((ov_amount + ov_gst + ov_discount)) as cur_credit, curr_code
FROM ".TB_PREF."suppliers supp LEFT JOIN "
.TB_PREF."supp_trans trans ON supp.supplier_id = trans.supplier_id, "
.TB_PREF."payment_terms terms, "
$supp_trans->tax_group_id = $myrow['tax_group_id'];
$supp_trans->dimension = $myrow['dimension_id'];
$supp_trans->dimension2 = $myrow['dimension2_id'];
+ $supp_trans->currency = $myrow['curr_code'];
}
} else
$allocs = get_po_prepayments($supp_trans);
- add_new_exchange_rate($supplier['curr_code'], $supp_trans->tran_date, $supp_trans->ex_rate);
+ add_new_exchange_rate($supp_trans->currency, $supp_trans->tran_date, $supp_trans->ex_rate);
foreach ($taxes as $n => $taxitem)
{
}
$date_ = $supp_trans->tran_date;
- $ex_rate = get_exchange_rate_from_home_currency($supplier['curr_code'], $date_);
+ $ex_rate = get_exchange_rate_from_home_currency($supp_trans->currency, $date_);
/*First insert the invoice into the supp_trans table*/
$invoice_id = write_supp_trans($trans_type, 0, $supp_trans->supplier_id, $date_, $supp_trans->due_date,
$dim, $dim2, $taxfree_line, $supp_trans->supplier_id);
else
{
- $ex_rate = get_exchange_rate_from_home_currency($supplier['curr_code'], $old_date);
+ $ex_rate = get_exchange_rate_from_home_currency($supp_trans->currency, $old_date);
$old_value = get_tax_free_price_for_item($entered_grn->item_code, $entered_grn->this_quantity_inv * $old_price,
$supp_trans->tax_group_id, $supp_trans->tax_included);
function read_supp_invoice($trans_no, $trans_type, &$supp_trans)
{
- $sql = "SELECT trans.*, supp_name, dimension_id, dimension2_id
+ $sql = "SELECT trans.*, supp_name, dimension_id, dimension2_id, curr_code
FROM ".TB_PREF."supp_trans trans,"
.TB_PREF."suppliers sup
WHERE trans_no = ".db_escape($trans_no)." AND type = ".db_escape($trans_type)."
$supp_trans->tax_included = $trans_row["tax_included"];
$supp_trans->dimension = $trans_row["dimension_id"];
$supp_trans->dimension2 = $trans_row["dimension2_id"];
+ $supp_trans->currency = $trans_row["curr_code"];
$id = $trans_row["trans_no"];
set_global_supplier($_POST['supplier_id']);
- $supplier_currency = get_supplier_currency($supp_trans->supplier_id);
-
$company_currency = get_company_currency();
- if ($supplier_currency != $company_currency)
+ if ($supp_trans->currency != $company_currency)
{
- label_row(_("Supplier's Currency:"), "<b>" . $supplier_currency . "</b>");
- exchange_rate_display($company_currency, $supplier_currency, $_POST['tran_date']);
+ label_row(_("Supplier's Currency:"), "<b>" . $supp_trans->currency . "</b>");
+ exchange_rate_display($company_currency, $supp_trans->currency, $_POST['tran_date']);
}
label_row(_("Tax Group:"), $supp_trans->tax_description);