Need a script to add customer checks to employee payroll when collected
I have been messing around with this for quite some time now can't get it right...
When a salesperson collects a customer's check they click the "check collected" button on the customers record. This leads them to my "checks collected details" layout where they enter the amount, check type, and a picture of the check. When they do this the check is automatically added to the "checks collected" layout which simply displays all checks collected by each salesperson in the entire time they have been employed.
I have created three new layouts; "employee payroll," "employee payroll details," and "employee payroll data" the details page is the printable page which is to list all of the checks collected during that week(sat. - friday) by that salesperson and automatically determines their commission for each check. The "employee payroll" layout is simple a layout for me to view all of the current and past payrolls, it shows basic details of each weeks payrolls for each salesperson. Each salesperson's payroll for each week has a status which is either "pending" or "paid." The "employee payroll data" layout is non-viewable I used this to create a portal on my "employee payroll details" layout which displays the info. for each check collected that week.
I would like to make a script that runs when the "check collected" layout is exited to transfer the information of the check to the salesperson's pending payroll. I need it to determine if there is a pending payroll already created for this salesperson for this week and add the check info to it. If no pending payroll exists it needs to create a new payroll and then add the check data as well as set the status to "pending."
Keep in mind that the check data has to be transferred to fields located in the portal on my "employee payroll details" page.
I hope I have given enough information please let me know if you need anything else. I appreciate anyone's help on this matter.