<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Exchange Rates - Add Australian RBA as Provider]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=9221&amp;type=atom" />
	<updated>2021-03-08T07:39:14Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=9221</id>
		<entry>
			<title type="html"><![CDATA[Re: Exchange Rates - Add Australian RBA as Provider]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39236#p39236" />
			<content type="html"><![CDATA[<p>@joe: ?</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2021-03-08T07:39:14Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39236#p39236</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Exchange Rates - Add Australian RBA as Provider]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39224#p39224" />
			<content type="html"><![CDATA[<p>The Reserve Bank of Australia (RBA) is Australia&#039;s central bank, and they supply an official exchange rate at https://www.rba.gov.au/rss/rss-cb-exchange-rates.xml.</p><p>I have made changes to the Exchange Rates function to include the RBA as a provider.</p><p>To use this, change the config file (<strong>config.php</strong>) so that:</p><div class="codebox"><pre><code>$xr_providers = array(&quot;ECB&quot;, &quot;YAHOO&quot;, &quot;GOOGLE&quot;, &quot;BLOOMBERG&quot;,&quot;RBA&quot;);
$dflt_xr_provider = 4;</code></pre></div><p>Hope this helps</p><div class="codebox"><pre><code>gl/includes/db/gl_db_rates.inc

@@ -170,6 +170,13 @@ function get_extern_rate($curr_b, $provider = &#039;ECB&#039;, $date)
         $proto = &#039;https://&#039;;
         $contents=file_get_contents($proto.$site.$filename);
     }
+    elseif ($provider == &#039;RBA&#039;)
+    {
+        $filename = &quot;/rss/rss-cb-exchange-rates.xml&quot;;
+        $site = &quot;www.rba.gov.au&quot;;
+        $proto = &#039;https://&#039;;
+        $contents=file_get_contents($proto.$site.$filename);
+    }
     if (empty($contents)) {
         if (function_exists(&#039;curl_init&#039;))
         {    // first check with curl as we can set short timeout;

@@ -240,6 +258,40 @@ function get_extern_rate($curr_b, $provider = &#039;ECB&#039;, $date)
         $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);
     }
+    elseif ($provider == &#039;RBA&#039;)
+    {
+        $data = new SimpleXMLElement($contents);
+        $data-&gt;registerXPathNamespace(&#039;ns&#039;, &#039;http://purl.org/rss/1.0/&#039;);
+        $data-&gt;registerXPathNamespace(&#039;cb&#039;, &#039;http://www.cbwiki.net/wiki/index.php/Specification_1.2/&#039;);
+
+        $val_a = 0;
+        $val_b = 0;
+        
+        for ($i = 0; $i &lt; count($data-&gt;xpath(&#039;ns:item&#039;)); $i++) {
+            if ($curr_a == &#039;AUD&#039;)
+            {
+                $val_a = 1;
+            }
+            elseif ($curr_a == $data-&gt;item[$i]-&gt;children(&#039;cb&#039;,TRUE)-&gt;statistics[0]-&gt;exchangeRate[0]-&gt;targetCurrency )
+            {
+                $val_a = (float) $data-&gt;item[$i]-&gt;children(&#039;cb&#039;,TRUE)-&gt;statistics[0]-&gt;exchangeRate[0]-&gt;observation[0]-&gt;value;
+            }
+
+            if ($curr_b == &#039;AUD&#039;) {
+                $val_b = 1;
+            }
+            elseif ($curr_b == $data-&gt;item[$i]-&gt;children(&#039;cb&#039;,TRUE)-&gt;statistics[0]-&gt;exchangeRate[0]-&gt;targetCurrency )
+            {
+                $val_b = (float) $data-&gt;item[$i]-&gt;children(&#039;cb&#039;,TRUE)-&gt;statistics[0]-&gt;exchangeRate[0]-&gt;observation[0]-&gt;value;
+            }
+        }
+
+        if ($val_b) {
+            $val = $val_a / $val_b;
+        } else {
+            $val = 0;
+        }
+    }
     return $val;
 }  /* end function get_extern_rate */</code></pre></div>]]></content>
			<author>
				<name><![CDATA[PaulShipley]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20029</uri>
			</author>
			<updated>2021-03-07T01:44:27Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39224#p39224</id>
		</entry>
</feed>
