fix: timesheet amount issue (#25993)
* fix: timesheet amount issue * fix: timesheet detail rate conversion * fix: condition to check timesheet currency * fix: removing console statement
This commit is contained in:
parent
1a39d1a311
commit
a6aa6cd7d6
@ -447,6 +447,15 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
this.frm.refresh_field("outstanding_amount");
|
this.frm.refresh_field("outstanding_amount");
|
||||||
this.frm.refresh_field("paid_amount");
|
this.frm.refresh_field("paid_amount");
|
||||||
this.frm.refresh_field("base_paid_amount");
|
this.frm.refresh_field("base_paid_amount");
|
||||||
|
},
|
||||||
|
|
||||||
|
currency() {
|
||||||
|
this._super();
|
||||||
|
$.each(cur_frm.doc.timesheets, function(i, d) {
|
||||||
|
let row = frappe.get_doc(d.doctype, d.name)
|
||||||
|
set_timesheet_detail_rate(row.doctype, row.name, cur_frm.doc.currency, row.timesheet_detail)
|
||||||
|
});
|
||||||
|
calculate_total_billing_amount(cur_frm)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -846,7 +855,8 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
'time_sheet': row.parent,
|
'time_sheet': row.parent,
|
||||||
'billing_hours': row.billing_hours,
|
'billing_hours': row.billing_hours,
|
||||||
'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,
|
||||||
|
'project_name': row.project_name
|
||||||
});
|
});
|
||||||
frm.refresh_field('timesheets');
|
frm.refresh_field('timesheets');
|
||||||
calculate_total_billing_amount(frm);
|
calculate_total_billing_amount(frm);
|
||||||
@ -965,43 +975,34 @@ frappe.ui.form.on('Sales Invoice', {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
frappe.ui.form.on('Sales Invoice Timesheet', {
|
|
||||||
time_sheet: function(frm, cdt, cdn){
|
|
||||||
var d = locals[cdt][cdn];
|
|
||||||
if(d.time_sheet) {
|
|
||||||
frappe.call({
|
|
||||||
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_data",
|
|
||||||
args: {
|
|
||||||
'name': d.time_sheet,
|
|
||||||
'project': frm.doc.project || null
|
|
||||||
},
|
|
||||||
callback: function(r, rt) {
|
|
||||||
if(r.message){
|
|
||||||
let data = r.message;
|
|
||||||
frappe.model.set_value(cdt, cdn, "billing_hours", data.billing_hours);
|
|
||||||
frappe.model.set_value(cdt, cdn, "billing_amount", data.billing_amount);
|
|
||||||
frappe.model.set_value(cdt, cdn, "timesheet_detail", data.timesheet_detail);
|
|
||||||
calculate_total_billing_amount(frm)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
var calculate_total_billing_amount = function(frm) {
|
var calculate_total_billing_amount = function(frm) {
|
||||||
var doc = frm.doc;
|
var doc = frm.doc;
|
||||||
|
|
||||||
doc.total_billing_amount = 0.0
|
doc.total_billing_amount = 0.0
|
||||||
if(doc.timesheets) {
|
if (doc.timesheets) {
|
||||||
$.each(doc.timesheets, function(index, data){
|
$.each(doc.timesheets, function(index, data){
|
||||||
doc.total_billing_amount += data.billing_amount
|
doc.total_billing_amount += flt(data.billing_amount)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_field('total_billing_amount')
|
refresh_field('total_billing_amount')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var set_timesheet_detail_rate = function(cdt, cdn, currency, timelog) {
|
||||||
|
frappe.call({
|
||||||
|
method: "erpnext.projects.doctype.timesheet.timesheet.get_timesheet_detail_rate",
|
||||||
|
args: {
|
||||||
|
timelog: timelog,
|
||||||
|
currency: currency
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if (!r.exc && r.message) {
|
||||||
|
frappe.model.set_value(cdt, cdn, 'billing_amount', r.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var select_loyalty_program = function(frm, loyalty_programs) {
|
var select_loyalty_program = function(frm, loyalty_programs) {
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
title: __("Select Loyalty Program"),
|
title: __("Select Loyalty Program"),
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
"description",
|
"description",
|
||||||
"billing_hours",
|
"billing_hours",
|
||||||
"billing_amount",
|
"billing_amount",
|
||||||
|
"column_break_5",
|
||||||
"time_sheet",
|
"time_sheet",
|
||||||
|
"project_name",
|
||||||
"timesheet_detail"
|
"timesheet_detail"
|
||||||
],
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
@ -61,11 +63,21 @@
|
|||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Description",
|
"label": "Description",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_5",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "project_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Project Name",
|
||||||
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-20 22:33:57.234846",
|
"modified": "2021-06-08 14:43:02.748981",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Accounts",
|
"module": "Accounts",
|
||||||
"name": "Sales Invoice Timesheet",
|
"name": "Sales Invoice Timesheet",
|
||||||
|
@ -310,6 +310,7 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"default": "1",
|
||||||
"fieldname": "exchange_rate",
|
"fieldname": "exchange_rate",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"label": "Exchange Rate"
|
"label": "Exchange Rate"
|
||||||
@ -319,7 +320,7 @@
|
|||||||
"idx": 1,
|
"idx": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2021-05-18 16:10:08.249619",
|
"modified": "2021-06-09 12:08:53.930200",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Projects",
|
"module": "Projects",
|
||||||
"name": "Timesheet",
|
"name": "Timesheet",
|
||||||
|
@ -227,7 +227,8 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to
|
|||||||
return frappe.db.sql("""SELECT tsd.name as name,
|
return frappe.db.sql("""SELECT tsd.name as name,
|
||||||
tsd.parent as parent, tsd.billing_hours as billing_hours,
|
tsd.parent as parent, tsd.billing_hours as billing_hours,
|
||||||
tsd.billing_amount as billing_amount, tsd.activity_type as activity_type,
|
tsd.billing_amount as billing_amount, tsd.activity_type as activity_type,
|
||||||
tsd.description as description, ts.currency as currency
|
tsd.description as description, ts.currency as currency,
|
||||||
|
tsd.project_name as project_name
|
||||||
FROM `tabTimesheet Detail` tsd
|
FROM `tabTimesheet Detail` tsd
|
||||||
INNER JOIN `tabTimesheet` ts ON ts.name = tsd.parent
|
INNER JOIN `tabTimesheet` ts ON ts.name = tsd.parent
|
||||||
WHERE tsd.parenttype = 'Timesheet'
|
WHERE tsd.parenttype = 'Timesheet'
|
||||||
@ -235,6 +236,19 @@ def get_projectwise_timesheet_data(project=None, parent=None, from_time=None, to
|
|||||||
and tsd.is_billable = 1
|
and tsd.is_billable = 1
|
||||||
and tsd.sales_invoice is null""".format(condition), {'project': project, 'parent': parent, 'from_time': from_time, 'to_time': to_time}, as_dict=1)
|
and tsd.sales_invoice is null""".format(condition), {'project': project, 'parent': parent, 'from_time': from_time, 'to_time': to_time}, as_dict=1)
|
||||||
|
|
||||||
|
@frappe.whitelist()
|
||||||
|
def get_timesheet_detail_rate(timelog, currency):
|
||||||
|
timelog_detail = frappe.db.sql("""SELECT tsd.billing_amount as billing_amount,
|
||||||
|
ts.currency as currency FROM `tabTimesheet Detail` tsd
|
||||||
|
INNER JOIN `tabTimesheet` ts ON ts.name=tsd.parent
|
||||||
|
WHERE tsd.name = '{0}'""".format(timelog), as_dict = 1)[0]
|
||||||
|
|
||||||
|
if timelog_detail.currency:
|
||||||
|
exchange_rate = get_exchange_rate(timelog_detail.currency, currency)
|
||||||
|
|
||||||
|
return timelog_detail.billing_amount * exchange_rate
|
||||||
|
return timelog_detail.billing_amount
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
@frappe.validate_and_sanitize_search_inputs
|
@frappe.validate_and_sanitize_search_inputs
|
||||||
def get_timesheet(doctype, txt, searchfield, start, page_len, filters):
|
def get_timesheet(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
Loading…
Reference in New Issue
Block a user