fix: calculate total billing amount on fetching timesheets
- show timesheet billing amounts in doc currency
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 747d0a9..1808005 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -820,7 +820,7 @@
},
add_timesheet_row: function(frm, row, exchange_rate) {
- frm.add_child('timesheets',{
+ frm.add_child('timesheets', {
'activity_type': row.activity_type,
'description': row.description,
'time_sheet': row.parent,
@@ -828,7 +828,8 @@
'billing_amount': flt(row.billing_amount) * flt(exchange_rate),
'timesheet_detail': row.name
});
- frm.refresh_field('timesheets')
+ frm.refresh_field('timesheets');
+ calculate_total_billing_amount(frm);
},
refresh: function(frm) {
@@ -871,36 +872,32 @@
project: data.project
},
callback: function(r) {
- if(!r.exc) {
- if(r.message.length > 0) {
- frm.clear_table('timesheets')
- r.message.forEach((d) => {
- let exchange_rate = 1.0;
- if (frm.doc.currency != d.currency) {
- frappe.call({
- method: "erpnext.setup.utils.get_exchange_rate",
- args: {
- from_currency: d.currency,
- to_currency: frm.doc.currency
- },
- callback: function(r) {
- if (r.message) {
- exchange_rate = r.message;
- frm.events.add_timesheet_row(frm, d, exchange_rate);
- }
+ if (!r.exc && r.message.length > 0) {
+ frm.clear_table('timesheets')
+ r.message.forEach((d) => {
+ let exchange_rate = 1.0;
+ if (frm.doc.currency != d.currency) {
+ frappe.call({
+ method: 'erpnext.setup.utils.get_exchange_rate',
+ args: {
+ from_currency: d.currency,
+ to_currency: frm.doc.currency
+ },
+ callback: function(r) {
+ if (r.message) {
+ exchange_rate = r.message;
+ frm.events.add_timesheet_row(frm, d, exchange_rate);
}
- });
- }
- else {
- frm.events.add_timesheet_row(frm, d, exchange_rate);
- }
- });
- }
- else {
- frappe.msgprint(__('No Timesheet Found.'))
- }
- d.hide();
+ }
+ });
+ } else {
+ frm.events.add_timesheet_row(frm, d, exchange_rate);
+ }
+ });
+ } else {
+ frappe.msgprint(__('No Timesheets found with the selected filters.'))
}
+ d.hide();
}
});
},
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 48d644c..e7dd6b8 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -772,6 +772,7 @@
"hide_days": 1,
"hide_seconds": 1,
"label": "Total Billing Amount",
+ "options": "currency",
"print_hide": 1,
"read_only": 1
},
@@ -1960,7 +1961,7 @@
"label": "Is Debit Note"
},
{
- "default": 0,
+ "default": "0",
"depends_on": "grand_total",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
@@ -1977,7 +1978,7 @@
"link_fieldname": "consolidated_invoice"
}
],
- "modified": "2021-05-13 17:53:26.185370",
+ "modified": "2021-05-20 22:48:33.988881",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice",
diff --git a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
index 9321630..f069e8d 100644
--- a/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
+++ b/erpnext/accounts/doctype/sales_invoice_timesheet/sales_invoice_timesheet.json
@@ -34,6 +34,7 @@
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Billing Amount",
+ "options": "currency",
"read_only": 1
},
{
@@ -64,7 +65,7 @@
],
"istable": 1,
"links": [],
- "modified": "2021-05-13 16:52:32.995266",
+ "modified": "2021-05-20 22:33:57.234846",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Invoice Timesheet",
diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py
index d42c6ab..a3e4577 100644
--- a/erpnext/projects/doctype/timesheet/timesheet.py
+++ b/erpnext/projects/doctype/timesheet/timesheet.py
@@ -342,9 +342,9 @@
rate = frappe.db.get_values("Activity Type", {"activity_type": activity_type},
["costing_rate", "billing_rate"], as_dict=True)
if rate and currency and currency!=base_currency:
- exchnage_rate = get_exchange_rate(base_currency, currency)
- rate[0]["costing_rate"] = rate[0]["costing_rate"] * exchnage_rate
- rate[0]["billing_rate"] = rate[0]["billing_rate"] * exchnage_rate
+ exchange_rate = get_exchange_rate(base_currency, currency)
+ rate[0]["costing_rate"] = rate[0]["costing_rate"] * exchange_rate
+ rate[0]["billing_rate"] = rate[0]["billing_rate"] * exchange_rate
return rate[0] if rate else {}