clever-host Posted February 10, 2015 Share Posted February 10, 2015 hello, I need to modify invoicepdf.tpl template. Template must contain two currencies exchange. Example: Euro and Dollar (EUR and USD). On the invoice need to be price in dollars and in euros. You can help me, please? 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted February 10, 2015 Share Posted February 10, 2015 you mean that you need to allow currency change inside invoices? - - - Updated - - - once your client register or adding the first order the selected currency will be saved and it will never changed, well you can change it from Client Profile in Admin Area but if changed it will break/mess things 0 Quote Link to comment Share on other sites More sharing options...
clever-host Posted February 10, 2015 Author Share Posted February 10, 2015 you have here one models. This invoice is in euro and Ron (Romanian money) 0 Quote Link to comment Share on other sites More sharing options...
clever-host Posted February 10, 2015 Author Share Posted February 10, 2015 in this moment i have this: What can I do for convert one currency to another currency? In viewinvoice.tpl i have this: <tr class="title textcenter"> <td width="20%">{$LANG.invoicestransdate}</td> <td width="20%">{$LANG.invoicestransgateway}</td> <td width="24%">{$LANG.invoicestransid}</td> <td width="18%">{$LANG.invoicestransamount} EURO</td> <td width="18%">{$LANG.invoicestransamount} RON</td> </tr> {foreach from=$transactions item=transaction} <tr> <td class="textcenter">{$transaction.date}</td> <td class="textcenter">{$transaction.gateway}</td> <td class="textcenter">{$transaction.transid}</td> <td class="textcenter">{$transaction.amount}</td> <td class="textcenter">{$transaction.amount}</td> </tr> in this line: <td class="textcenter">{$transaction.amount}</td> What can I do for appear another currency? In this moment appear only Euro. I want to appear two currency. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 10, 2015 Share Posted February 10, 2015 the potential problem you're going to run into is that the WHMCS database doesn't store previous currency exchange rates - it only stores today's rate. I would guess that the easiest way to calculate an invoice amount in another currency would be to multiply it by the currency exchange rate in the database... but if you do that today, it will give you an answer in RON - but view the same invoice online tomorrow, when the exchange rate has changed, and it might give you a different result - which is not what you want. as well as making modifications to your viewinvoice and invoicepdf templates, you might also need to use something like M-Bit's Cached Invoice addon to lock the invoices from changes - that might prevent the need to constantly store the exchange rates in the database. http://forum.whmcs.com/showthread.php?95294-M-BIT-Cached-Invoices-Addon-Module-for-WHMCS I suspect it could be done, but it's going to require more advanced coding than I think you have so far. 0 Quote Link to comment Share on other sites More sharing options...
clever-host Posted February 11, 2015 Author Share Posted February 11, 2015 hello, If i buy this module: http://forum.whmcs.com/showthread.php?95294-M-BIT-Cached-Invoices-Addon-Module-for-WHMCS , what can i do for appear on the invoice two currencies? i make this: but, what can i do to convert euro to ron? <td class="textcenter">{$item.amount}</td> <td class="textcenter">{$item.amount}</td> What can write here to appear another currency? {$item.amount} thanks. 0 Quote Link to comment Share on other sites More sharing options...
clever-host Posted February 12, 2015 Author Share Posted February 12, 2015 anybody can help me? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 13, 2015 Share Posted February 13, 2015 anybody can help me? i've been working on an addon that will allow you to do display multiple currencies in your invoices as you want to - it's about 80% done and working succesfully - but when finished, using this addon will mean that M-Bit's Cached Invoice addon is no longer required. I would expect to have more details about this next week. 0 Quote Link to comment Share on other sites More sharing options...
clever-host Posted February 16, 2015 Author Share Posted February 16, 2015 hello I wait for your addons. thanks. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 20, 2015 Share Posted February 20, 2015 Hi, I just wanted to check if your website only sells your products priced in EUR and needs the invoices to convert EUR->RON, or whether you sell products priced in RON, and need the invoices to convert RON->EUR too? you can PM me your answer if you prefer. 0 Quote Link to comment Share on other sites More sharing options...
Experthost Posted February 19, 2016 Share Posted February 19, 2016 Hello @brian!: if the addon is available, would you please be kind to link me to the download source ? I'm trying for hours to find a way to get the value of $total within the viewinvoice.tpl and multiply it by exchange rate in order to get the amount in different currency to have displayed both but without luck. For pdf invoices I've find a primitive way to do it but there too it would be great to be able to automatically extract and use those data (total & exchange rate). I will dare to PM tomorrow if there will be no reply here. TY -- PS: I was trying to reply here but wasn't able to do it unless using IE, due to grayed textbox (in FF and Chrome). 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 19, 2016 Share Posted February 19, 2016 i'd forgotten all about that - though it was a year ago! I can certainly remember doing a custom solution for a client for v5, but it might be slightly easier with v6 as it uses Smarty 3 so maths calculations are simpler. i'll find my notes on this and have a play with updating it for v6 over the weekend and i'll let you know. 0 Quote Link to comment Share on other sites More sharing options...
Experthost Posted February 19, 2016 Share Posted February 19, 2016 Thanks mate for replying pretty fast! We're under V5 so less headache for you. I've tried in viewinvoice.tpl the {math equation="x * y" x=$total y=x.xxx} where x.xxx is the fixed currency exchange rate but the $total looks not to be understood by the formula so I gave up after multiple ideas. I wonder why WHMCS can't have this silly but useful feature included by default... 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 19, 2016 Share Posted February 19, 2016 if memory serves, your problem will be that $total is a string not an integer - e.g it will contain the currency prefix and suffix... $total = "$100.00 USD"... the solution was probably to get hold of the total as a number (perhaps through another Smarty variable or hooking the value from the database), or using some Smarty to strip the currency details from $total - once $total is a number (or at least Smarty sees it as one), then your equation would probably work. 0 Quote Link to comment Share on other sites More sharing options...
Experthost Posted February 19, 2016 Share Posted February 19, 2016 I did manage to make it work for invoicepdf.tpl by using the same variable $total: <tr height="30" bgcolor="#efefef" style="font-weight:bold;"> <td align="right">'.$_LANG['invoicestotal'].'</td> <td align="center">'.$total.' ('.[b]$totalron[/b].' RON)</td> </tr> but for viewinvoice.tpl it doesn't work at all. Please keep in mind that Im not a programmer and I just have a clue about how things are working All I need to have is to display main currency amount near the $total placeholder and if possible, to have it automatically calculated from tblcurrencies because ATM the value is defined within the file Didn't try yet the email template sent after invoice creation but I bet there will be another mess .. I won't mind to pay few bucks for this if you're willing to waste few minutes to search your previous work and give the lines of code needed. Please PM with needed info: amount and PP address. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 19, 2016 Share Posted February 19, 2016 All I need to have is to display main currency amount near the $total placeholder and if possible, to have it automatically calculated from tblcurrencies because ATM the value is defined within the file Didn't try yet the email template sent after invoice creation but I bet there will be another mess .. if you can find a Smarty solution that would work in the viewinvoice.tpl template, then it should work in the email template - they both use Smarty... the tricky part will be getting the exchange rate - I can't see any way to do that other than by using action hooks to pull the info from the database. I won't mind to pay few bucks for this if you're willing to waste few minutes to search your previous work and give the lines of code needed. the Smarty code in the template is straightforward - especially on v6... longer on v5! so if you were using v6 and wanted to add another row to show the Romanian Total (I know you want it on the same row, but that's just a case of placing the Smarty variable to wherever you want it!)... you could modify viewinvoice.tpl and add the new row... <td class="total-row text-right"><strong>{$LANG.invoicestotal}</strong></td> <td class="total-row text-center">{$total}</td> </tr> <tr> <td class="total-row text-right"><strong>Romanian Total</strong></td> <td class="total-row text-center">{($total|replace:'£':'' * 5.75)|string_format:"%.2f"} RON</td> </tr> 5.75 is the current exchange rate between GBP and RON, and like yours, is currently hard-coded... I assume your other currency will be EUR - so your code might be... (you might need a space before EUR if you've also added it to your currency suffix) <td class="total-row text-center">{($total|replace:'€':''|replace:'EUR':'' * 5.75)|string_format:"%.2f"} RON</td> </tr> so pretty simple in v6... but a few more steps to go through for v5... <tr class="title"> <td class="textright">{$LANG.invoicestotal}:</td> <td class="textcenter">{$total}</td> </tr> {assign var="numbertotal" value=$total|replace:'£':''} <tr class="title"> <td class="textright">Romanian Total:</td> <td class="textcenter">{math equation="x * y" x=$numbertotal y=5.75 format="%.2f"} RON</td> </tr> again, I would guess that for you, one of the above lines would need to be changed to... {assign var="numbertotal" value=$total|replace:'€':''|replace:'EUR':''} if the solution is going to need a hook to pull the exchange rate from the database, you could do the calculation in the hook and avoid the need for so much Smarty code in the template. but you run into the issue of WHMCS not archiving exchange rates - so as I said previously, look at the HTML invoice today and it will give you the 'correct' figure in EUR and RON... look at it tomorrow after the exchange rates have updated and the EUR value will be the same, but RON will have changed. the PDF invoice should be accurate for both currencies as that will have been generated and emailed to the customer at the time of ordering and so its values will be static - but if the html invoice is pulling the exchange rate from the database, it will pull today's rate - not the rate when the order is was made. it might be simpler to let the HTML invoice and email just show the price in EUR, and the PDF show both - I assume that the PDF version would be considered the official one for tax purposes? unfortunately I can't find it at the moment, but i'm pretty sure the solution I did previously for the client just pulled the latest rate - they weren't bothered about using archived rate values. 0 Quote Link to comment Share on other sites More sharing options...
Experthost Posted February 20, 2016 Share Posted February 20, 2016 Thanks a ton for spending your time giving a hand! I bet V6 could be easier to customize but we had the db messed up and template issues after upgrading to V6.1 so we had to go back to V5.*... look at it tomorrow after the exchange rates have updated and the EUR value will be the same, but RON will have changed. For several years now we no longer automatically update currency rates and Im not ready to trust it now view that the last time we've enabled the function, we had to manually adjust the prices for 100+ products. I'll follow your instructions and get back to the thread. Unfortunately I got no notifications about your response and I was tired to refresh the page every 10-15mins 0 Quote Link to comment Share on other sites More sharing options...
Experthost Posted February 20, 2016 Share Posted February 20, 2016 Well... bad news: is not working... 0 Quote Link to comment Share on other sites More sharing options...
Experthost Posted February 20, 2016 Share Posted February 20, 2016 (edited) ..but after a rainy day here it comes a sunny one I did somehow make it work! Thanks again for your patience! Really appreciate it! -- LE: the problem is that if the invoice is already set to local currency, there will be 2 different values and we'll have to use an "if" but can't get it. I've tried {if $currency eq "EUR"} bla bla {/if} without success -> blank page Edited February 20, 2016 by Experthost extra 0 Quote Link to comment Share on other sites More sharing options...
koko20212021 Posted April 18, 2021 Share Posted April 18, 2021 Hello everyone. I do apoligise for opening this old thread, but I found it the moust relevand for my issue... again I need to display on invoice Ron and EUR. I setup as default Ron and second currency Eur, but accountant asked that the ones in euro would need to have visible the Ron as well. How is this possible, i tried to explain to accountant that to me is something very strange in this flow , ex: Customer chose Euro currency -- > he will pay with our payment provider Netopia --- > then he will get an invoice with Euro & Ron ( at a certain rate ) ---> Netopia will send an invoice/confirmation in Ron ( at their rate ) How will this be even possible to manage ? aaany kind of advice would be so much welcomed!! 0 Quote Link to comment Share on other sites More sharing options...
koko20212021 Posted April 19, 2021 Share Posted April 19, 2021 On 2/10/2015 at 8:22 PM, clever-host said: in this moment i have this: What can I do for convert one currency to another currency? Hi Clever host, could you please tell me how did you manage to solve this. You just edited the invoices .tpl ? 0 Quote Link to comment Share on other sites More sharing options...
koko20212021 Posted April 20, 2021 Share Posted April 20, 2021 So my stage now is this: I have 2 currency: Default RON and EURO. On bouth i created separate Total/Value fields in bout - viewinvoice.tpl & invoicepdf.tpl , now I am wondering what should be the switch. I am thinking of making for each field: {$subtotal} {$taxrate}% {$credit} {$total} Different variable in Ron and Euro , so basicly no matter what currency client will chose between euro and ron will have them bouth 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 25, 2021 Share Posted April 25, 2021 On 18/04/2021 at 13:50, koko20212021 said: Netopia will send an invoice/confirmation in Ron ( at their rate ) oh that will be a pain if Netopia is using an exchange rate that WHMCS is unaware of. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted April 25, 2021 Share Posted April 25, 2021 The real issue is that you must: Keep track of historical currency exchange rates Include the currency rate in use at the time the invoice was issued If you don't do that amounts on invoice fluctuate. Moreover your accountant needs to manually retreive the currency rate from invoice date or transaction date. It takes time. IMO you should look for something like follows (top-right corner). Once you have currency rates, you can display all currencies you want safe from fluctuating exchange rates. 0 Quote Link to comment Share on other sites More sharing options...
koko20212021 Posted April 25, 2021 Share Posted April 25, 2021 2 hours ago, brian! said: oh that will be a pain if Netopia is using an exchange rate that WHMCS is unaware of. it seems it can be solved by accountant these differences so it will not be a real issue 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.