Best way to implement?

Best way to implement?

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


ajj3085 posted on Friday, July 25, 2008

Hi,

I have a quoting / ordering / invoicing system built on Csla.  I now need to have the system automatically create a new back order if any items on the invoice have a quantity shipped less than quantity ordered.

The business rule is this; documents can be closed, an once closed are not to be modified again.  In the case of an invoice, the invoice then gets exported to our accounting system.   The requirement is to have a new order be created when the invoice is closed in the database (the user clicks the Close button, then Save).

My initial thinking is to put code in the DP_InvokeComplete to call a stored procedure that creates the back order.  No big deal, except that I do want to automatically bring up the newly created order so the user can print it if needed.  I'm trying to think of the best way to get this information back to the user.  One simple option is certainly to add a property to the Invoice.  The odd part of this is that the property will only ever have a value if a back order was just created.  Otherwise the value will always be null.  So, doesn't feel quite right, but I'm not sure of other good ways to handle this.

Any ideas?

tmg4340 replied on Friday, July 25, 2008

I don't think that adding a property on your Invoice object is necessarily a bad idea.  From a certain perspective, the new order is now part of your Invoice use case, so it would seem to have some merit.  But if you don't like that idea, the next best one I can think of is to stuff it into the GlobalContext.  Then you can check for your new Order ID after the save and launch your order form as necessary.

HTH

- Scott

SonOfPirate replied on Friday, July 25, 2008

Nah, this is a process issue.  Sounds like a good candidate for WF under-the-hood to manage the process (business) rules you described.

Not knowing how your UI is built, I'd say that I'd have some sort of OrderManager or InvoiceManager that handles the business rules and checks to see if a back order exists whenever an invoice is closed.  If it does, it notifies the UI that it needs to display the back-order.  Remember that your classes should only serve one purpose (single-responsibility) and if your Invoice class is there to support viewing/printing/editing an invoice, then it already has a purpose.  Delegate this responsibility to another object.

HTH

 

Copyright (c) Marimer LLC