Hi Everyone,
I wanted to know how can I get the total of 5 custom fields in a form
In the offer letter document, I created 5 Fields for Salary and Allowances, I want to get the total at the bottom, and also to get the the amount in words for the currency fields and also for the total. I want to use this info in the offer letter print format as well.
What is my best way to approach this?
Thanks
@bibinqcs , In Words
run in the backend side, you can give a sample of how get the value in words here
def set_total_in_words(self):
from frappe.utils import money_in_words
company_currency = get_company_currency(self.company)
disable_rounded_total = cint(frappe.db.get_value("Global Defaults", None, "disable_rounded_total"))
if self.meta.get_field("base_in_words"):
self.base_in_words = money_in_words(disable_rounded_total and
abs(self.base_grand_total) or abs(self.base_rounded_total), company_currency)
if self.meta.get_field("in_words"):
self.in_words = money_in_words(disable_rounded_total and
abs(self.grand_total) or abs(self.rounded_total), self.currency)
def calculate_commission(self):
if self.meta.get_field("commission_rate"):
self.round_floats_in(self, ["base_net_total", "commission_rate"])
if self.commission_rate > 100.0:
throw(_("Commission rate cannot be greater than 100"))
self.total_commission = flt(self.base_net_total * self.commission_rate / 100.0,
self.precision("total_commission"))
Akash
January 3, 2018, 6:34am
3
def validate(self):
from frappe.utils import money_in_words
from erpnext.setup.utils import get_company_currency
if self.company:
company_currency = get_company_currency(self.company)
self.total_in_word = money_in_words(self.grand_total, company_currency)
1 Like
Thank you for the responses will check it out
is it client script or server ?