def get_amount(ref_doc, dt):
 if (dt == u'Sales Order'):
  grand_total = (flt(ref_doc.grand_total) - flt(ref_doc.advance_paid))
 if (dt == u'Sales Invoice'):
  if (ref_doc.party_account_currency == ref_doc.currency):
   grand_total = flt(ref_doc.outstanding_amount)
  else:
   grand_total = (flt(ref_doc.outstanding_amount) / ref_doc.conversion_rate)
 if (grand_total > 0):
  return grand_total
 else:
  frappe.throw(_(u'Payment Entry is already created'))

def get_amount ( ref_doc , dt ) : if ( dt == u'Sales Order' ) : grand_total = ( flt ( ref_doc . grand_total ) - flt ( ref_doc . advance_paid ) ) if ( dt == u'Sales Invoice' ) : if ( ref_doc . party_account_currency == ref_doc . currency ) : grand_total = flt ( ref_doc . outstanding_amount ) else : grand_total = ( flt ( ref_doc . outstanding_amount ) / ref_doc . conversion_rate ) if ( grand_total > 0 ) : return grand_total else : frappe . throw ( _ ( u'Payment Entry is already created' ) )
get amount based on doctype .