Hello,

I am working on some sort of a invoice system.

I have a field for the "sub-total" amount, one of "tax 1", "tax 2" and finally, "total including taxes"

Subtotal is : invoice_total_amount
Tax 1 is : invoice_tps
Tax 2 is : invoice_tvq
Total with taxes is : invoice_tax_total_amount

So basically, what I need, is whatever I enter in the "invoice_total_amount" editable region, must be used to calculate both taxes, and then both taxes must be added to the subtotal amount, to give the "Total with taxes" number which must be saved in the "invoice_tax_total_amount" field.

I want all the operation to happen when you click "SAVE", on the admin page.

I tried this (on the "content_form_invoice-php.html" file) :

Code: Select all
<cms:set my_subtotal="<cms:show invoice_total_amount/>" scope="global"/>
<cms:set my_tax1='0' scope="global"/>
<cms:set my_tax2='0' scope="global"/>
<cms:set my_both_taxes='0' scope="global"/>
<cms:set my_big_total='0' scope="global"/>[

<cms:incr my_big_total "<cms:add my_subtotal my_2taxes />" />
<cms:incr my_2taxes "<cms:add my_tps my_tvq />" />


Then under the "form" section :

Code: Select all
 <cms:if k_success >

            <cms:db_persist_form
                _invalidate_cache='1'
                _token=k_cur_token
                invoice_tvq = "<cms:number_format thousands_separator='' my_tvq />"
                invoice_tps = "<cms:number_format thousands_separator='' my_tps />"
                invoice_tax_total_amount = "<cms:number_format thousands_separator='' my_big_total />"
            />

...


All it does is updating the "total with taxes" field with the subtotal input, but I have to save the page twice when the subtotal is changed for something else.

I'm not sure how to handle this.

Any ideas how to do this?
Thanks a lot!