Jump to content
Sign in to follow this  
clever-host

Invoice Template

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

in this moment i have this:

whmcs3.png

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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:

 

whmcs3.png

 

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.

Share this post


Link to post
Share on other sites
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. :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

i'd forgotten all about that - though it was a year ago! :twisted:

 

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.

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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! :roll:

 

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!)...

 

VKkWrOK.png

 

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... :roll:

 

    <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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

..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 by Experthost
extra

Share this post


Link to post
Share on other sites

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!! 

 

Share this post


Link to post
Share on other sites
On 2/10/2015 at 8:22 PM, clever-host said:

in this moment i have this:

whmcs3.png

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 ? 

Share this post


Link to post
Share on other sites

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 

Whmcs-Invoices.png

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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).

whmcs-billing-extension-historic-currency-exchange-rate.png.488fd6ab51bd421b6f8b923625bb63d1.png

Once you have currency rates, you can display all currencies you want safe from fluctuating exchange rates.

whmcs-show-multiple-currencies-on-invoice.png.fdd01dfddb49cdb06c1aef3326d618ab.png

 

 

Share this post


Link to post
Share on other sites
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 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated