Skip to content

feat(Timesheet): validate employee cost with provision#590

Open
kunhimohamed wants to merge 4 commits into
ParaLogicTech:version-15from
kunhimohamed:activity_cost
Open

feat(Timesheet): validate employee cost with provision#590
kunhimohamed wants to merge 4 commits into
ParaLogicTech:version-15from
kunhimohamed:activity_cost

Conversation

@kunhimohamed

Copy link
Copy Markdown

No description provided.

self.calculate_percentage_billed()
self.set_dates()
self.set_status()
self.validate_employee_cost(self.employee)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This call does nothing since stop_assigning=False
  • Better validate for new rows, rather than validating for the whole timesheet

frappe.throw(_("Row {0}: Incorrect time range").format(d.idx))

@staticmethod
def validate_employee_cost(employee_id, stop_assigning=False):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unnecessary stop_assigning argument, make this a configurable feature with checkbox in Projects Settings

Comment on lines 290 to +319
@@ -302,8 +312,11 @@ def get_activity_cost(employee=None, activity_type=None):

elif activity_type:
activity_cost = _get_activity_cost(activity_type=activity_type)

return activity_cost or _get_activity_cost() or frappe._dict()

if not activity_cost and get_cost_if_employee_not_set:
return _get_activity_cost() or frappe._dict()
else:
return activity_cost or frappe._dict()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Keep the old functionality the same, you can achieve the same validation without changing this
  • If you really do not want a fallback cost, then remove the fallback cost from Activity Cost master in the site rather than the code

costing_rate = flt(activity_cost.get("costing_rate"))
if not costing_rate and stop_assigning:
frappe.throw(
f"Employee <b>{employee_id}</b> cannot be assigned because no employee cost has been configured."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translate string, do not use f-string for user-messages, use str.format instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants