Document conversion

Document conversion

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


ajj3085 posted on Thursday, April 12, 2007

Hi all,

I have a use case where a user can convert a quote to an order and order to invoice.

Its been suggested that I create a Csla class specifically to handle the conversion rules, which is what I intend to do.

My question is this; the use case has the document being converted while the document is currently being edited.  After conversion, the document status should be set to closed.  All that is well and good, but I'm struggling on what the 'proper' way to handle these points would be:

1.  How do I indicate that the document even can be converted?  It would be nice to disable the convert button if the document cannot be converted for whatever reason.

2.  There are rules that would keep a document from being converted, but I'm not sure how to convy this to the user on my document editing screen.  The button is on the document edit screen, but the converter is a seperate object that contains the violated rules. 

3.  Once the conversion runs, the document should be invalidated so that any attempts to edit it should result in an exception.  The document object must be reloaded to work with it again, although the UI will close the edit screen, but the BO needs to prevent this.

Any thoughts on how to go about these goals?

RockfordLhotka replied on Thursday, April 12, 2007

1) Let's assume you want an IsConvertible property. How expensive is that? In other words, can your ConvetOrder2Invoice (CO2I) object make the determination without having to get more info from the database?

If so, then CO2I can implement IsConvertible for use by the UI.

If not, then you need to decide whether disabling the button is worth the extra cost. If it is, you can just use CO2I and pay the price, otherwise just don't disable the button.

2) I suggest that CO2I uses Order, but Order is oblivious to what's going on. In other words, the UI fetches the order, then creates a CO2I object based on that Order. The UI then has references to both objects and can bind to both.

I'm not sure how you should display why conversion isn't possible, but you can probably do it by binding a size 0,0 label to a property of CO2I near your button - if CO2I is invalid, the tooltip of the errorprovider would should what's wrong.

3) It is your CO2I object that'll do the conversion right? I wonder if you can't just implement an internal/Friend interface in your business layer so the CO2I can, once conversion succeeds, tell the Order to change states. This would be done in the CO2I.Save() method after the save completes.

ajj3085 replied on Friday, April 13, 2007

Rocky,

That was the general direction I was thinking in.. glad to know I wasn't far off the track.

I'll start implementing as advised.

Thanks and feel better!

Andy

Copyright (c) Marimer LLC