Creating two sequential invoices from a single order/job
See attached ERD to see my relationship structure.
The user creates an Order (has its own sequential serial number), from a custome rlayout, based on customers.
The contents of the quoteslorders/invoices comes from the invoice details table. The actual serial numbers for each of these comes from their respecrive tables (quotes/orders/invoices)
On this order, that has a lines portal to products which will be filled with several records containing the ordered items, the user then is supposed to raise/create an automatic invoice for a deposit. This Invoice will then be raised using the same order number, customer details etc from the order. Once this has been done, the user can then convert the original order to an invoice - keeping the same order number but a new invoice number. The invoices must not skip, but be the next serail.
The problem I am having is creating two sequential invoice numbers, for the same order number. Teh clsoest I have got it working is that the order numbers skip one.
I also attach my script that needs a bit of work!
I suppose in a way it is like creating a supplmentary invoice to the original order. The orders are like Jobs for this company..