From 07ab4622e89295427925bb4de1c97603f1a78a44 Mon Sep 17 00:00:00 2001 From: Pawan Mehta Date: Wed, 25 Oct 2017 11:55:49 +0530 Subject: [PATCH] [fix] #9824 - Calculate costing amount even if billable is unchecked (#11310) * [fix] #9824 * fix code --- erpnext/projects/doctype/timesheet/timesheet.js | 4 +--- erpnext/projects/doctype/timesheet/timesheet.py | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/erpnext/projects/doctype/timesheet/timesheet.js b/erpnext/projects/doctype/timesheet/timesheet.js index 1ea5962911..43f5705e82 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.js +++ b/erpnext/projects/doctype/timesheet/timesheet.js @@ -191,7 +191,6 @@ var update_time_rates = function(frm, cdt, cdn){ var child = locals[cdt][cdn]; if(!child.billable){ frappe.model.set_value(cdt, cdn, 'billing_rate', 0.0); - frappe.model.set_value(cdt, cdn, 'costing_rate', 0.0); } } @@ -202,9 +201,8 @@ var calculate_billing_costing_amount = function(frm, cdt, cdn){ if(child.billing_hours && child.billable){ billing_amount = (child.billing_hours * child.billing_rate); - costing_amount = flt(child.costing_rate * child.billing_hours); } - + costing_amount = flt(child.costing_rate * child.hours); frappe.model.set_value(cdt, cdn, 'billing_amount', billing_amount); frappe.model.set_value(cdt, cdn, 'costing_amount', costing_amount); calculate_time_and_amount(frm); diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index ad566d5ac1..01552a50c9 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -49,10 +49,10 @@ class Timesheet(Document): self.update_time_rates(d) self.total_hours += flt(d.hours) + self.total_costing_amount += flt(d.costing_amount) if d.billable: self.total_billable_hours += flt(d.billing_hours) self.total_billable_amount += flt(d.billing_amount) - self.total_costing_amount += flt(d.costing_amount) self.total_billed_amount += flt(d.billing_amount) if d.sales_invoice else 0.0 self.total_billed_hours += flt(d.billing_hours) if d.sales_invoice else 0.0 @@ -265,19 +265,19 @@ class Timesheet(Document): def update_cost(self): for data in self.time_logs: - if data.activity_type and data.billable: + if data.activity_type or data.billable: rate = get_activity_cost(self.employee, data.activity_type) hours = data.billing_hours or 0 + costing_hours = data.billing_hours or data.hours or 0 if rate: data.billing_rate = flt(rate.get('billing_rate')) if flt(data.billing_rate) == 0 else data.billing_rate data.costing_rate = flt(rate.get('costing_rate')) if flt(data.costing_rate) == 0 else data.costing_rate data.billing_amount = data.billing_rate * hours - data.costing_amount = data.costing_rate * hours + data.costing_amount = data.costing_rate * costing_hours def update_time_rates(self, ts_detail): if not ts_detail.billable: ts_detail.billing_rate = 0.0 - ts_detail.costing_rate = 0.0 @frappe.whitelist() def get_projectwise_timesheet_data(project, parent=None):