This recipe synchronizes currency exchange rates on an as needed basis or on a periodic basis. This is extremely useful for enterprises that deal with multiple currencies need to track the exchange rates for the purpose of their commercial documentation involving money. Vtiger by default provides a currency management module, where the present implementation limitations are
- No change of data stored for trend analysis of currency rate fluctuations
- Requires updating of exchange rates manually
The present vtiger currency management module will be modified to realize the additional requirements. Yahoo Finance provides an API which is used for the purpose of this implementation. Other services exist, including the paid for real time rate queries provided by financial information agencies. While Yahoo’s rates are not real time, it is available for free and has a popularly used API.
Implementation and Features
- Independent script that would be executable either by a cron job or by a call from Vtiger currency module.
- Vtiger currency module would need to have an additional button, which when clicked, would call the current rates from Yahoo Finance and update the rates.
- A new exchange rate change table to be added to the database.
- Above features to be packed into a module and made installable via vtiger module manager installable zip file.
Present vTiger system features vtiger menu- Settings
The currency management module of vtiger is accessible from the Settings menu link. Selecting this module brings up the currency management screen where once can manage the list of currencies that are to be configured in the system. In our example, we have setup a typical situation of a enterprise that deals with vendors, suppliers and customers, channel partners from many countries, and in this case, we have selected 21 different currencies. Figure 1 : New Currency setup form Figure 2 : Multiple currencies setup for testing
Figure 3 : Updates to user interface for exchange rate update
- Scripts modified – Smarty/templates/CurrencyListView.tpl, vtigercron.php
- Scripts added – getxrates.php
- Tables modified – vtiger_currency_info
- Tables added – vtiger_currencies_rates
- Other changes – Permissions on directories, Smarty/templates
Cheat sheet using Yahoo! Finance API
- http://www.gummy-stuff.org/Yahoo-data.htm
- http://allurcode.com/2010/11/08/get-live-exchange-rates-in-php/
A premium real time forex rate service
- http://www.exchangerate-api.com/
Further enhancements
- Historical exchange rates log table storage parameters ( no of days, no of records ). See UI concept in figure
- Link to other / alternative exchange rate sources
- Store rates from more than one source
https://raw.github.com/currencybot/open-exchange-rates/master/latest.json vtiger tables’ details
- vtiger_currencies
- vtiger_currencies_seq
- vtiger_currency
- vtiger_currency_decimal_separator
- vtiger_currency_decimal_separator_seq
- vtiger_currency_grouping_pattern
- vtiger_currency_grouping_pattern_seq
- vtiger_currency_grouping_separator
- vtiger_currency_grouping_separator_seq
- vtiger_currency_info
- vtiger_currency_info_seq
- vtiger_currency_symbol_placement
- vtiger_currency_symbol_placement_seq
[code language=”PHP”]</pre>
<?php
//
//CREATE TABLE ‘vtiger_currencies_rates’ ( ‘Id’ int(11) NOT NULL auto_increment, PRIMARY KEY (‘Id’) ) ENGINE=MyISAM COMMENT=’Stores the daily exchange rates against the default currency for all other currencies found in the vtiger_currency_info table’ CHARACTER SET=’utf8′;
//ALTER TABLE vtiger_currencies_rates ADD (currency_code VARCHAR(10), exchange_rate DECIMAL(12,6), rate_date DATE, rate_time TIME);
//ALTER TABLE vtiger_currency_info ADD xr_date DATETIME;
require_once(“config.php”);
require_once(‘include/logging.php’);
require_once(‘include/utils/CommonUtils.php’);
require_once(‘include/utils/VtlibUtils.php’);
$log = &LoggerManager::getLogger(‘Get Currencies Exchange rates’);
global $adb,$log;
$tdt=date(‘Y-m-d’);
$action = $_REQUEST[‘action’];
if ($action == ‘List’ || $action == ‘list’)
{
$sql_sel=”select * from vtiger_currencies_rates order by id desc “;
$dresult = $adb->pquery($sql_sel, array());
while($row = $adb->fetch_array($dresult))
{
echo $row[‘id’] .’, ‘. $row[‘rate_date’] .’, ‘. $row[‘rate_time’] .’, ‘. $row[‘currency_code’] .’, ‘. $row[‘exchange_rate’] .'<br>’ ;
}
}
else
{
$sql_sel=”select currency_code from vtiger_currency_info where currency_name = ? “;
$dresult = $adb->pquery($sql_sel, array($currency_name));
$from = $adb->query_result($dresult,0,”currency_code”);
$sql_sel=”select currency_code from vtiger_currency_info where currency_name <> ? “;
$result = $adb->pquery($sql_sel, array($currency_name));
while($row = $adb->fetch_array($result))
// loop thru all currencies in the table, obtain the information from Yahoo Finance and insert new records into the table with a datetimestamp of loading
{
$to= $row[‘currency_code’];
$xrate = getYahooXrate($from,$to);
sleep (1);
$xval=$xrate[0];
if ($xrate && $xrate[0] > 0 )
{
$ins_sql= “INSERT INTO vtiger_currencies_rates (currency_code, exchange_rate, rate_date, rate_time) VALUES (‘$to’, $xval, CURDATE(), CURTIME() )”;
$upd_sql= “UPDATE vtiger_currency_info set conversion_rate = ?, xr_date=NOW() where currency_code= ?”;
$uresult= $adb->pquery($upd_sql, array($xval,$to) );
}
else
{
$to .= “-FAILED”;
$ins_sql= “INSERT INTO vtiger_currencies_rates (currency_code, exchange_rate, rate_date, rate_time) VALUES (‘$to’, 0, CURDATE(), CURTIME() ) ;”;
}
$iresult = $adb->pquery($ins_sql, array() );
}
}
function getYahooXrate($cur_from,$cur_to)
{
$yf_url = ‘http://finance.yahoo.com/d/quotes.csv?f=l1d1t1&s=’.$cur_from.$cur_to.’=X’;
$handle = fopen($yf_url, ‘r’);
if ($handle)
{
$result = fgetcsv($handle);
return $result;
fclose($handle);
}
else
{
return false;
}
}
?>
[/code]
Template file Smarty/templates/ CurrencyListView.tpl, near line # 52
This is the orginal code
[code language=”PHP”]
<input class=”crmButton create small” type=”submit” value=”{$MOD.LBL_NEW_CURRENCY}” />[/code]
This has to be like this
[code language=”PHP”]
<a href=”getxrates.php” target=”_blank”>Refresh Rates</a>
<input class=”crmButton create small” onclick=””alert(“Cookbook” type=”submit” value=”value=” />
<input class=”crmButton create small” onclick=””href:” type=”submit” value=”value=” />”>
<input class=”crmButton create small” type=”submit” value=”{$MOD.LBL_NEW_CURRENCY}” /> [/code]
—————————————————————————————————–
Check www.vtigress.com for the latest release of vtDZiner.
Use Promo Code vtDZinerWP and avail a discount of 5% on the sale price of vtDZiner
—————————————————————————————————–
What Client’s Say
They worked quickly and effectively to build a custom CRM for our Co-Pilot team
myEnterprise team are a pleasure to work with. They worked quickly and effectively to build a custom CRM for our Co-Pilot team. They have always responded quickly throughout the project and for any issues or concerns we had and myEnterprise team always made themselves available to speak to us. We are extremely happy with our CRM and we would recommend working with myEnterprise Team
A strong development partner
We thank the team at myEnterprise BizAutomations for their knowledge, professionalism, dedication and friendliness. They are quick to understand our requirements, offer creative designs, follow project plans, and meet timelines – all of this while accommodating our changing needs. They are always there to help us when we need support. myEnterprise is a valuable business partner. We hope you find this satisfactory. Thank you myEnterprise team.
VTigress team is one of the best in this field
“VTigress team is the real professionals in this field. They are the right team of the right job. They can provide solution exactly what we wanted extremely fast and accurately. I have been working with many IT professionals, I can say that VTigress team is one of the best I've ever worked with. I also appreciate their quick and courteous responses. We look forward to continue working with them in the future.”
I would highly recommend myEnterprise to anyone who wanted to start the vTiger journey.
It has been a privilege and an honor to work with you and your team. I was looking for a capable long term partner for vTiger CRM implementation and have been lucky to find myEnterprise Team. The team understood my various requirements and came back with excellent solutions that delighted my users. Moreover, the team went over and above to support the project in time of crisis. What I like the best is the value system and the work ethics along with the in-depth technical knowledge which is so rare to find these days. I would highly recommend myEnterprise to anyone who wanted to start the vTiger journey.
I strongly recommend myEnterprise BizAutomations for all your business automation requirements.
We have started our operations 6 months back in Hyderabad & was facing challenges in terms of managing customer inquiries, lead management & automation of the business process. Our needs were very unique in terms of message automation & customized dashboards. myEnterprise has gone out of the box to get what we needed. I strongly recommend myEnterprise for all your business automation requirements. Wishing them all the very best for their future endeavors.
I am a fan of the Team. 30-Jan-2020
My relationship with vTigress/myenterprise.in team began in August 2011, when I needed a vTiger module created for a client. I found ST Prasad as a result of a web search; I talked with ST about my requirements and felt confident this was a good fit. I was on a tight schedule (4 days) at the time and ST made it possible to meet my timeline, with minimal updates to the code. I have continued working with the team, using their vtDZiner module; upgrades of vTiger versions; development of a XERO private app. At all times I have been afforded their best efforts for every development request. Their advice on how to proceed for every project has always been clear and their work is solid. As system environment requirements have changed, the team have been very happy to provide recommendations and assistance where requested.
Professional and Unmatched Service
I would like to appreciate myEnterprise for their professional and unmatched service. Their team helped us to customize Vtiger CRM for our business. Their experience in Vtiger not only helped us to solve the issue that we had but also guided us to use it in a very efficient manner. Their useful and guided suggestions have eased the job of my team in using the CRM
Specialized and Qualified Expertise in Developing
myEnterprise Services has provided us with specialised and qualified expertise in developing our own CRM module. Our industry requires that our CRM module be both ISO 17025(2005) and Safe Quality Food (SQF) compliant. These customization’s included, but were not limited to, integration to existing 3rd party e- commerce applications, enhanced inventory tracking, creation of sample analysis records. Since the start of our project in 2011 the myEnterprise team has demonstrated its ability to adapt to our work environment.
Specialized and Qualified
myEnterprise Services has provided us with specialized and qualified expertise in developing our own Sales and Marketing CRM and we are writing to recommend the services of myEnterprise Services. We have been using myEnterprise Services for CRM build and customisation since December 2016. Our Experience with the development team is that their service has been professional and they are very responsive and good with understanding our needs.
Exceptional service
My Experience with the development team at myEnteprise is that they are very responsive, good with understanding our needs and fast in response whenever we have an issue. We have been using myEnterprise Services since 2016 to develop and maintain Payroll Management system on Vtiger. Since Vtiger is a CRM system a lot of complicated customizations had to be done to accept Organization, Employee based data along with many complex backend calculations.
Good understanding and fast in response
I have been using myEnterprise Services since the year 2013 to develop a vtiger/vtigress based global Research & Development database solution. My experience with the developer team at myEnterprise Services is, that they are very responsive, good with the understanding of our needs and fast in response whenever we have an issue. I'm happy to recommend the services of myEnterprise Services.
Excellent Work
They are highly talented people. Once you present an idea, they will create it for you and will exceed your expectations. I highly recommend this company for doing such a fantastic job with us to solve our problems.
vTigress have helped us
vTigress have helped us migrate from On Demand to Opensource Vtiger 7, by aligning the two databases and creating additional module extensions and plugins that have enabled us to build a much more practical and user friendly system for our very specific business needs. There are so many possibilities with this system, and vTigress have the knowledge, skills and desire to develop what you need.
I was very impressed
I was very impressed with the entire process: from establishing my needs through to delivery. They provided lots of clarification and reassurance throughout, and were quick to respond to any questions.I would definitely recommend their services to anyone requiring custom development work.
Satisfactorily conducted
This is to acknowledge that Theme Animations Pvt. Ltd. has worked with Tata BSS for three(3) CRM implementations for its clients covering the following areas:· Marketing & Sales, Lead and Campaign Management, Opportunity and Contact Management,· Support & Service Ticketing, Case & Complaint Management, Service Request.All the above projects were satisfactorily conducted and completed without any delay.
Excellent support!
We solved for one of our end customers the problem of following user activity and working with their crm data updates. History++ , Forensic View and a custom auto logout plugins were integrated to make a new type of user follow-up tool. The communication with Myenterprise and understanding of the problem was excellent. We can gladly recommend using their services and extensions.
The quality of their work
The quality of their work, combined with the quick turn-around and out-of-the box creative ideas was extremely impressive. They Again super result, Fast Communication. A+++Highly recommended