Print Format question

237 views
Skip to first unread message

Hernan Gonzalez

unread,
Jan 9, 2014, 12:57:44 PM1/9/14
to erpnext-u...@googlegroups.com
I want to limit the number of decimal places for the qty field (float), i can limit the decimal Float Precision in global defaults, but i want to keep the precision set to 4 decimals and show only two in the print format as it is done in currency fields.

My custom print format is attached.

And this is the output:



Ageka Pesos.txt

Akhilesh Darjee

unread,
Jan 10, 2014, 12:41:47 AM1/10/14
to erpnext-u...@googlegroups.com
Hi Hernan,

You can use flt(amount, 2) to set the precision to 2 decimal places.


--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

Regards,
Akhilesh Darjee

Hernan Gonzalez

unread,
Jan 11, 2014, 5:12:41 PM1/11/14
to erpnext-u...@googlegroups.com
How do i put the flt(amount, 2)  inside the "print_item_table" function, only for the "qty" field.

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_name', 'description', 'qty', 'stock_uom',
					'basic_rate', 'amount'
				],
				[// Here specify the labels of column headings
					'Sr', 'Nombre', 'Descripción', 'Cant',
					'Unidad', 'Unitario', 'Monto'
				],
				[// Here specify the column widths
					'3%', '20%', '37%', '5%',
					'5%', '15%', '15%'
				],
				null,
				null,
				{

On Friday, January 10, 2014 2:41:47 AM UTC-3, Akhi wrote:
Hi Hernan,

You can use flt(amount, 2) to set the precision to 2 decimal places.
On Thu, Jan 9, 2014 at 11:27 PM, Hernan Gonzalez <nuco....@gmail.com> wrote:
I want to limit the number of decimal places for the qty field (float), i can limit the decimal Float Precision in global defaults, but i want to keep the precision set to 4 decimals and show only two in the print format as it is done in currency fields.

My custom print format is attached.

And this is the output:



--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--

Regards,
Akhilesh Darjee

Akhilesh Darjee

unread,
Jan 12, 2014, 4:22:39 AM1/12/14
to erpnext-u...@googlegroups.com

Hi Hernan,

You can use for function for all float values,  even for any.
Flt(qty, 2)

To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

Hernan Gonzalez

unread,
Jan 12, 2014, 10:29:29 AM1/12/14
to erpnext-u...@googlegroups.com
Well, this doesnt seem to work:

si_std = {
print_item_table: function() {
var table = print_table(
'Sales Invoice',
'entries',
'Sales Invoice Item',
[// Here specify the table columns to be displayed
'Sr', 'item_name', 'description', 'Flt(qty, 2)', 'stock_uom',
'basic_rate', 'amount'
],
[// Here specify the labels of column headings
'Sr', 'Nombre', 'Descripción', 'Cant',
'Unidad', 'Unitario', 'Monto'
],
[// Here specify the column widths
'3%', '20%', '37%', '5%',
'5%', '15%', '15%'
);
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--

Regards,
Akhilesh Darjee

Akhilesh Darjee

unread,
Jan 13, 2014, 12:39:41 AM1/13/14
to erpnext-u...@googlegroups.com
Hi Hernan,

Don't use print_table() function, create your own custom function which will show item details table.
In that function when printing qty, use flt(qty, 2)


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Akhilesh Darjee

Anand Doshi

unread,
Jan 13, 2014, 12:40:20 AM1/13/14
to ERPNext User's Forum
Hi Hernan,

Just like how the description modifier is passed to the print_table function, in the same dictionary, you can also pass a qty modifier and return flt(data_row.qty, 2)

Thanks,
Anand.


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

Hernan Gonzalez

unread,
Jan 16, 2014, 1:01:15 PM1/16/14
to erpnext-u...@googlegroups.com
Well, i'm getting closer. this code returns a value with two decimals, but the value is always 0.00. 

Any sugestions?

<script>
si_std = {
print_item_table: function() {
var table = print_table(
'Sales Invoice',
'entries',
'Sales Invoice Item',
[// Here specify the table columns to be displayed
'Sr', 'item_name', 'description', 'qty',
'basic_rate', 'amount'
],
[// Here specify the labels of column headings
'Sr', 'Nombre', 'Descripción', 'Cant',
'Unitario', 'Monto'
],
[// Here specify the column widths
'3%', '22%', '40%', '5%',
'15%', '15%'
],
null,
null,
  {
  // return Quantity
'qty': function(data_row) {
return format_number(data_row.qty, 2);
}
  }

);

// This code takes care of page breaks
if(table.appendChild) {
out = table.innerHTML;
} else {
out = '';
for(var i=0; i < (table.length-1); i++) {
out += table[i].innerHTML + 
'<div style = "page-break-after: always;" \
class = "page_break"></div>\
<div class="page-settings"></div>';
}
out += table[table.length-1].innerHTML;
}
return out;
},


print_other_charges: function(parent) {
var oc = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');
var rows = '<table width=100%>\n';
for(var i=0; i<oc.length; i++) {
if(!oc[i].included_in_print_rate) {
rows +=
'<tr>\n' +
'\t<td>' + oc[i].description + '</td>\n' +
'\t<td>AR$</td>\n' +
'\t<td width=38%, align="right">' + format_number(oc[i].tax_amount,null,2) + '</td>\n' +
'</tr>\n';
}
}
return rows + '</table>\n';
}
};
</script>

Akhilesh Darjee

unread,
Jan 17, 2014, 12:36:01 AM1/17/14
to erpnext-u...@googlegroups.com
Hi Hernan,
You should use return flt(data_row.qty, 2);
 
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Akhilesh Darjee

Hernan Gonzalez

unread,
Jan 17, 2014, 6:22:38 AM1/17/14
to erpnext-u...@googlegroups.com
Well i tryed thar before and it returns a 0, (without decimals)
Regards,
Akhilesh Darjee

Akhilesh Darjee

unread,
Jan 17, 2014, 6:26:11 AM1/17/14
to erpnext-u...@googlegroups.com
Hi Hernan,

Use format_number(data_row.qty, null, 2)


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
Message has been deleted

Hernan Gonzalez

unread,
Jan 17, 2014, 2:41:31 PM1/17/14
to erpnext-u...@googlegroups.com
Welli added the  "null," but it gives the same output.

Hi Hernan,

--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-forum+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Akhilesh Darjee

unread,
Jan 23, 2014, 4:37:59 AM1/23/14
to erpnext-u...@googlegroups.com
Hi Hernan,

Can you please share the code via pastebin.com


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Hernan Gonzalez

unread,
Jan 24, 2014, 3:39:59 PM1/24/14
to erpnext-u...@googlegroups.com
http://pastebin.com/6Z7bCa7z

Here is the complete code.

Akhilesh Darjee

unread,
Jan 27, 2014, 4:25:39 AM1/27/14
to erpnext-u...@googlegroups.com
Hi Hernan,

Please use this code - http://pastebin.com/K0g6ZWhh.
This might solve your problem.
Also change the table heading lables according to your preferred language.


To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Hernan Gonzalez

unread,
Jan 27, 2014, 8:54:13 AM1/27/14
to erpnext-u...@googlegroups.com
It works great!!, thanks a lot for your effort.

Rushabh Mehta

unread,
Jan 29, 2014, 9:01:17 AM1/29/14
to erpnext-u...@googlegroups.com
Please consider making a contribution too :)

Addy

unread,
Mar 31, 2014, 11:21:05 PM3/31/14
to erpnext-u...@googlegroups.com
Hi,

I would like to ask if it is OK for users to delete certain (standard) print formats from the system.
I see that we can assign roles the ability to delete the print formats but I just wanted to confirm that whether deleting the Standard print formats in various documents would have any adverse effect on the system. Please let me know the same since we are planning to delete some of the standard print formats which we are not using.

Umair Sayyed

unread,
Apr 1, 2014, 2:24:35 AM4/1/14
to ERPNext User's Forum
Hello Aditya,

Deleting Standard Print Formats (Classic, Modern, Spartan) should not be a problem. If needed, you can add it again as non-standard print format. HTML script for these Print Formats will be available on Github.



--
You received this message because you are subscribed to the Google Groups "ERPNext User's Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-user-fo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/erpnext-user-forum/3194a99e-ad41-4f74-8357-1fd77038a3f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks and Regards,
Umair Sayyed
www.erpnext.com

Paul Dowd

unread,
Apr 17, 2014, 2:14:19 AM4/17/14
to erpnext-u...@googlegroups.com
Hi Akhilesh

I've tried to use your print format because I have a very similar problem where I need to show only integers on the print formats. However when I copied your print format in nothing shows up in the item table. The rest shows fine, just the item table is missing the items. 

Is there a different or simpler way of doing this change without changing the entire structure of how the item table is built?

thanks

Paul
Reply all
Reply to author
Forward
0 new messages