Status change in Attendance

Hi there,
I am trying to capture late_arrival of an employee in a month.
My aim is to mark the employee attendance to half day if employee is late for 3rd day in a month.
and absent if he is late for 6th day in a month.
How can implement this via script.
I have already added the custom fields but unable to retrieve attendance of employee in a month.
We directly upload the attendance.
So how can i mark the status accordingly?

Maybe run a scheduled script that updates at the end of every month (?)

Is it possible that the value of a submitted document can be changed later on through script?
In my case changing the status to absent if it is possible.