Sample ERP

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

https://www.youtube.com/watch?

v=aitw-hePyAo&list=PLy7DXThvWXb9VX1DNH3hU-Y5VEPg3s17E

https://www.youtube.com/@mananshah7052

https://www.youtube.com/watch?v=8Q5B7DnxmLg&list=PLIj_IdEl38ZvywjSlTUrGa1Mdrg1jSo3S

HR and Payroll

https://www.youtube.com/playlist?list=PL5NizQZenrgNBJmjYtt2fQ0Tz7_ATMBUT
https://www.youtube.com/watch?v=MWQ9_Uplq-
E&list=PL5NizQZenrgNBJmjYtt2fQ0Tz7_ATMBUT&index=7

https://www.youtube.com/watch?
v=QNzENGWjavQ&list=PL5NizQZenrgNBJmjYtt2fQ0Tz7_ATMBUT&index=8

Define - Holiday list (create for shift people and normal people)
Shift Type - Define Shift Type and Assign Appropriate

To Calculate Work Experience:


-------------------------------
frappe.ui.form.on('Employee', {
onload: function (frm) {
frm.add_fetch('date_of_joining', 'date_of_joining', 'date_of_joining');
},
refresh: function (frm) {
calculateWorkExperience(frm);
},
date_of_joining: function (frm) {
calculateWorkExperience(frm);
},
});

function calculateWorkExperience(frm) {
if (frm.doc.date_of_joining) {
const dateOfJoining = new Date(frm.doc.date_of_joining);
const currentDate = new Date();
const diffInMilliseconds = currentDate - dateOfJoining;
const years = Math.floor(diffInMilliseconds / (1000 * 60 * 60 * 24 * 365));
const months = Math.floor((diffInMilliseconds % (1000 * 60 * 60 * 24 *
365)) / (1000 * 60 * 60 * 24 * 30));
const fractionalYears = (years + months / 12).toFixed(2);
frm.set_value('work_experience', parseFloat(fractionalYears));
} else {
frm.set_value('work_experience', '');
}
}

=================================
---------------------------------------------------------------

2- To Calculate Age
------------------------------
frappe.ui.form.on('Employee', {
date_of_birth: function(frm) {
if (frm.doc.date_of_birth) {
var birthDate = new Date(frm.doc.date_of_birth);
var today = new Date();
var ageInMilliseconds = today - birthDate;
var ageInYears = Math.floor(ageInMilliseconds / (365.25 * 24 * 60 * 60
* 1000));
frm.set_value('age', ageInYears);
}
}
});
--------------------------------------------------------------------

You might also like