<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[FrontAccounting forum — Adapting to google's error when getting exchange rates.]]></title>
		<link>https://frontaccounting.com/punbb/viewtopic.php?id=7150</link>
		<atom:link href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7150&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Adapting to google's error when getting exchange rates..]]></description>
		<lastBuildDate>Sun, 26 Nov 2017 23:14:18 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=29773#p29773</link>
			<description><![CDATA[<p><a href="https://github.com/FrontAccountingERP/FA/commit/ff67198fa8d011c788e8fb6d6d726a1712b6597e">Committed</a> to stable Repo.</p><p>/Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 26 Nov 2017 23:14:18 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=29773#p29773</guid>
		</item>
		<item>
			<title><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=29771#p29771</link>
			<description><![CDATA[<p>Willdo later.</p><p>Joe</p>]]></description>
			<author><![CDATA[null@example.com (joe)]]></author>
			<pubDate>Sun, 26 Nov 2017 17:33:35 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=29771#p29771</guid>
		</item>
		<item>
			<title><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=29770#p29770</link>
			<description><![CDATA[<p>@joe: want to commit this with a check for <strong>if (empty($val)) {</strong> ?</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 26 Nov 2017 16:21:02 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=29770#p29770</guid>
		</item>
		<item>
			<title><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=29762#p29762</link>
			<description><![CDATA[<p>The reason is that it is a very big numner for these conversions:<br />1 EUR = 24810.7356 STD<br />The inverse obtained is obviously too small:<br />1 STD = 0.000040305133073120169802623667474011 EUR<br />This is more than the 4 digits after the decimal place.<br />Hence Google needs to increase the number of decimal places for such evaluations.<br />Doing it in FA with the default values will be of no use and hence @notrinos solution is elegant.</p><p>If you search for &quot;1 STD = ? EUR&quot; you will get 0.000040 as the answer now.<br />Hence their evaluator for the search engine is okay.</p><p>Incidentally, we may have a Chart of Accounts for Sao Tome among the forum users - <a href="https://frontaccounting.com/punbb/profile.php?id=20777">@odaio</a>!</p><p><s>Alternatively, if all the reverse rates work, then we can swap the currencies and make just 1 single check.</s> The reverse for IDR to OMR does not work.</p><p>USD to any currency works - hence only when a non USD is involved as the From and To currencies, we will need 2 conversions and then a division! Here we will have the second check only when the first fails.</p>]]></description>
			<author><![CDATA[null@example.com (apmuthu)]]></author>
			<pubDate>Sun, 26 Nov 2017 12:45:10 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=29762#p29762</guid>
		</item>
		<item>
			<title><![CDATA[Adapting to google's error when getting exchange rates.]]></title>
			<link>https://frontaccounting.com/punbb/viewtopic.php?pid=29760#p29760</link>
			<description><![CDATA[<p>I have found google does not convert following currencies STD,&nbsp; ITL, IRR, FRF, DEM, VND, BYR to USD but it does opposite (USD to those currencies).</p><p>Should we change lines <strong>213-225 of gl_db_rates.inc</strong></p><div class="codebox"><pre><code>elseif ($provider == &#039;GOOGLE&#039;)
    {
        $val = &#039;&#039;;
        
        $regexp = &quot;%([\d|.]+)\s+{$curr_a}\s+=\s+&lt;span\sclass=(.*)&gt;([\d|.]+)\s+{$curr_b}\s*&lt;/span&gt;%s&quot;;
        if (preg_match($regexp, $contents, $matches)) 
        {
            $val = $matches[3];
            $val = str_replace(&#039;,&#039;, &#039;&#039;, $val);
            if ($val != 0)
                $val = 1 / $val;
        }
    }</code></pre></div><p>TO</p><div class="codebox"><pre><code>    elseif ($provider == &#039;GOOGLE&#039;)
    {
        $val = &#039;&#039;;
        
        $regexp = &quot;%([\d|.]+)\s+{$curr_a}\s+=\s+&lt;span\sclass=(.*)&gt;([\d|.]+)\s+{$curr_b}\s*&lt;/span&gt;%s&quot;;
        if (preg_match($regexp, $contents, $matches)) 
        {
            $val = $matches[3];
            $val = str_replace(&#039;,&#039;, &#039;&#039;, $val);
            if ($val != 0)
                $val = 1 / $val;
        }
// Start of New Code lines
        if(!$val) {
                $filename = &quot;/finance/converter?a=1&amp;from={$curr_b}&amp;to={$curr_a}&quot;;
                $regexp = &quot;%([\d|.]+)\s+{$curr_b}\s+=\s+&lt;span\sclass=(.*)&gt;([\d|.]+)\s+{$curr_a}\s*&lt;/span&gt;%s&quot;;
                $contents = url_get_contents(&quot;http://&quot;.$site.$filename);
                if (preg_match($regexp, $contents, $matches))  {
                    $val = $matches[3];
                    $val = str_replace(&#039;,&#039;, &#039;&#039;, $val);
                }
        }
// End of New code lines
    }</code></pre></div><p>to adapting to the google&#039;s issue ?</p><p>if this issue will not be solved FA will shows folowing red error comment:<br /><span style="color: red">number_format() expects parameter 2 to be integer, float given in file: C:\xampp\htdocs\fa243\includes\current_user.inc at line 318</span></p>]]></description>
			<author><![CDATA[null@example.com (notrinos)]]></author>
			<pubDate>Sun, 26 Nov 2017 12:30:31 +0000</pubDate>
			<guid>https://frontaccounting.com/punbb/viewtopic.php?pid=29760#p29760</guid>
		</item>
	</channel>
</rss>
