Thanks for the replies everyone.
Let me explain this process in a little more detail. They have the ability to pull inventory from more than one location. Not every item will have Qty in a location.
This is a non-profit business and they do not follow the standard inventory management rules where ever item has a location in the warehouse or inventory store.
Sometimes they are packing items as soon as they come in the door and then update the computer later. They can pull inventory qty from 3 area:
Loose Qty (not in a location)
Location Qty ( Qty that has a location)
Expiration Date Qty ( items like medical items vitamins etc. that have exp. dates, each exp. date has its own qty)
Locations and Exp. Dates are child records of the inventory item.
QtyOnHand does not get updated unless they ship a packaged or a loose item.
I have this working where they just pull from a location but this will not work for them as they do not have the time to put every item in a location, some items are just packed loose.
The process I have now that works for location and is called when they click the Create or Save button in the form is:
Passing PackageDetail as a parmaeter
FIND InvLocation WHERE InvLocation.PM_PackageDetail.ID=PackageDetail.ID TAKE BEST 1
FIND InventoryMaster WHERE InventoryMaster.PM_PackageDtl.ID=PackageDetail.ID TAKE BEST 1
IF PackageDetail.PD_Qty>ThisInvLocation.IL_Qty+OLD_VALUE(PackageDetail.PD_Qty)
THEN
REPORT ERROR'Invalid Qty'
ELSE
INCREASE ThisInvLocation.IL_Qty BY OLD_VALUE(PackageDetail.PD_Qty)-PackageDetail.PD_Qty
INCREASE ThisInventoryMaster.IM_Qty4Packed BY PackageDetail.PD_Qty-OLD_VALUE(PackageDetail.PD_Qty)
This rule covers, WAS ADDED TO, WAS REMOVED FROM and WAS CHANGED.
The logic I think I need to add to cover all conditions they can use to pull qty from and split into several processes if needed.
Example #1:
FIND InvLocation WHERE InvLocation.PM_PackageDetail.ID=PackageDetail.ID TAKE BEST 1
FIND InvExpDate WHERE InvExpDate.PM_PackageDetail.ID=PackageDetail.ID TAKE BEST 1
FIND InventoryMaster WHERE InventoryMaster.PM_PackageDtl.ID=PackageDetail.ID TAKE BEST 1
IF LooseQty with ExpirationDates
THEN...
ELSE IF LooseQty with no expiration dates
THEN...
ELSE IF LocationQty with expiration dates
THEN...
ELSE LocationQty with no expirations dates
THEN...
Example #2 Call separate process to managing each condition
FIND InvLocation WHERE InvLocation.PM_PackageDetail.ID=PackageDetail.ID TAKE BEST 1
FIND InvExpDate WHERE InvExpDate.PM_PackageDetail.ID=PackageDetail.ID TAKE BEST 1
FIND InventoryMaster WHERE InventoryMaster.PM_PackageDtl.ID=PackageDetail.ID TAKE BEST 1
IF LoostQty with ExpirationDates
THEN call process passing parameters
IF LooseQty with no expiration dates
THEN call process pass parameters
IF LocationQty with expiration dates
THEN call process pass parameters
IF LocationQty with no expirations dates
THEN call process passing parameters
Also, would it be a good idea to have 3 qty fields in the package detail BO and show all 3 fields on the Add/Edit form for package detail?
Loose Qty Packed ___________ short cut to Available Qty
LocationQty Packed _________short cut to Available Qty
Expiration Date Qty Packed_________short cut to Available Qty
There is a location combo box on the form that is filtered based on the Inventory # they enter. It will show the locations and qty for the selected item if there is any. I could do the same for an expiration date.
Thoughts?