This is one for the accountant and expert programers out there.
I have two tables:
Invoices
Payments
I need to allocate the payments to the invoices.
Sounds easy right? - Not!
Scinario: I have an invoice for £100 and someone pays me £150, I have an overpayment; therefore I need to be able to pay £100 against the invoice and leave £50 "on account". and visa-versa for underpayments, then I will also need to allocate the remainder to another invoice.
Has anyone written a customer account system that I can pinch for a programming favour debt? - Or some advice from someone who has done this before. I really need some help on this one.