Jump to content

Invoice Template


clever-host

Recommended Posts

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

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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. :)

Link to comment
Share on other sites

  • 11 months later...

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

Link to comment
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.

Link to comment
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...

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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 :)

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

  • 5 years later...

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

 

Link to comment
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

Link to comment
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

 

 

Link to comment
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.

  • 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