I am building program to manage payment/monthly payments. I've ran into an issue that I haven't been able to overcome and need some help. I've been lurking for a while and decided it was time to ask you guys...Here's the issue:
I have a table 'payments' that contains scheduled payments that looks like:
id
clientid
paymentduedate
balance
expected
pending
367
112233
4/16/2011
1030.00
257.50
Y
368
112233
5/16/2011
1030.00
257.50
Y
369
112233
6/16/2011
1030.00
257.50
Y
370
112233
7/16/2011
1030.00
257.50
Y
What I need to do that I haven't figured out is to adjust the expected amount according to the payment, update the status to N (not pending) without affecting the later expected payments.
For example:
they make a payment of $257.50, applies that to row 367, sets the status to N, but leaves the other status' to Y (for obvious reasons).
the make a payment of $250.00, leaving the balance at $7.50, so lets add $7.50 to row 368, mark 367 status to N
the make a payment of $300.00, leaving the expected balance at $0.00 for row 367, but adjust the balance for row 368 to $215.00
Any ideas?
Thanks