1
Good afternoon, Friends I am creating here a system of notinhas to use in the company it is very basic, but I am doubtful on how to set up the payment function so that it identifies the values some of low paid value and create a balance. my table and as follows
id | cliente | valor | pago | Deb/Cred
1 | teste | 35.00 | N | D
2 | teste | 35.00 | N | D
3 | teste | 35.00 | N | D
4 | pago | 65.00 | S | C
5 | saldo | 40.00 | N | C
Ai would like to know how to assemble the formula in php so that when I launch the payment it adds up the amounts up to id 3 that are only debited that gives a value of 105.00 subtract the payment that is in id 4 that is a credit picking up the result that is 105.00-65.00=40.00 launch on id 5 as credit and sub-subscribe in paid column N by S to identify who is paid
These values
pago
andsaldo
are also being inserted in this same table? That’s right?– Marcelo de Andrade
The amount paid it and inserted at each payment, the balance and the result of the values tests - paid. and all stay only on a table and when there is a payment I want to change the value "N" of the paid column to "S" and add the balance
– Cristiano Cardoso Silva
It is not clear your doubt... When the customer pays one of these installments, you will update the line
pago
and add how much he paid? Or just mark the installment asS
?– Marcelo de Andrade
So Marcelo, wanted when a person paid he sum the debt with the amount paid mark all debts and cast a new debt with the rest that would be the balance so that when I issue a bill not issue the whole report but only after the release of last balance. let’s for an example equal in id 4 he paid and generated a balance (debit/credit) ai in the id s above would be given an update and inserted S in the paid column in id 5 let’s assume that he makes 5 more purchases the last purchase would be the id 10 would pay would have an id 11 with the amount paid and the id 12 with the balance (debit/credit)
– Cristiano Cardoso Silva
Yes, that’s exactly what I understood, but are you using a single table for that? If you really need a record containing the amount paid and the remaining balance, you could have another related table and with these records. In this example of your question, the customer has 3 purchases in the amount of 35 and paid 65, this means that it is possible to make a payment of such a portion with less than the total?
– Marcelo de Andrade
That’s right, an example is this post here, http://answall.com/questions/86151/extracto-tipo-banc%C3%A1rio-complex-mysql-how-solve
– Cristiano Cardoso Silva
Let’s go continue this discussion in chat.
– Cristiano Cardoso Silva