<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — No exchange rate working in FA now]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7718&amp;type=atom" />
	<updated>2021-09-07T09:18:55Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=7718</id>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39980#p39980" />
			<content type="html"><![CDATA[<p>Thanks @boxygen.</p><p>Fixed and committed to stable repo.</p><p>A fixed file can be downloaded and replaced.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2021-09-07T09:18:55Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39980#p39980</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39978#p39978" />
			<content type="html"><![CDATA[<p>Hello, Recently due to some changes in output of EXCHANGE-RATES.ORG the current code is not retrieving Exchange Rate. </p><p>Following fix is needed.</p><p><strong>/gl/includes/db/gl_db_rates.inc</strong><br />Line # 240 Replace <br /></p><div class="codebox"><pre><code>$val = getInnerStr($contents, &#039;&lt;span id=&quot;ctl00_M_lblToAmount&quot;&gt;&#039;, &#039;&lt;&#039;);
        $val = str_replace (&#039;,&#039;, &#039;&#039;, $val);</code></pre></div><p>with<br /></p><div class="codebox"><pre><code>        $val = getInnerStr($contents, &quot;1 $curr_b = &quot;,$curr_a);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2021-09-06T16:55:20Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39978#p39978</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=34507#p34507" />
			<content type="html"><![CDATA[<p>This has been <a href="https://github.com/FrontAccountingERP/FA/commit/f4161d2985268fc4333f968b215ed0c6a53b731c#commitcomment-32876991">committed</a> to stable repo. Thank you @notrinos for providing this.</p><p>Remember to change the settings in <strong>config.php</strong> also.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2019-03-21T21:35:25Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=34507#p34507</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=34505#p34505" />
			<content type="html"><![CDATA[<p>Updated new <strong>gl_db_rates.inc</strong></p><p>- Removed CCA, (currencyconverterapi.com) is no longer working<br />- Updated url from google api</p><p>Fixed file <a href="https://drive.google.com/open?id=1xUnhlHKOLT4s6WwA5G894ArKRUt9YgMB">here</a></p><p>And new config.default.php content<br /></p><div class="codebox"><pre><code>$xr_providers = array(&quot;ECB&quot;, &quot;EXCHANGE-RATES.ORG&quot;, &quot;GOOGLE&quot;, &quot;YAHOO&quot;, &quot;BLOOMBERG&quot;);</code></pre></div>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2019-03-21T17:27:35Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=34505#p34505</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33705#p33705" />
			<content type="html"><![CDATA[<p>The 3 Providers, ECB, CCA and EXCHANGE-RATES.ORG is working now and the /gl/includes/db/gl_db_rates.inc is committed as well as config.default.php.<br />They can be downloaded <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/gl/includes/db/gl_db_rates.inc">here</a> and <a href="https://sourceforge.net/p/frontaccounting/git/ci/master/tree/config.default.php">here</a>.</p><p>Please copy the $xr_providers array from config.default.php to your config.php.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-20T12:09:37Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33705#p33705</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33704#p33704" />
			<content type="html"><![CDATA[<p>Hello @notrinos</p><p>I got the following errors when using<br /></p><div class="codebox"><pre><code>Yahoo
Undefined offset: 1 in file: C:\wamp3\www\account24\gl\includes\db\gl_db_rates.inc at line 228
Google
Cannot retrieve exchange rate for currency GBP. Please adjust approximate rate if needed.
Bloomberg
Cannot retrieve exchange rate for currency GBP. Please adjust approximate rate if needed.</code></pre></div><p>I think we could just commit it. The 3 first providers works OK. We can then investigate further on the others, right?</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-20T11:48:27Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33704#p33704</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33703#p33703" />
			<content type="html"><![CDATA[<p>Sure @notrinos. Thanks for the investigation.</p><p>I will just test them all and commit them later.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-20T11:29:20Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33703#p33703</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33702#p33702" />
			<content type="html"><![CDATA[<p>Fixed file gl_db_rates.inc for ECB and included CCA can be download <a href="https://drive.google.com/open?id=1mr_SR_aYzjqrMjPEiS9s_1NF1oZOpHs5">here</a></p><p>for config file:<br /></p><div class="codebox"><pre><code>$xr_providers = array(&quot;ECB&quot;, &quot;EXCHANGE-RATES.ORG&quot;, &quot;CCA&quot;, &quot;YAHOO&quot;, &quot;GOOGLE&quot;, &quot;BLOOMBERG&quot;);</code></pre></div><p>A well-known financial institution should be default so I moved ECB to first position.</p>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2018-12-20T07:04:09Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33702#p33702</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33701#p33701" />
			<content type="html"><![CDATA[<p>Hello @boxygen,</p><p>Your code for CCA doesn&#039;t work. It gives no rates. Will you give it a check, please? Thanks.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-19T23:04:48Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33701#p33701</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33697#p33697" />
			<content type="html"><![CDATA[<p>Hello @apmuthu,</p><p>Yes I will include your fix and @boxygen&#039;s provider in FA later this evening.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2018-12-19T17:50:35Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33697#p33697</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33696#p33696" />
			<content type="html"><![CDATA[<p>@joe: Please include the fixes to ECB in my previous post and @boxygen&#039;s currencyconverterapi.com (CCA) as exchange providers.</p><p>CCA&#039;s output of:<br /></p><div class="codebox"><pre><code>https://free.currencyconverterapi.com/api/v5/convert?q=USD_EUR&amp;compact=y</code></pre></div><p>is a json value formatted like:<br /></p><div class="codebox"><pre><code>{&quot;USD_EUR&quot;:{&quot;val&quot;:0.875505}}</code></pre></div><p>The reverse currency rate check for large decimal differences like IDR =&gt; KWD is not accounted for in it as yet.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-19T17:41:40Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33696#p33696</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33691#p33691" />
			<content type="html"><![CDATA[<p>https://free.currencyconverterapi.com/</p><p>They allow 100 Requests Per Hour for Free.</p><p>This is also a good option</p><p>config.php changes<br /></p><div class="codebox"><pre><code>$xr_providers = array(&quot;ECB&quot;, &quot;YAHOO&quot;, &quot;GOOGLE&quot;, &quot;BLOOMBERG&quot;, &quot;CCA&quot;);</code></pre></div><br /><p>gl_db_rates.inc changes as follows.</p><div class="codebox"><pre><code>function get_extern_rate($curr_b, $provider = &#039;ECB&#039;, $date)
{
    global    $path_to_root;

    if ($date != Today())    // no historical rates available
        return 0;

    $contents = &#039;&#039;;
    $proto = &#039;http://&#039;;
    $curr_a = get_company_pref(&#039;curr_default&#039;);
    if ($provider == &#039;ECB&#039;)
    {
        $filename = &quot;/stats/eurofxref/eurofxref-daily.xml&quot;;
        $site = &quot;www.ecb.europa.eu&quot;;
        $site_ip=&quot;172.230.157.137&quot;;
    }
    elseif ($provider == &#039;YAHOO&#039;)
    {
        $filename = &quot;/d/quotes.csv?s={$curr_a}{$curr_b}=X&amp;f=sl1d1t1ba&amp;e=.csv&quot;; // new URL&#039;s for YAHOO
        $site = &quot;download.finance.yahoo.com&quot;;
        $site_ip=&quot;203.84.220.151&quot;;
    }
    elseif ($provider == &#039;GOOGLE&#039;)
    {
        $filename = &quot;/bctzjpnsun/converter?a=1&amp;from={$curr_a}&amp;to={$curr_b}&quot;;
        $site = &quot;finance.google.com&quot;;
    }
    elseif ($provider == &#039;BLOOMBERG&#039;)
    {
        $filename = &quot;/quote/{$curr_b}{$curr_a}:CUR&quot;;
        $site = &quot;www.bloomberg.com&quot;;
        $proto = &#039;https://&#039;;
        $contents=file_get_contents($proto.$site.$filename);
    }
    elseif ($provider == &#039;CCA&#039;) //free.currencyconverterapi.com
    {
        $filename = &quot;/api/v5/convert?q={$curr_b}_{$curr_a}&amp;compact=y&quot;;
        $site = &quot;free.currencyconverterapi.com&quot;;
        $proto = &#039;https://&#039;;

    }
    if (empty($contents)) {
        if (function_exists(&#039;curl_init&#039;))
        {    // first check with curl as we can set short timeout;
            $retry = 1;
             do {
                   $ch = curl_init();
                   curl_setopt ($ch, CURLOPT_URL, $proto.$site.$filename);
                   curl_setopt ($ch, CURLOPT_COOKIEJAR, VARLIB_PATH.&quot;/cookie.txt&quot;);
                   curl_setopt ($ch, CURLOPT_HEADER, 0);
                   curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
                   // prevent warning while safe_mode/open_basedir on (redirection doesn&#039;t occur at least on ECB page)
                   if (!ini_get(&#039;safe_mode&#039;) &amp;&amp; !ini_get(&#039;open_basedir&#039;))
                       curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
                   curl_setopt ($ch, CURLOPT_TIMEOUT, 3);
                   $contents = curl_exec ($ch);
                   curl_close($ch);
                // due to resolver bug in some curl versions (e.g. 7.15.5)
                // try again for constant IP.
                if (isset($site_ip))
                       $site=$site_ip;
               } while( ($contents == &#039;&#039;) &amp;&amp; $retry--);
        } else {
            $contents = url_get_contents($proto.$site.$filename);
        }
    }
    $val = &#039;&#039;;
    if ($provider == &#039;ECB&#039;)
    {
        $contents = str_replace (&quot;&lt;Cube currency=&#039;USD&#039;&quot;, &quot; &lt;Cube currency=&#039;EUR&#039; rate=&#039;1&#039;/&gt; &lt;Cube currency=&#039;USD&#039;&quot;, $contents);
        $from_mask = &quot;|&lt;Cube\s*currency=\&#039;&quot; . $curr_a . &quot;\&#039;\s*rate=\&#039;([\d.,]*)\&#039;\s*/&gt;|i&quot;;
        preg_match ( $from_mask, $contents, $out );
        $val_a = isset($out[1]) ? $out[1] : 0;
        $val_a = str_replace ( &#039;,&#039;, &#039;&#039;, $val_a );
        $to_mask = &quot;|&lt;Cube\s*currency=\&#039;&quot; . $curr_b . &quot;\&#039;\s*rate=\&#039;([\d.,]*)\&#039;\s*/&gt;|i&quot;;
        preg_match ( $to_mask, $contents, $out );
        $val_b = isset($out[1]) ? $out[1] : 0;
        $val_b = str_replace ( &#039;,&#039;, &#039;&#039;, $val_b );
        if ($val_b)
        {
            $val = $val_a / $val_b;
        }
        else
        {
            $val = 0;
        }
    }
    elseif ($provider == &#039;YAHOO&#039;)
    {
        $array = explode(&#039;,&#039;,$contents); // New operations for YAHOO. Safer.
        $val = $array[1];
        if ($val != 0)
            $val = 1 / $val;
    }
    elseif ($provider == &#039;GOOGLE&#039;)
    {
        $val = getInnerStr($contents, &#039;&lt;span class=bld&gt;&#039;, &#039; &#039;);
        if (empty($val) || $val+0 &lt;= 0.0001) {
            // reverse lookup on could not convert for too small values
            $filename = &quot;/bctzjpnsun/converter?a=1&amp;from={$curr_b}&amp;to={$curr_a}&quot;;
            $contents = url_get_contents($proto.$site.$filename);
            $val = getInnerStr($contents, &#039;&lt;span class=bld&gt;&#039;, &#039; &#039;);
        } else {
            if ($val != 0)
                $val = 1 / $val;
        }
    }
    elseif ($provider == &#039;BLOOMBERG&#039;)
    {
        $val = getInnerStr($contents, &#039;,&quot;price&quot;:&#039;, &#039;,&quot;&#039;);
    }
    elseif ($provider == &#039;CCA&#039;)
    {
        $rates = json_decode($contents, true);
        $val = $rates[$curr_b.&#039;_&#039;.$curr_a][&#039;val&#039;];
      }
    return $val;
}  /* end function get_extern_rate */</code></pre></div>]]></content>
			<author>
				<name><![CDATA[boxygen]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20175</uri>
			</author>
			<updated>2018-12-19T03:35:52Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33691#p33691</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33689#p33689" />
			<content type="html"><![CDATA[<p>Exchange-rates.org is absolutely fine one.&nbsp; It supports major 30 currencies in the world. But we have FA users from many small countries. We need to look up them as well. </p><p>So what I am suggesting is to adapt one more exchange rate provider. https://currencylayer.com or fixer.io to work on 168 currencies. They allow 1000 request per month for free of cost .&nbsp; I hope that&#039;s more than enough for them. Because we keep existing exchange rates for next requests. So let&#039;s provide them one more as well. Also we can provide them functionality to go premium to get extra. But that&#039;s their choice. Hope Joe and janusz will think of it..</p>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2018-12-19T02:55:00Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33689#p33689</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33688#p33688" />
			<content type="html"><![CDATA[<p>ECB exchange rate can be fixed by modifying from line 139 onwards in <strong>gl/includes/db/gl_db_rates.inc</strong>:<br /></p><div class="codebox"><pre><code>    if ($provider == &#039;ECB&#039;)
    {
        $filename = &quot;/stats/eurofxref/eurofxref-daily.xml&quot;;
        $site = &quot;www.ecb.europa.eu&quot;;
        $proto = &#039;https://&#039;;
        $site_ip=&quot;172.230.157.137&quot;;
        $contents=file_get_contents($proto.$site.$filename);
    }</code></pre></div><p>Also remove the trailing tab character in the config.default.php file for the $xr_providers line.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-19T02:43:02Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33688#p33688</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: No exchange rate working in FA now]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=33687#p33687" />
			<content type="html"><![CDATA[<p>https://fx-rate.net/USD/GBP/<br />Shows rate for 1000 units of source currency</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2018-12-19T02:27:23Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=33687#p33687</id>
		</entry>
</feed>
