Skip to content

Commit

Permalink
working with overtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohtashim-1 committed May 2, 2024
1 parent b67a8a3 commit ee6721f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
11 changes: 7 additions & 4 deletions overtime/overtime/doctype/overtime/overtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
frappe.ui.form.on('Overtime', {
attendance_record: function (frm) {
console.log(frm);
var data = frm.doc;
var standard_hours = data.standard_hours;
var working_hours = data.working_hours;
var doc = frm.doc;
var standard_hours = doc.standard_hours;
var working_hours = doc.working_hours;
// var per_hour_salary = 50000 / 30 / 9;
// console.log(per_hour_salary)

// Calculate overtime hours
var ot_hours = working_hours - standard_hours;
console.log(ot_hours);
// console.log(ot_hours);

// Set the value of the 'overtime_hours' field
frm.set_value('ot_hours', ot_hours);
// frm.set_value('per_hour_salary', per_hur_salary)
}
});
10 changes: 10 additions & 0 deletions overtime/overtime/doctype/overtime/overtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@
"fieldname": "standard_hours",
"fieldtype": "Data",
"label": "Standard Hours"
},
{
"fieldname": "per_hour_salary",
"fieldtype": "Float",
"label": "Per Hour Salary"
},
{
"fieldname": "overtime_hour",
"fieldtype": "Data",
"label": "Overtime Hour"
}
],
"index_web_pages_for_search": 1,
Expand Down
28 changes: 13 additions & 15 deletions overtime/overtime/doctype/overtime/overtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
from frappe.model.document import Document

class Overtime(Document):
def before_save(self):
ctc = frappe.get_all('Employee',filters={'employee':self.employee},fields=['employee','ctc'])
frappe.msgprint('Message')


# frappe.msgprint('Message')

# self.ot_hours_calculation()

def before_save(self):
self.salary()
self.overtime_hour_calculation()

# def ot_hours_calculation(self):
# # Calculate overtime hours
# self.overtime_hours = self.working_hours - self.standard_hours
# # Save the document
# self.save()

def salary(self):
frappe.msgprint("testing...")
self.per_hour_salary = float(self.ctc / 30 / 9)
frappe.errprint(self.per_hour_salary)

# # Optionally, you can also display a message to the user
# frappe.msgprint(f"Overtime hours calculated: {self.overtime_hours}")
def overtime_hour_calculation(self):
if(self.working_hours > 9 ):
self.overtime_hour - self.working_hours
else:
self.overtime_hour = 0

0 comments on commit ee6721f

Please sign in to comment.