def get_field_precision(df, doc=None, currency=None):
 from frappe.utils import get_number_format_info
 if cint(df.precision):
  precision = cint(df.precision)
 elif (df.fieldtype == u'Currency'):
  number_format = None
  if ((not currency) and doc):
   currency = get_field_currency(df, doc)
  if (not currency):
   currency = frappe.db.get_default(u'currency')
  if currency:
   number_format = frappe.db.get_value(u'Currency', currency, u'number_format', cache=True)
  if (not number_format):
   number_format = (frappe.db.get_default(u'number_format') or u'#,###.##')
  (decimal_str, comma_str, precision) = get_number_format_info(number_format)
 else:
  precision = (cint(frappe.db.get_default(u'float_precision')) or 3)
 return precision

def get_field_precision ( df , doc = None , currency = None ) : from frappe . utils import get_number_format_info if cint ( df . precision ) : precision = cint ( df . precision ) elif ( df . fieldtype == u'Currency' ) : number_format = None if ( ( not currency ) and doc ) : currency = get_field_currency ( df , doc ) if ( not currency ) : currency = frappe . db . get_default ( u'currency' ) if currency : number_format = frappe . db . get_value ( u'Currency' , currency , u'number_format' , cache = True ) if ( not number_format ) : number_format = ( frappe . db . get_default ( u'number_format' ) or u'#,###.##' ) ( decimal_str , comma_str , precision ) = get_number_format_info ( number_format ) else : precision = ( cint ( frappe . db . get_default ( u'float_precision' ) ) or 3 ) return precision
get precision based on docfield options and fieldvalue in doc .