I have a database table which stores items for an invoice, there are 4 cols (where item_net is a float (4,2) and stores the amount before tax and item_vat is a true or false (1 or 0) which identifys whether vat is required on that item.
invoice_id | item_details | item_net | item_vat
When i pull out all items related to an invoice (invoice_id) i need to do some calculations to pull out three results.
1. total net ($net)
2. total vat ($vat)
3 Total ($net +$vat)
So i need to take each row of the $item array that i create when i pull all the values out of the database and then for each row calculate the vat if required and then add to the running total.
I have tried creating some empty vars for the net and the vat and then adding to them but i cant seem to get it working, could this be something to do with the float format in the db.
Any suggestions, example code would be much appriciated, i can post my current attempt, but i would rather see how a pro would approach it first.