The SimpleInvoices forum has moved to Google Plus - this forum is now read-only
Numbers to words
  • ReallyNAReallyNA May 2010

    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

  • ReallyNAReallyNA May 2010

    Anyone can help me?

    This is essencial so I can use SI

    Thanks in advance

  • VeGaTrOnVeGaTrOn May 2010

    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

  • jmruasjmruas May 2010

    I liked your help VeGaTrOn.

    Thank you for me too.

  • justinjustin May 2010

    thanks VeGaTrOn for sharing this!!!

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA May 2010

    Hey VeGaTrOn

    Thank you very much for your help.

    I'll test this later as soon as I get home and I'll post here the result ;)

    Thank you ;)

  • VeGaTrOnVeGaTrOn May 2010

    you're all welcome

  • ReallyNAReallyNA June 2010

    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

  • VeGaTrOnVeGaTrOn June 2010

    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

  • justinjustin June 2010

    thanks VeGaTrOn for posting this info

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA June 2010

    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

  • VeGaTrOnVeGaTrOn June 2010

    hi
    well this depends on the php library that used.
    I'm sure there is a configuration to make it convert the fraction to words.
    try searching the help files of the php numbers to words library.

  • ReallyNAReallyNA June 2010

    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

  • ReallyNAReallyNA June 2010

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

  • justinjustin June 2010

    thanks reallyNA and harvinder

    reallyNA
    - let us kow how you go with your french numbers to words script

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA June 2010

    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

  • ReallyNAReallyNA June 2010

    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

  • justinjustin June 2010

    re

    Does someone have some idea of what the code to make that working for payments


    should just be ac_amount

    refer the template: http://code.google.com/p/simpleinvoices/source/browse/trunk/templates/default/payments/print.tpl#159

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA June 2010

    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

  • ReallyNAReallyNA July 2010

    Hello people,

    I have been away from the computer so I haven't yet post here the complete tutorial on how to do this.

    I don't have the code with me at the moment so I'll post here the detailed info tomorrow. Promise.

  • Hi

    Thanks for your answer ReallyNA, I appreciate your help.

    Your tutorial will be assom.

    best regards

  • ReallyNAReallyNA July 2010

    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

  • ReallyNAReallyNA July 2010

    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.

  • justinjustin July 2010

    thanks reallyna for the great tutorial!!

    have added it to our faq list

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • ReallyNAReallyNA July 2010

    Hello Justin,

    I'm glad I can help

    Cheers

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

  • justinjustin July 2010

    thanks aristoteles

    look forward to seeing your upload work

    cheers

    justin

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • aristotelesaristoteles August 2010

    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

  • jmruasjmruas August 2010

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

  • dovydzdovydz August 2010

    Hi,
    wonderfull product!!!!

    well i did ok with the invoice template, but can not get the words in payments print....

    maybe something with the "include('./library/Numbers/Words.php');"

  • dovydzdovydz August 2010

    or this...

    $nw = new Numbers_Words();
    $invoice['total_in_words'] = $nw->toWords( $invoice['total']);
    $invoice['total_in_words_currency'] = $nw->toCurrency( $invoice['total']);

  • aristotelesaristoteles August 2010

    Hello

    Where can I uplod my files (to upload one file per invoice)

    Thanks

  • justinjustin August 2010

    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

    SmarterInvoices.com :: Simple Invoices hosting | Kelly.org.au :: Simple Invoices custom development | justin.kelly.org.au
  • lvargas65lvargas65 December 2010

    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

  • lvargas65lvargas65 December 2010

    Solved: I installed go-pear.php and I included PEAR.php and PEAR5.php in Numbers directory

  • walticogtwalticogt March 2012

    Correction to VeGaTrOn May 2010 Permalink

    1) OK
    2) OK
    3) OK
    4) replaze this:

    include('../../library/Numbers/Words.php');

    5) Continue ...

  • modirmodir March 2012

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

Categories