hello, in erpnext i have in system settings → date and number format selected this number format #,###.## with precision 3 so basically numbers would be 1,234.123
in a report that i created how if i want the number to be taken from the database but shown as 1,234.12
i don’t wannt to round the number i just want to show 2 decimals.
i tried such thing , no error but didn’t work
CAST(tabSales Invoice
.total
as DECIMAL(10,2)) AS total
,
so i cannot bypass the formatting number that i selected in the system settings?
use
frappe.utils.fmt_money('invoice_amount_field', precision=2, currency='invoice_currency')
3 Likes
thanks a lot for your help, how if i want to round the value with 2 precision decimal also ??
if i want to include the line code that you sent me how can i include it for this report for example for totalht
from __future__ import unicode_literals
import frappe
from frappe import _
import frappe.utils.fmt_money
def execute(filters=None):
columns = get_columns()
sl_sales_entries = get_sales_entries(filters)
data = []
for sle in sl_sales_entries:
data.append([ sle.sales, sle.cust, sle.creation, sle.totalht, sle.vat, sle.totalttc ])
return columns, data
def get_columns():
"""return columns"""
columns = [
_("Sales Invoice")+":Link/Sales Invoice:120",
_("Customer")+":Link/Customer:150",
_("Date")+":Date:Date",
_("Total HT")+":Float:140",
_("VAT")+":Float:140",
_("Total TTC")+":Float:140"
]
return columns
def get_sales_entries(filters):
return frappe.db.sql("""
(select
`tabSales Invoice`.`name` AS `sales`,
`tabSales Invoice`.`customer_name` AS `cust`,
STR_TO_DATE(`tabSales Invoice`.creation, '%%Y-%%m-%%d') as 'creation',
`tabSales Invoice`.`total_ht` AS `totalht`,
`tabSales Invoice`.`vat` AS `vat`,
`tabSales Invoice`.`grand_total` AS `totalttc`
FROM
`tabSales Invoice`)"""\
.format(sle_conditions=get_sle_conditions(filters)), filters, as_dict=1)
def get_sle_conditions(filters):
conditions = []
return "and {}".format(" and ".join(conditions)) if conditions else ""
sorry i’m kind of new to reports if you can help with that , i would appreciate it