"Related" business actions

"Related" business actions

Old forum URL: forums.lhotka.net/forums/t/5332.aspx


ajj3085 posted on Tuesday, September 02, 2008

Hi,

I'm now moving to capture inventory information in my quoting / sales application.  As part of this, the expectation is that when an order is saved, the appropriate inventory is "locked."  Not taken out of inventory, but somehow marked as committed to an order.

My question is how to plug this functionality into my existing order business objects.  I know it needs to be encapsulated out.. but what's the best way to handle this?  Just call this other BO which updates the inventory?  As the order is changed and saved, the inventory needs to be changed as well.  So just include this code as part of the DataPortal Insert / Update methods?

Thanks
Andy

tmg4340 replied on Tuesday, September 02, 2008

The first solution that comes to mind is a Command object that locks the inventory.  After a successful Save(), you fire off this command.  Or, you could fire it off in the DP_ methods of your base order object.  Unless locking inventory is part of a use case/user interaction, I wouldn't create a full-fledged BO to do the locking.

HTH

- Scott

ajj3085 replied on Tuesday, September 02, 2008

I see the inventory locking as a new step being added to saving a document. It all should happen within the same transaction.

One thing I didn't mention is that inventory only gets locked if certain conditions about the order are true.  So I don't know if that will affect anyone's advice.

tmg4340 replied on Tuesday, September 02, 2008

I'd still make it a separate Command object.  Given these conditions, I'd probably launch the command from the DP_ methods inside your root order object.  That way, you can share the transaction that's been set up.  And you could pass the order object to your command (via criteria) to let the command determine whether it needs to do anything.  That would be the least intrusion into your order codebase.  But you could certainly make a case for putting the determination of locking inventory into your order object, and then you don't have to pass it to your inventory command.  I guess it depends on how you view the responsibility - it's a bit of a toss-up for me.

- Scott

ajj3085 replied on Wednesday, September 03, 2008

Actually that's a pretty good case for the command object.  Also, I'll need the same logic when converting the quote to an order as well (quotes can lock inventory too). 

Thanks!

SonOfPirate replied on Wednesday, September 03, 2008

Why not implement a workflow that is triggered when your order is saved?  Then you can customize what does and doesn't occur as part of the workflow, giving you greater flexibility into the future.

Your workflow activity can make use of a command object as suggested.  So, your business logic would trigger the workflow in response to your order being saved, one of the workflow activities would be "LockInventoryActivity" that implements a command object to perform the task in the data store.

This approach will allow you to change the business PROCESS (as opposed to logic) as needed.

P.S. Workflow activities are reusable, so you can add a workflow to your quote and reuse the same activity to lock the inventory!

Copyright (c) Marimer LLC