Support A2Billing :

provided by Star2Billing S.L.

Support A2Billing :
It is currently Thu Apr 18, 2024 12:59 am
Hosted Voice Broadcast


All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Base Currency and currencies_update_yahoo.php Issue
PostPosted: Fri Aug 20, 2010 2:21 am 
Offline

Joined: Mon Mar 15, 2010 4:43 pm
Posts: 19
Hello,

I have previously installed A2Billing 1.3 and got the Base Currency working for EUR by making the change in the "a2billing.conf" file:
Code:
base_currency = eur

I also set the cronjob for it:
Code:
0 6 * * * php /var/lib/asterisk/agi-bin/libs_a2billing/crontjob/currencies_update_yahoo.php

everything was working fine.

I have also installed the A2Billing 1.4 months ago and got the Base Currency set to EUR by making the appropriate changes such as make the change in the "a2billing.conf" in the database via the A2Billing GUI under the SYSTEM SETTING. This time I ran the php file once to make the changes as I was not interested in getting update from "yahoo" and only wish to change currency shown under the customer and the admin portal as shown here:

Attachment:
untitled.JPG
untitled.JPG [ 19.3 KiB | Viewed 8970 times ]


Code:
php /usr/src/a2billing/Cronjobs/currencies_update_yahoo.php

