mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-12 17:23:38 +00:00
fix: updating base amounts through python for timesheet for v15
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user