X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fdata_checks.inc;fp=includes%2Fdata_checks.inc;h=67768b937df6d1f3eff7662b8258b76fa71e7ece;hb=6a12518d87e341c16dd2e2898f36e74320369d71;hp=798e84c4b5c10070a4526a2ccbc7a2ad987b0898;hpb=c00e6c0f28b8924b088c26814cc303638e8d093a;p=fa-stable.git diff --git a/includes/data_checks.inc b/includes/data_checks.inc index 798e84c4..67768b93 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -41,6 +41,19 @@ function check_db_has_currencies($msg) } } +function db_has_currency_rates($currency, $date_, $msg=false) +{ + $date = date2sql($date_); + + if (is_company_currency($currency)) + return 1; + $ret = check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."exchange_rates WHERE curr_code = '$currency' && date_ <= '$date'"); + if ($ret == 0 && $msg) + display_error(sprintf(_("Cannot retrieve exchange rate for currency %s as of %s. Please add exchange rate manually on Exchange Rates page."), + $currency, $date_), true); + return $ret; +} + function db_has_sales_types() { return check_empty_result("SELECT COUNT(*) FROM ".TB_PREF."sales_types");