Sounds like you need to get the SUM of each invoice, then deduct the deposits for each invoice.
invoice with many items and deposit
I am building an invoice system in which the invoice has many items. my db structure as following
| invoices | | -------- | | id | | service_prices | | discount | | final_price | | deposit | | rest_price_to_pay | | total_paid | | date | | status (1= paid - 2= not-paid 3= deposit|
| invoice_items | | -------- | | invoice_id | | quantity | | price | | date |
it works fine but the problem is when I need to get a daily report of each item's income to know what income I get daily from each item, it does not work properly with deposits, because when I want to get the daily items income i foreach items from invoice_items table, so when the client does deposit for sure the income will not be the equal of each item price. so i don't know how to solve it in the database
Please or to participate in this conversation.