feat(Timesheet): validate employee cost with provision#590
Open
kunhimohamed wants to merge 4 commits into
Open
feat(Timesheet): validate employee cost with provision#590kunhimohamed wants to merge 4 commits into
kunhimohamed wants to merge 4 commits into
Conversation
…n if no cost is configured
…n if no cost is configured
SaiFi0102
requested changes
Jun 16, 2026
| self.calculate_percentage_billed() | ||
| self.set_dates() | ||
| self.set_status() | ||
| self.validate_employee_cost(self.employee) |
Member
There was a problem hiding this comment.
- 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): |
Member
There was a problem hiding this comment.
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() | |||
Member
There was a problem hiding this comment.
- 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." |
Member
There was a problem hiding this comment.
Translate string, do not use f-string for user-messages, use str.format instead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.