Re: Refunds again
Hi Adam, Hi EHW,
After you mentioned in a previous post that everything that comes in on one purchase invoice goes out on one sales invoice (so a strict 1:1) but that there can be a number of adjustments (refunds) against the original purchase invoice, it seemed to me (unless I'm missing something) that from a data design point of view, the simplest thing would have been to hold both purchase and sales information on one single record. Then you don't have to worry about creating additional records, maintaining links between related sales and purchases, leaving orphaned records, losing traceability etc etc.
Simplest is often the best if the design doesn't compromise functionality and I don't believe it does in this case.
Looking back over the history of this topic, the options have gone from having separate tables for purchase and sales invoices, using the same table but with discrete purchase and sales records and now it seems you can use not only the same table but also the same record!
I haven't attempted to replicate all of the functionality of your existing project but I'm pretty sure that it's possible using the above suggested schema.
I've knocked up a quick demo to prove some of the more basic functionality - the whole thing can actually work without any script at all (always my target!): the few lines of script that I've used are only cosmetic, to make it a bit more user friendly.
I appreciate that you and EHW have done a lot of work on this so it's possibly too far down the road to want to change now, but it might yet prove to be of some use.
Regards,
Derek.