<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Adapting to google's error when getting exchange rates.]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=7150&amp;type=atom" />
	<updated>2017-11-26T23:14:18Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=7150</id>
		<entry>
			<title type="html"><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=29773#p29773" />
			<content type="html"><![CDATA[<p><a href="https://github.com/FrontAccountingERP/FA/commit/ff67198fa8d011c788e8fb6d6d726a1712b6597e">Committed</a> to stable Repo.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-11-26T23:14:18Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=29773#p29773</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=29771#p29771" />
			<content type="html"><![CDATA[<p>Willdo later.</p><p>Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2017-11-26T17:33:35Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=29771#p29771</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=29770#p29770" />
			<content type="html"><![CDATA[<p>@joe: want to commit this with a check for <strong>if (empty($val)) {</strong> ?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2017-11-26T16:21:02Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=29770#p29770</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Adapting to google's error when getting exchange rates.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=29762#p29762" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2017-11-26T12:45:10Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=29762#p29762</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Adapting to google's error when getting exchange rates.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=29760#p29760" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2017-11-26T12:30:31Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=29760#p29760</id>
		</entry>
</feed>
