diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py index 1e2688daf4d..e17fa3d622c 100644 --- a/erpnext/projects/doctype/timesheet/test_timesheet.py +++ b/erpnext/projects/doctype/timesheet/test_timesheet.py @@ -17,6 +17,15 @@ class TestTimesheet(unittest.TestCase): def setUp(self): frappe.db.delete("Timesheet") + def test_timesheet_base_amount(self): + emp = make_employee("test_employee_6@salary.com") + timesheet = make_timesheet(emp, simulate=True, is_billable=1) + + self.assertEqual(timesheet.time_logs[0].base_billing_rate, 50) + self.assertEqual(timesheet.time_logs[0].base_costing_rate, 20) + self.assertEqual(timesheet.time_logs[0].base_billing_amount, 100) + self.assertEqual(timesheet.time_logs[0].base_costing_amount, 40) + def test_timesheet_billing_amount(self): emp = make_employee("test_employee_6@salary.com") timesheet = make_timesheet(emp, simulate=True, is_billable=1) @@ -236,4 +245,5 @@ def make_timesheet( def update_activity_type(activity_type): activity_type = frappe.get_doc("Activity Type", activity_type) activity_type.billing_rate = 50.0 + activity_type.costing_rate = 20.0 activity_type.save(ignore_permissions=True) diff --git a/erpnext/projects/doctype/timesheet/timesheet.py b/erpnext/projects/doctype/timesheet/timesheet.py index 0b4b99ba35b..ec58c55f020 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.py +++ b/erpnext/projects/doctype/timesheet/timesheet.py @@ -296,6 +296,20 @@ class Timesheet(Document): data.billing_amount = data.billing_rate * hours data.costing_amount = data.costing_rate * costing_hours + exchange_rate = flt(self.get("exchange_rate")) or 1.0 + data.base_billing_rate = flt( + data.billing_rate * exchange_rate, data.precision("base_billing_rate") + ) + data.base_costing_rate = flt( + data.costing_rate * exchange_rate, data.precision("base_costing_rate") + ) + data.base_billing_amount = flt( + data.billing_amount * exchange_rate, data.precision("base_billing_amount") + ) + data.base_costing_amount = flt( + data.costing_amount * exchange_rate, data.precision("base_costing_amount") + ) + def update_time_rates(self, ts_detail): if not ts_detail.is_billable: ts_detail.billing_rate = 0.0