I will definitely need a design that an invoice can be linked to one or more orders.
I think you have made a good point... so basically to keep it simple I only need to add invoice_id field in the tbl_order table without having invoice_order table?
- order_id (PK)
- shop_id (FK)
- user_id (FK)
- invoice_id (FK, default is 0)
5, 2, 12, 10.50, 1, 01/01/2011, 123
6, 2, 12, 11.00, 1, 02/01/2011, 123
7, 2, 12, 13.30, 1, 02/01/2011, 123
Note: invoice_id field will get updated if I insert a row in the invoice table.
- order_item_id (PK)
- order_id (FK)
- invoice_id (PK)
- status (Paid, Unpaid, etc)
Eg: 123, 01/06/2011, 01/06/2011, 01/06/2011, 15/06/2011, Unpaid
I want to generate an invoices for every 2 weeks automatically, I could use Cron Jobs for that?
Here what I am trying to do... When customer placed an order, their order are stored in the order table. I want to create an invoice for period: 1 to 15 May from order.shop_id = 2 (An invoice will have multiple order_id).