fix: calculate total billing amount on fetching timesheets
- show timesheet billing amounts in doc currency
This commit is contained in:
parent
8a407f1ec3
commit
a7d0dbb085
@ -820,7 +820,7 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
add_timesheet_row: function(frm, row, exchange_rate) {
|
add_timesheet_row: function(frm, row, exchange_rate) {
|
||||||
frm.add_child('timesheets',{
|
frm.add_child('timesheets', {
|
||||||
'activity_type': row.activity_type,
|
'activity_type': row.activity_type,
|
||||||
'description': row.description,
|
'description': row.description,
|
||||||
'time_sheet': row.parent,
|
'time_sheet': row.parent,
|
||||||
@ -828,7 +828,8 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
'billing_amount': flt(row.billing_amount) * flt(exchange_rate),
|
'billing_amount': flt(row.billing_amount) * flt(exchange_rate),
|
||||||
'timesheet_detail': row.name
|
'timesheet_detail': row.name
|
||||||
});
|
});
|
||||||
frm.refresh_field('timesheets')
|
frm.refresh_field('timesheets');
|
||||||
|
calculate_total_billing_amount(frm);
|
||||||
},
|
},
|
||||||
|
|
||||||
refresh: function(frm) {
|
refresh: function(frm) {
|
||||||
@ -871,36 +872,32 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
project: data.project
|
project: data.project
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(!r.exc) {
|
if (!r.exc && r.message.length > 0) {
|
||||||
if(r.message.length > 0) {
|
frm.clear_table('timesheets')
|
||||||
frm.clear_table('timesheets')
|
r.message.forEach((d) => {
|
||||||
r.message.forEach((d) => {
|
let exchange_rate = 1.0;
|
||||||
let exchange_rate = 1.0;
|
if (frm.doc.currency != d.currency) {
|
||||||
if (frm.doc.currency != d.currency) {
|
frappe.call({
|
||||||
frappe.call({
|
method: 'erpnext.setup.utils.get_exchange_rate',
|
||||||
method: "erpnext.setup.utils.get_exchange_rate",
|
args: {
|
||||||
args: {
|
from_currency: d.currency,
|
||||||
from_currency: d.currency,
|
to_currency: frm.doc.currency
|
||||||
to_currency: frm.doc.currency
|
},
|
||||||
},
|
callback: function(r) {
|
||||||
callback: function(r) {
|
if (r.message) {
|
||||||
if (r.message) {
|
exchange_rate = r.message;
|
||||||
exchange_rate = r.message;
|
frm.events.add_timesheet_row(frm, d, exchange_rate);
|
||||||
frm.events.add_timesheet_row(frm, d, exchange_rate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
else {
|
} else {
|
||||||
frm.events.add_timesheet_row(frm, d, exchange_rate);
|
frm.events.add_timesheet_row(frm, d, exchange_rate);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
frappe.msgprint(__('No Timesheets found with the selected filters.'))
|
||||||
frappe.msgprint(__('No Timesheet Found.'))
|
|
||||||
}
|
|
||||||
d.hide();
|
|
||||||
}
|
}
|
||||||
|
d.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -772,6 +772,7 @@
|
|||||||
"hide_days": 1,
|
"hide_days": 1,
|
||||||
"hide_seconds": 1,
|
"hide_seconds": 1,
|
||||||
"label": "Total Billing Amount",
|
"label": "Total Billing Amount",
|
||||||
|
"options": "currency",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@ -1960,7 +1961,7 @@
|
|||||||
"label": "Is Debit Note"
|
"label": "Is Debit Note"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"default": 0,
|
"default": "0",
|
||||||
"depends_on": "grand_total",
|
"depends_on": "grand_total",
|
||||||
"fieldname": "disable_rounded_total",
|
"fieldname": "disable_rounded_total",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
@ -1977,7 +1978,7 @@
|
|||||||
"link_fieldname": "consolidated_invoice"
|
"link_fieldname": "consolidated_invoice"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2021-05-13 17:53:26.185370",
|
"modified": "2021-05-20 22:48:33.988881",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice",
|
"name": "Sales Invoice",
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
"fieldtype": "Currency",
|
"fieldtype": "Currency",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Billing Amount",
|
"label": "Billing Amount",
|
||||||
|
"options": "currency",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -64,7 +65,7 @@
|
|||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-13 16:52:32.995266",
|
"modified": "2021-05-20 22:33:57.234846",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice Timesheet",
|
"name": "Sales Invoice Timesheet",
|
||||||
|
@ -342,9 +342,9 @@ def get_activity_cost(employee=None, activity_type=None, currency=None):
|
|||||||
rate = frappe.db.get_values("Activity Type", {"activity_type": activity_type},
|
rate = frappe.db.get_values("Activity Type", {"activity_type": activity_type},
|
||||||
["costing_rate", "billing_rate"], as_dict=True)
|
["costing_rate", "billing_rate"], as_dict=True)
|
||||||
if rate and currency and currency!=base_currency:
|
if rate and currency and currency!=base_currency:
|
||||||
exchnage_rate = get_exchange_rate(base_currency, currency)
|
exchange_rate = get_exchange_rate(base_currency, currency)
|
||||||
rate[0]["costing_rate"] = rate[0]["costing_rate"] * exchnage_rate
|
rate[0]["costing_rate"] = rate[0]["costing_rate"] * exchange_rate
|
||||||
rate[0]["billing_rate"] = rate[0]["billing_rate"] * exchnage_rate
|
rate[0]["billing_rate"] = rate[0]["billing_rate"] * exchange_rate
|
||||||
|
|
||||||
return rate[0] if rate else {}
|
return rate[0] if rate else {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user