Add fields to Sales Invoice Print Format

396 views
Skip to first unread message

bd

unread,
Oct 25, 2012, 4:05:24 AM10/25/12
to erpnext-dev...@googlegroups.com
Hello,

I am working at a new Sales Invoice print template.
So, I created a new Prin Format from Setup, and copied the existing Standard one.

But how to:
- add a column with VAT for each item ?
- add my own company details (address etc) ?

I added tax_amount, but perhaps the calculation is not included here:

                [// Here specify the table columns to be displayed
                    'SR', 'item_name', 'description', 'qty', 'stock_uom',
                    'export_rate', 'export_amount','tax_amount'
                ],
                [// Here specify the labels of column headings
                    'Sr', 'Item Name', 'Description', 'Qty',
                    'UoM', 'Basic Rate', 'Amount','VAT'
                ],
                [// Here specify the column widths
                    '3%', '20%', '37%', '5%',
                    '5%', '15%', '9%','6%'

Regards

Rushabh Mehta

unread,
Oct 25, 2012, 12:34:32 PM10/25/12
to erpnext-dev...@googlegroups.com
Hi,

You are right, you will have to calculate the tax for each item.

To do that, you will have to write a function to return the tax amount.

Here is an example:


See line #150 for the function to return the "tax_amount" column. This assumes you have a field in the main form called vat_rate. You should get the general idea.

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To unsubscribe from this group, send email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/5AqrEl0ZJtsJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

bd

unread,
Oct 31, 2012, 3:53:04 AM10/31/12
to erpnext-dev...@googlegroups.com
Hi,

Thank you for example, I believe I got the idea.
Still, did not manage to show an additional column (even without using any calculation).
Perhaps I am still missing something. This is set also as SalesInvVatCol report on my erpnext.com account.
Do you have any suggestion?

.......
 
<!-- Javascript -->
<script>
    si_std = {
        print_item_table: function() {
            var table = print_table(
                'Sales Invoice',
                doc.name,
                'entries',
                'Sales Invoice Item',

                [// Here specify the table columns to be displayed
                    'SR', 'item_code', 'description', 'qty', 'stock_uom',
                    'export_rate', 'export_amount', 'vatvat'

                ],
                [// Here specify the labels of column headings
                    'Sr', 'Item Code', 'Description', 'Qty',

                    'UoM', 'Basic Rate', 'Amount','VAT'
                ],
                [// Here specify the column widths
                    '3%', '10%', '15%', '32%', '5%',
                    '10%', '15%','10%'
                ],
                null,
                null,
                {       
                    'description' : function(data_row) {
                        if(data_row.adj_rate) {
                            var to_append = '<div style="padding-left: 15px;"><i>Discount: ' +
                                data_row.adj_rate + '% on ' + doc.currency + ' ' +
                                fmt_money(data_row.ref_rate) + '</i></div>';
                            if(data_row.description.indexOf(to_append)==-1) {
                                return data_row.description + to_append;
                            } else { return data_row.description; }
                        } else {
                            return data_row.description;
                        }
                    },
                    // return vavat column just a value for test
                    'vatvat' : function(data_row) {
                        return data_row.amount;
                    }

                }
                );

Rushabh Mehta

unread,
Nov 1, 2012, 1:30:42 AM11/1/12
to erpnext-dev...@googlegroups.com
Hi,

1. Sorry did not mention but you will also have to add a custom field in the Sales Invoice Detail table named "vatvat" (or equivalent)
2. There must be some value in the field (the print_table function will automatically remove any empty columns).

best,
Rushabh


W: https://erpnext.com
T: @rushabh_mehta

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To unsubscribe from this group, send email to erpnext-developer...@googlegroups.com.

stkitmanager

unread,
Nov 1, 2012, 1:51:08 AM11/1/12
to erpnext-dev...@googlegroups.com
Daer

Please find full script of sales invoice, may be its work for you.

Thanks
MHI
Sales Invoice Final.txt

bd

unread,
Nov 2, 2012, 4:06:03 AM11/2/12
to erpnext-dev...@googlegroups.com
It works with added field, thank you Rushabh!

Is there any plan to add VAT as a column in Sales Invoice Item table?
This is a common practice in other ERPs.
Right now there is no direct link between VAT for each item and sales invoice lines. Now It can be only calculated, but if changed manually on total, then is no link.

Regards

Rushabh Mehta

unread,
Nov 2, 2012, 5:23:21 AM11/2/12
to erpnext-dev...@googlegroups.com
You are welcome.

We are in the process of rewriting this code. If you have some experience please feel free to dive in :)

This is the tax calculation code on the server side:


We are hoping to rewrite the client code for this soon.

If you are looking for a quick fix, I recommend you write your own function, the current client-side code is extremely messy.

best,
Rushabh






Regards

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To unsubscribe from this group, send email to erpnext-developer...@googlegroups.com.

bd

unread,
Feb 4, 2013, 3:13:38 PM2/4/13
to erpnext-dev...@googlegroups.com
Hello,

I understood you were/ are rewriting parts of code.

Are the taxes (VAT or any other, as they are very generic) saved after invoice validation separately for each item?
The tax for each item may be calculated based on item master, but if calculation changes in time, it is not possible.

Regards
B



On Friday, November 2, 2012 11:23:22 AM UTC+2, rushabh wrote:
You are welcome.

We are in the process of rewriting this code. If you have some experience please feel free to dive in :)

This is the tax calculation code on the server side:


We are hoping to rewrite the client code for this soon.

If you are looking for a quick fix, I recommend you write your own function, the current client-side code is extremely messy.

best,
Rushabh


On Fri, Nov 2, 2012 at 1:36 PM, bd <> wrote:
It works with added field, thank you Rushabh!

Is there any plan to add VAT as a column in Sales Invoice Item table?
This is a common practice in other ERPs.
Right now there is no direct link between VAT for each item and sales invoice lines. Now It can be only calculated, but if changed manually on total, then is no link.


Regards

--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To unsubscribe from this group, send email to erpnext-developer-forum+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages