How can I add "Tax amount", "Tax rate" on Sales Order Item List?

I need show “Tax amount”, “Tax rate” on Sales Order Item List in Sales Order.

tax_amount = amount - net_amount
tax_rate = tax_amount / net_amount

Thanks!

@nnylyj you cannot actually do this for an item if your using format builder, you can do it though using custom print format:

https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/print-format.html

uhmmm… okay, I found a dirty way to do this.

frappe.ui.form.on("Sales Order", "refresh", function(frm) {
	frappe.ui.form.GridRow = frappe.ui.form.GridRow.extend(
	{
	    make_static_display:function() {
	                var me = this;
	                this.row.empty();
	                $('<div class="row-index">' + (this.doc ? this.doc.idx : "&nbsp;")+ '</div>')
	                        .appendTo(this.row);

	                if(this.grid.template) {
	                        $('<div class="row-data">').appendTo(this.row)
	                                .html(frappe.render(this.grid.template, {
	                                        doc: this.doc ? frappe.get_format_helper(this.doc) : null,
	                                        frm: this.frm,
	                                        row: this
	                                }));

	if(this.doc&&this.doc.doctype==='Sales Order Item'){
	    this.row.find('.row-data div.row div.row')
              .last()
	      .after('<div class="row">    <div class="col-xs-4 text-ellipsis">     <strong title="tax_rate">Tax rate:</strong>    </div>    <div class="col-xs-8">' + ((this.doc.amount - this.doc.net_rate) / this.doc.net_rate).toFixed(2) + '</div>   </div>')
	      .after('<div class="row">    <div class="col-xs-4 text-ellipsis">     <strong title="Tax amount">Tax amount:</strong>    </div>    <div class="col-xs-8">' + (this.doc.amount - this.doc.net_rate)+ '</div>   </div>');
	  }
	                } else {
	                        this.add_visible_columns();
	                }

	                $(this.frm.wrapper).trigger("grid-row-render", [this]);
	        }
	});
});

i hope this is a custom script not a source code modification…

yeah, it’s a custom client script

1 Like