Frappe Cloud Support Partners Foundation Frappe School

Compensatory Off valid only for 3 months

Hi can anyone give me a idea for Compesatory off consumption validity.

With the above Image I want to automate a process where in the Work from date should be checked with today’s date and if it passes through 90 days (3 months) it should be automatically deleted from the leave allocation total leaves allocated

I am ok for custom script even I used one of them to execute the process:
I am not good with coding, but below is the attempt I made to make this work.

frappe.ui.form.on(‘Compensatory Leave Request’, ‘refresh’,‘validated’, function(frm){
var today = new Date(frappe.datetime.nowdate());
var valid = frappe.datetime.get_day_diff( today, frm.doc.from_date);
if (frm.doc.leave_type== ‘Compensatory Off’ && valid >90)
frm.validated = true;

Any type of help will be appriciated