end of week/month

end of week/month

hi guys,
i hope you can help me to solve this problem.
I have a form called "clients" where i set payment terms of them and apply it on every invoice.
If i have scheduled payments with "n" days starting by invoice date, i haven't problem to obtain the "due date".
The problem is when i set payments with "n" days starting by the end of the month or the week.
Can someone help me?
Thanks in advance
bye