MaxAllen
7 years agoQrew Cadet
Automatically Create Master Record for Child if one doesn't exist
This may be a bit of a long one as I want to explain the situation fully.. sorry in advance!
I'm building an app to report the weight of different types of post leaving our warehouse for invoicing reasons. As batches of post are completed, the ID of the user who packed it are entered, along with the quantity of items in the batch, the courier, the postage class, and whether it's a batch of parcels or packages. At the end of the day, every day, all of the items in one Bin (package vs letter, courier, class) are weighed, and the average weight calculated from the total quantity, this is what needs to be reported each day.
My thoughts on how to do this was to have two tables, a master called Bins and a details called Batches. The user would create a batch and populate it, at which point a parent would be automatically added, so there would be 1 record in Bins for each type each day. And then at the end of the day add the weight to the Bins table, where the total quantity for that Bin will be reported as a summary field.
My problem is how to somehow automatically create the parent record (perhaps using a concatenation of date&type&class&courier as the key) for the child if it does not already exist.
Many thanks for any advice! Or alternatively if there's another way of going about this!
I'm building an app to report the weight of different types of post leaving our warehouse for invoicing reasons. As batches of post are completed, the ID of the user who packed it are entered, along with the quantity of items in the batch, the courier, the postage class, and whether it's a batch of parcels or packages. At the end of the day, every day, all of the items in one Bin (package vs letter, courier, class) are weighed, and the average weight calculated from the total quantity, this is what needs to be reported each day.
My thoughts on how to do this was to have two tables, a master called Bins and a details called Batches. The user would create a batch and populate it, at which point a parent would be automatically added, so there would be 1 record in Bins for each type each day. And then at the end of the day add the weight to the Bins table, where the total quantity for that Bin will be reported as a summary field.
My problem is how to somehow automatically create the parent record (perhaps using a concatenation of date&type&class&courier as the key) for the child if it does not already exist.
Many thanks for any advice! Or alternatively if there's another way of going about this!