As I have recently tried to change the base currency on my test setup for both A2Billing 1.3 and A2Billing 1.4, I have realised the currency is not updated. The log file "/tmp/cront_a2b_currency_update.log" on my A2Billing 1.3 shows that the Currency Update has been facing issues recently. This is the error that has been accumulated in the log file:
Code:
[13/08/2010 06:00:02]:[currencies_update_yahoo.php line:51[#### START CURRENCY UPDATE ####]]

[13/08/2010 06:00:03]:[currencies_update_yahoo.php line:63Our base_currency seems to be worthless. Currency update ABORTED.]

I also have noticed the the downloaded CVS file "/tmp/currencies.cvs" from yahoo is populated with 151 line of "0.00" which I guess means nothing meaningful/useful has been downloaded.

I also check the information available in the database under table cc_currencies and it shows the "lastupdate" was at "2010-08-08 06:00:04". If I am not mistaken, in the situations that I don't wish to update the currency conversion, I should be able to fix the problem by changing the "basecurrency" from USD to EUR in the cc_currencies table, but the problem will still be there or writting a small script to access the cc_currencies table and update the conversion which in this case it would be reinventing the wheel if you know what I mean and that is not the route that I would like to go.

I appears that for no particular reason known to me the update currency has been stop! The A2Billing 1.3 has been up and running for more than a year.

I also tried downloading couple of currency conversion rates from yahoo using:
Code:
http://finance.yahoo.com/d/quotes.csv?s=USDALL=X+USDDZD=X+USDXAL=X+USDARS=X+U SDAWG=X+USDAUD=X+USDBSD=X+USDBHD=X+USDBDT=X+USDBBD =X+USDBYR=X+USDBZD=X+USDBMD=X+USDBTN=X+USDBOB=X+US DBRL=X+USDGBP=X+USDBND=X+USDBGN=X+USDBIF=X+USDKHR= X+USDCAD=X+USDKYD=X+USDXOF=X+USDXAF=X+USDCLP=X+USD CNY=X+USDCOP=X+USDKMF=X+USDXCP=X+USDCRC=X+USDHRK=X +USDCUP=X+USDCYP=X+USDCZK=X+USDDKK=X+USDDJF=X+USDD OP=X+USDXCD=X+USDECS=X+USDEGP=X+USDSVC=X+USDERN=X+ USDEEK=X+USDETB=X+USDEUR=X+USDFKP=X+USDGMD=X+USDGH C=X+USDGIP=X+USDXAU=X+USDGTQ=X+USDGNF=X+USDHTG=X+U SDHNL=X+USDHKD=X+USDHUF=X+USDISK=X+USDINR=X+USDIDR =X+USDIRR=X+USDILS=X+USDJMD=X+USDJPY=X+USDJOD=X+US DKZT=X+USDKES=X+USDKRW=X+USDKWD=X+USDLAK=X+USDLVL= X+USDLBP=X+USDLSL=X+USDLYD=X+USDLTL=X+USDMOP=X+USD MKD=X+USDMGF=X+USDMWK=X+USDMYR=X+USDMVR=X+USDMTL=X +USDMRO=X+USDMUR=X+USDMXN=X+USDMDL=X+USDMNT=X+USDM AD=X+USDMZM=X+USDNAD=X+USDNPR=X+USDANG=X+USDTRY=X+ USDNZD=X+USDNIO=X+USDNGN=X+USDNOK=X+USDOMR=X+USDXP F=X+USDPKR=X+USDXPD=X+USDPAB=X+USDPGK=X+USDPYG=X+U SDPEN=X+USDPHP=X+USDXPT=X+USDPLN=X+USDQAR=X+USDROL =X+USDRON=X+USDRUB=X+USDRWF=X+USDWST=X+USDSTD=X+US DSAR=X+USDSCR=X+USDSLL=X+USDXAG=X+USDSGD=X+USDSKK= X+USDSIT=X+USDSOS=X+USDZAR=X+USDLKR=X+USDSHP=X+USD SDD=X+USDSRG=X+USDSZL=X+USDSEK=X+USDCHF=X+USDSYP=X +USDTWD=X+USDTZS=X+USDTHB=X+USDTOP=X+USDTTD=X+USDT ND=X+USDUSD=X+USDAED=X+USDUGX=X+USDUAH=X+USDUYU=X+ USDVUV=X+USDVEB=X+USDVND=X+USDYER=X+USDZMK=X+USDZW D=X+USDGYD=X&f=l1

just to see if there has been any changes on the yahoo site which is causing the issue and I had no problem getting the CSV file with conversion rate. I didn't check the number to see if they are GOOD but I have a 100+ rows of digits rather than 151 line of "0.00"

Can someone tell me where the "log file for Cron Currency Update" is in A2Billing 1.4?

Thank you in advance for your help.

Babak :)


Top
 Profile  
 
 Post subject: Re: Base Currency and currencies_update_yahoo.php Issue
PostPosted: Fri Aug 20, 2010 9:09 am 
Offline

Joined: Fri Jun 23, 2006 3:56 pm
Posts: 4065
See viewtopic.php?f=1&t=7669

Joe


Top
 Profile  
 
 Post subject: Re: Base Currency and currencies_update_yahoo.php Issue
PostPosted: Sat Aug 21, 2010 2:36 am 
Offline

Joined: Mon Mar 15, 2010 4:43 pm
Posts: 19
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
untitled 2.JPG [ 18.69 KiB | Viewed 8810 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=1

We 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 :)


Last edited by Avestan on Sat Aug 21, 2010 4:17 pm, edited 11 times in total.

Top
 Profile  
 
 Post subject: Re: Base Currency and currencies_update_yahoo.php Issue
PostPosted: Sat Aug 21, 2010 8:23 am 
Offline

Joined: Fri Jun 23, 2006 3:56 pm
Posts: 4065
Hi
Quote:
Even though the A2Billing offers conversion of currencies which make the platform flexible, but the problem is if the continues change of conversion rate.


Yes this is the case, and it is my advice to use a separate instance of A2Billing for each currency, provided that the amount of traffic is worthwhile.

I don't see an easy logical solution to the problem of running multiple currencies on the same installation of A2Billing, short of the solution you have come up with, however, even that is not perfect, in as much as I imagine you have three GUI's to manage.

Another approach would be to use virtualisation if you wanted the installations on the same hardware.

For interest, why did you not just upgrade to 1.7.1, or do your modifications make that unreasonably difficult?

Joe


Top
 Profile  
 
 Post subject: Re: Base Currency and currencies_update_yahoo.php Issue
PostPosted: Sat Aug 21, 2010 2:42 pm 
Offline

Joined: Mon Mar 15, 2010 4:43 pm
Posts: 19
Hello,

In no shape or form I was trying to convey this as a short coming on the A2Billing end. I personally believe A2Billing Group has done a great job. I was trying to point the mad world and the continuous changes that A2Billing has to deal with it.

You are absolutely correct that in the solution I have offered, for the Three Base Currencies, admin ends up with Three Database, and GUI, and etc. But the other benefit to this would be a better data protection in the case of data corruption "Don't Put All Your Eggs In One Basket". If I am not mistaken, it also improves on the speed of you database query since you will end up with three smaller databases rather than one larger database. But as you pointed out, for my 12 customer, none of the benefit I mentioned would play an important part and the benefit starts to become appealing as the number of customer increases. I personally, think there are pros and cons and one should make their own judgment once they are provided with all the information.

Virtualization is something I have tried to stay away from for a long time. I don’t have much experience in it and I am unable to pass any judgment on it. Maybe once I get more free time, I will look into it. But thanks for the advice.

Since I have always been running behind, I haven’t come around to install the A2Billing 1.7. You should have noticed that from my Fedora 7 OS! :wink:

The main reason for using A2Billing 1.3 for Testing and A2Billing 1.4 for production is like looking under the hood of a classic car. I always end up admiring the genius way that they came up with in order to over come issues and not to forget things make more sense if you know what I mean. Here is a test, take a look at the engine of your 2011 auto and see if you can locate the thermostat!

Any ways, I have been looking more into the code and have been dusting on my php and I think the issue with yahoo currency update is due to strong_currency “XAG”, if I am not mistaken it is around line 1279 of Misc.php file where you guys talk about “addiction to tea and biscuits”. :D

Thank you have a have a great weekend.

Avestan :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 
Voice Broadcast System


All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group