Hello everyone,
First of all, thank you jroper for pointing me to the posting.
I also would like to inform others with the same issue that I managed to fix the issue and here is the solution to the problem:
I am using Fedora 7 and the location of the file in question may be different if you are running a different Operating System.
The file that needs to be fix is "Misc.php"
Code:
#nano -c /usr/src/a2billing/common/lib/Misc.php
Look for the following section of the code under function "currencies_update_yahoo ($DBHandle, $instance_table)". The line should start around 1109 which is 72% into the file:
Code:
// we will retrieve a .CSV file e.g. USD to EUR and USD to CAD with a URL like:
// http://download.finance.yahoo.com/d/quotes.csv?s=USDEUR=X+USDCAD=X&f=l1
if (is_array($old_currencies)) {
$num_cur = count($old_currencies);
if ($FG_DEBUG >= 1)
$return .= basename(__FILE__) . ' line:' . __LINE__ . "[CURRENCIES TO UPDATE = $num_cur]\n";
for ($i = 0; $i < $num_cur; $i++) {
if ($FG_DEBUG >= 1)
$return .= $old_currencies[$i][0] . ' - ' . $old_currencies[$i][1] . ' - ' . $old_currencies[$i][2] . "\n";
// Finish and add termination ?
if ($i +1 == $num_cur) {
$url .= $strong_currency . $old_currencies[$i][1] . "=X&f=l1";
} else {
$url .= $strong_currency . $old_currencies[$i][1] . "=X+";
}
// Save the index of base_currency when we find it
if (strcasecmp(BASE_CURRENCY, $old_currencies[$i][1]) == 0) {
$index_base_currency = $i;
}
}
and change it to:
Code:
// we will retrieve a .CSV file e.g. USD to EUR and USD to CAD with a URL like:
// http://download.finance.yahoo.com/d/quotes.csv?s=USDEUR=X+USDCAD=X&f=l1
if (is_array($old_currencies)) {
$num_cur = count($old_currencies);
if ($FG_DEBUG >= 1)
$return .= basename(__FILE__) . ' line:' . __LINE__ . "[CURRENCIES TO UPDATE = $num_cur]\n";
for ($i = 0; $i < $num_cur; $i++) {
if ($FG_DEBUG >= 1)
$return .= $old_currencies[$i][0] . ' - ' . $old_currencies[$i][1] . ' - ' . $old_currencies[$i][2] . "\n";
// Finish and add termination ?
if ($i +1 == $num_cur) {
//$url .= $strong_currency . $old_currencies[$i][1] . "=X&f=l1"; <--- Comment This Line...
$url .= $old_currencies[$i][2] . $old_currencies[$i][1] . "=X&f=l1"; <--- Add This Line...
} else {
//$url .= $strong_currency . $old_currencies[$i][1] . "=X+"; <--- Comment This Line...
$url .= $old_currencies[$i][2] . $old_currencies[$i][1] . "=X+"; <--- Add This Line...
}
// Save the index of base_currency when we find it
if (strcasecmp(BASE_CURRENCY, $old_currencies[$i][1]) == 0) {
$index_base_currency = $i;
}
}
Don't forget to run the yahoo update currencies file "currencies_update_yahoo.php" ... before you leave the job to the Cron for the auto-run.
Code:
#php /usr/src/a2billing/Cronjobs/currencies_update_yahoo.php
Now you should have your good old Yahoo Currencies Update back.
Attachment:
untitled 2.JPG [ 18.69 KiB | Viewed 8829 times ]
Here is the explanation of the situation and the fix. After looking into A2Billing code and heavy dusty of my php, I can conclude the A2Billing download list of XAG - Currencies conversion from yahoo. Once it has the conversion rate in possession, then it find Base Currency's value in strong currency to help avoid Yahoo's early truncation, and therefore win back a lot of accuracy. It appears that yahoo have stopped to provide conversion on strong currency XAG. Why?! I don't know, yahoo's action never made sense to me and that is why there were early provider of many services and in time people moved to other services. So, add this one to the list also. As the result when you look at the downloaded file "/etc/tmp/currencies.cvs" you will notice 151 line of "0.00" which simply means yahoo gave you no currency conversion to strong currency XAG. Here is the link to the Strong Currency terminology:
http://coinmill.com/XAG_calculator.html#XAG=1We are lucky that A2Billing has placed some flags for the service and the A2Billing checks to see if we have end-up with a valid currencies.cvs file. Due to yahoo changes the currencies.cvs is worthless and the flags doesn't allow any update of currencies and you will continue to have your old currency rate in your database. If they have not set the flag your database would have been populated with lost of Zero Conversion Rate. In case you are intrested to know when was the last time the Currency Conversion Rates were updated, you can check the date by going to table cc_cuurencies of your A2Billing DataBase.
There are issues with my fix which is due to use of strong_currency XAG. If I am not mistaken the currency conversion accuracy is going to be subject to this issue but I am not seeing any issue with strong currencies like USD, EUR, CAD, etc. I scanned the cc_currencies table of the DataBase, and I noticed GYD is one that has suffered. By the way, GYD stands for Guyana Dollar (GYD). But please check the currencies that you are interested in to see how they get effected before offering the service back to your customer. I will see how I can over come the issue and will post the better solution to the yahoo issue.
Here is some information that you might find helpful when it comes to currencies. Even though the A2Billing offers conversion of currencies which make the platform flexible, but the problem is if the continues change of conversion rate. Therefore, if the Base Currency is in USD and you decide to offer the service in both USD and EUR, the EUR customer will be subject to balance fluctuation to the change in Exchange Rate.
To over come this issue, I am running Three instances of A2Billing and separating the customers base on their currencies into A2Billingusd, A2Billingcad, A2Billingeur to cover USA, CAD, and EUR customers, respectively. In this case the Base Currency is the currency used by the customer and consequently, and their balance doesn't fluctuates base on the exchange rate since their balance is based on the Base Currency.
In order to setup the system as such, you need to have three A2Billing databases and some changes in the A2Billing files in order to make sure everything is working flawlessly. The changes are not very complex but they are not the regular changes that needs to be done to get the system up and running by default. If you need any information on how to setup such a system, I will be more than happy to walk you thru.
I hope you find this information useful.
Thanks,
Avestan