Jump to content

Rounding Invoice Total


Swehoster

Recommended Posts

Hi,
We need to have a rounding feature for making the invoices better.

I know there is a feature if I choose the currency format 1,234 in WHMCS but that doesn't work in Sweden or many other countries.

We need to use the format 123,45.

We writ one thousand as 1000 NOT 1,000.

Our clients call us in 5 seconds and wonder why they should pay only 1 (one) sek instead of 1000 (one thousand).

Does anyone know if this can be accomplished by a hook or something?

We only use 1 currency.

I've followed this request, https://requests.whmcs.com/topic/rounding-invoice-total-due-amount-to-the-nearest-decimal
But WHMCS say that my request isn't on the agenda.

Edited by Swehoster
Link to comment
Share on other sites

is this purely a visual change on the invoice, or you really want to change the total amounts on those invoices?? ... are you bothered what's shown in the cart ??

the first could be a ClientAreaPageViewInvoice hook (for the html invoice) and editing invoicepdf.tpl for the PDF invoice;

the second could be an InvoiceCreationPreEmail that adjusts the invoices total(s) in the db before the email/invoice is sent to the client - though as with Dennis' suggestion, the values would still be set to 2dp in the db.

I can think of another way, but that's a nuclear option and a coding solution would be better than that I think.

6 hours ago, Swehoster said:

I know there is a feature if I choose the currency format 1,234 in WHMCS but that doesn't work in Sweden or many other countries.

would it be an option for you to use the above format, but remove the comma (,) from the output ?

Link to comment
Share on other sites

On 9/20/2019 at 3:38 PM, Swehoster said:


We would like the final total to be rounded, 99,49 = 99 and 99,50 = 100.
 

Thinking about VAT laws in many countries, this is often forbidden.

And even if it's allowed in your country, it's a nightmare for accounting.

Last: if price is 99,51 and you round it to 100, users will complain (and they will be right to do it)

 

Link to comment
Share on other sites

Thank you.
Regarding the rounding that's fine. Every store in Sweden work like this. There is online or physical.

I just think it's strange since the feature is in place for a certain currency format but not the rest.
It should be a checkbox to enable it on every format instead.
If I use it in cart I'll get a faulty value on invoice? And what happens with all current clients? 

Link to comment
Share on other sites

On 9/20/2019 at 5:59 PM, brian! said:

is this purely a visual change on the invoice, or you really want to change the total amounts on those invoices?? ... are you bothered what's shown in the cart ??

the first could be a ClientAreaPageViewInvoice hook (for the html invoice) and editing invoicepdf.tpl for the PDF invoice;

the second could be an InvoiceCreationPreEmail that adjusts the invoices total(s) in the db before the email/invoice is sent to the client - though as with Dennis' suggestion, the values would still be set to 2dp in the db.

I can think of another way, but that's a nuclear option and a coding solution would be better than that I think.

would it be an option for you to use the above format, but remove the comma (,) from the output ?

This is  should be implemented for the invoice total.
We transfer the invoicing to an external system to generate the printed invoices and in some case other as well. 
This is not only for the client view. It could be a solution to remove the comma, I'll look into it.

Link to comment
Share on other sites

1 hour ago, Swehoster said:

Regarding the rounding that's fine. Every store in Sweden work like this. There is online or physical.

I've just seen that 1 SEK = 0,01 €, so rounding is making sense... 

I don't know when Sweden will enforce Euro usage, but take note that when this will happen, you'll have to throw away your rounding work... no one will ever accept you to round a sum to one full Euro! 😄
 

About the comma: you can modify viewinvoice.tpl and invoicepdf.tpl using Smarty string_format (which has the same syntax of php sprintf) :

  https://www.smarty.net/docsv2/en/language.modifier.string.format.tpl

 

Link to comment
Share on other sites

11 minutes ago, Remitur said:

I've just seen that 1 SEK = 0,01 €, so rounding is making sense... 

I don't know when Sweden will enforce Euro usage, but take note that when this will happen, you'll have to throw away your rounding work... no one will ever accept you to round a sum to one full Euro! 😄
 

About the comma: you can modify viewinvoice.tpl and invoicepdf.tpl using Smarty string_format (which has the same syntax of php sprintf) :

  https://www.smarty.net/docsv2/en/language.modifier.string.format.tpl

 

I don't think the enforced Euro in Sweden will be for a long time.
I can modify the comma but that still sends the data for invoices and make the invoice display the comma.

Link to comment
Share on other sites

3 hours ago, Swehoster said:

I just think it's strange since the feature is in place for a certain currency format but not the rest.

I think there has only been those 4 formats for as long as i've been using WHMCS - with no real simple way to add more.

https://requests.whmcs.com/topic/apostrophe-thousand-separator-currency-format

Quote

The current lists of currency formats lacks the format "12 345,67" used in Sweden. Would it be possible to add this to the list of default formats, or add the ability to specify a custom currency format.

i've always believed that feature request was marked as "Completed" too soon - I don't think it has been completed and price formatter is not a good way to create a new currency format... i'm not even sure if format can be used in that way (there are no working examples that i'm aware of how to use the format option to create a new currency format).

5 hours ago, Swehoster said:

It should be a checkbox to enable it on every format instead.

there is a feature request for rounding up invoices - it's 6 years old and has 11 votes... it's not going to happen this year, that is for sure.

https://requests.whmcs.com/topic/round-up-invoices-bills

or another one, marked as already possible, that is 3 years old with 5 votes...

https://requests.whmcs.com/topic/rounding-invoice-total-due-amount-to-the-nearest-decimal

5 hours ago, Swehoster said:

If I use it in cart I'll get a faulty value on invoice? And what happens with all current clients? 

if you don't alter it with a hook, then WHMCS will store it with 2 decimal places unrounded.

4 hours ago, Swehoster said:

I can modify the comma but that still sends the data for invoices and make the invoice display the comma.

then you'd have to alter the invoices templates - either in the Smarty/PHP code themselves, or with hooks when it's passed to the invoices.

1 hour ago, Swehoster said:

I noticed that the rounding only happens as a "view", in the DB the actual price still exist, not rounded.

hence I asked if the change was only for show, or whether you wanted to change the amounts on the invoices (and by implication, in the db).

the issue is that there is no neat way to create new currency formats - the four current ones are hardcoded within the encrypted files... submitting a feature request would be pointless and I can't think of an addon module that adds additional formats.

btw - the nuclear option I mentioned previously would involve changing the number of decimal places in the database table settings - it's been done previously to increase either the length of numbers or the number of decimal places... i've never tried it with 0 decimal places, but it should round automatically.

however, I really would regard that as a nuclear option and it would require thorough testing on a development install before being applied to a live production install... and it's not ideal if at some future point, you need to add EUR with 2 decimal places.

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