Hello people,
I need your help for an "addon" to SI.
I need to have the total of the invoice in words besides numbers. Something like this:
Total: $ 24
The total of the invoice is: twenty four dollars
A search gives me the following link with some php code but my coding skills are 0. The link is : http://www.builderau.com.au/program/soa/Converting-numbers-to-words-in-PHP/0,339024614,339128989,00.htm
Can someone tell me if its possible to adapte that code to SI invoice template? I just need the value in words in the invoice (the file that I'll send by e-mail or print)
Thanks in advance
well, its easy if you have the script , I've did the same thing but with arabic language..
but I'll guide you through it
1) download the numbers2words script from : http://pear.php.net/package/Numbers_Words/download
2) copy the Numbers folder to the library folder in your simple invoices directory
3) open "includes/class/export.php"
4) add in the top of the file (after <?php ) : include('./library/Numbers/Words.php');<br />5) search for : case "invoice"
then find in this line it: $customFieldLabels = getCustomFieldLabels();
add after it :
$nw = new Numbers_Words();
//change total to whatever you want, or add another one beneath it
$invoice['total_in_words'] = $nw->toWords( $invoice['total'] );
6) open "templates/invoices/default/template.tpl"
add the following wherever you want :
{$invoice.total_in_words}
-----
hope this works
thanks VeGaTrOn for sharing this!!!
cheers
justin
Hello VeGaTrOn and others,
This worked fine, and I do get the number in words. Next step is to make it working for currency (numbers to currency).
Don't look hard if currency is USD but what should I do if I want this in french?
The lang.fr file in the package you link dont have the toCurrencyWords function :/ Can you point me the place where I can get that file or some other solution?
Isn't a way to do that "directly" with some php function? (google and find PHP money_format() but don't know how to use it on SI)
Thanks in advance
hi ReallyNA
if you want to add the EURO sign after the number instead of the dollar sign, you can change the dollar sign in "Settings->Invoice Preferences->Currency sign"
or if you want to change the number format ( 1000 -> 1,000) you should set the local in the config.ini to french locale
if that didnt help , open " includes\class\siLocal.php" and change the "number" function
thanks VeGaTrOn for posting this info
cheers
justin
Hey VeGaTrOn,
I need your (or someone else) help again,
I used the code and I can convert for example 148,41 to "one hundred forty-eight" This means that he is not working with the fraction part.
How can I make this to work to be able to get: one hundred forty-eight euros and forty one cents. Looks like I need to use toCurrency.. the question is how :s
And btw, this is easy to make in french after?
Thanks in advance
HI VeGaTrOn
I downloaded the script http://pear.php.net/package/Numbers_Words/download and read the readme file but can't make it work to fraction besides there is some info there. I don't know too much of coding so I guess I'm missing something.
Are you sure it's a fraction and not a comma? I think you are giving a formatted number that already contains commas to the number to words library and maybe it is not able to understand the comma. Try giving it just a stright decimal number without commas.
If my assumption is incorrect (it is a comma not a decimal), just ignore my comments because I do not have any experience with this library.
Thanks
Harvinder Singh
Hi all
Yes, I was asking about converting a number with a comma to words.
Example: 24 296,28
Converting it to numbers i can have this: twenty-four thousand two hundred ninety-six
Converting it to currency I can have now: twenty-four thousand two hundred ninety-six dollars twenty-eight cents
This is what I need but in french. The script don't have the currency function in french so I need to make a new one based on the en_US to make it work.
Let' s try it ;)
thanks reallyNA and harvinder
reallyNA
- let us kow how you go with your french numbers to words script
cheers
justin
Well, I manage to get this done and presented on the invoice.
As soon I "clean up" my code I'll write here all the steps if someone else need this.
I now need to have this working on the payment print page index.php?module=payments&view=print
Can someone point me the right direction so I can change the code as I did for invoices? I now need to convert the "amount" instead of total, but can't find any amount field on export.php and in payment.php the code is a little different.
VeGaTrOn help me here... beer on me next time :P
I had a problem with my computer and have been away from the forum for a few days. I'll post here the code.
Does someone have some idea of what the code to make that working for payments? Need to convert the amount payed on the payments to words, but can't guess what is the "variable"..guess ac_amount but can't find it anywhere.
Thanks in advance
re
Does someone have some idea of what the code to make that working for payments
Hey Justin,
That's my guess also, but where should I "create" the new variable?
For total amount, I have change case invoice on includes/class/export.php file. I have done something similar with this... http://simpleinvoices.org/forum/discussion/1236/numbers-to-words/#Item_3
But there is no ac_amount on that file. Maybe on includes/class/payment.php ?
Thank you
NA
Hi, I am new in simple invoices and the php code.
Someone can post your files to change numbers to words?
I´ve try to do this but its dificult for me.
thanks
someone can tell me where must write this:
//change total to whatever you want, or add another one beneath it
$invoice['total_in_words'] = $nw->toWords( $invoice['total'] );
thanks for your help
or someone can post the code with the changes (export.php)
Thanks again
Hi
Thanks for your answer ReallyNA, I appreciate your help.
Your tutorial will be assom.
best regards
Hello to all,
Here we go: How to convert numbers to words (or currency) on SI
////
Example: 24 296,28
Converting it to numbers i can have this: twenty-four thousand two hundred ninety-six
Converting it to currency I can have now: twenty-four thousand two hundred ninety-six dollars twenty-eight cents
///
HOW TO:
1- download this script http://download.pear.php.net/package/Numbers_Words-0.16.2.tgz
2- extract the downloaded file and copy Numbers folder to library/ folder in SI directory
3- open "includes/class/export.php"
4- at line 2 add this: include('./library/Numbers/Words.php');
5- on the same file search for line 216 - you'll find: $customFieldLabels = getCustomFieldLabels();
6- right below this line paste this:
$nw = new Numbers_Words();
$invoice['total_in_words'] = $nw->toWords( $invoice['total']);
$invoice['total_in_words_currency'] = $nw->toCurrency( $invoice['total']);
7- save "includes/class/export.php" file :p
8- open "templates/invoices/default/template.tpl" (or the template.tpl of the template you're using) and wherever you want to appear the "words" paste this:
{$invoice.total_in_words} -for total value of the invoice in words
or/and
{$invoice.total_in_words_currency} - for total value of the invoice in currency
9- save "templates/invoices/default/template.tpl" file
10 - clear your cache folder ( /tmp/cache/ )
11 - open a new invoice in the print view
That should work ;)
///
BTW, let me send my regards again to VeGaTrOn for helping me.
Hello
Thanks fot the tutorial,
I try with the up instructions but nothing happen.
I have a couple questions about.
When I download the tgz file, I get this folder Numbers_Words-0.16.2, is this folder should copy as Numers on the class library?
And, Numbers_Words file into folder with the same name no have extension. Must I rename this file (Numbers_Words-0.16.2) like Words.php?
Thanks for your answer.
Best regards
Hello aristoteles
After download have you manage to extract the .tgz file?
You need to extract the file until you have:
/Numbers
/tests
changelog
readme
You need the Numbers folder where you will have a /Words folder and Words.php
To become this simpler download the file here http://rapidshare.com/files/408658531/Numbers.zip
Download and follow the guide again.
thanks reallyna for the great tutorial!!
have added it to our faq list
cheers
justin
Thanks for the tutorial, the number to words works perfect.
Best regards
Actually I have an add to upload (or attach ) a file to each invoice (any kind of file). I´ll post the files to do this this week.
thanks everybody.
thanks aristoteles
look forward to seeing your upload work
cheers
justin
hello again
I dont have upload my files because I have problems when a try to export a PDF invoice.
I modify everiting to upload just one file per invoice, but for some reason the PDF module is not working. I am trying to solve this.
Any way, this week post my files to upload files per ionvoice.
Bests regards
@ReallyNA
includes/class/export.php file is not the same you refer in your really good tutorial.
There are 2 $customFieldLabels = getCustomFieldLabels(); and no one at line 216
I'm with a little problem as I get "Unable to include the Numbers/Words/lang.pt_PT.php file Unable to include the Numbers/Words/lang.pt_PT.php file" (although the customization done in Words.php).
Thank you.
Jose
_______
[UPDATED]
All ok now!
Hello
Where can I uplod my files (to upload one file per invoice)
Thanks
re upload
- you can upload files to our wiki
- refer: http://simpleinvoices.org/wiki/file_bin
or just email me and i'll upload for you
cheers
justin
I just followed ALL instructions, I have a doubt about PEAR already installed with current PHP Simpleinvoices version, but at the end I can't run this Number to words class (I already installed in a previous Simpleinvoices web version and it's running). This is what I've done:
1. export.php updated according with instructions
2. template.tpl has this instruction print($nw->toCurrency($invoice[total],'es','MXN'));
Executing Invoice preview and next error shows:
Fatal error: Class 'PEAR' not found in C:\proyectos\simpleInvoices\Simple Invoices for Windows\si\library\Numbers\Words.php on line 231
In Words.php I added two echoes to know where is the error, and messages are:
ClassName = 'Numbers_Words_es'
Unable to find toCurrencyWords method
Please help, I have to deliver a local version to one customer in two days.
Thanks
@walticogt
If something has to be changed in this text http://code.google.com/p/simpleinvoices/wiki/HowTo#..._convert_numbers_to_words can you do this too? Then our documentation is more current.