On Jul 15, 2009, at 4:35 AM, Vikas Mayur wrote:
Hi,
I have introduced a feature called Verify Pick in Facility component
few months back based on a requirement. I was reviewing the code
more closely and found some issues.
The pre-condition to run this process is that order is in approved
status.
Steps to do Verify Pick are:
1) Create a Sales Order without split shipment option. Order should
be in approved status.
2) Go to Facility and select the WebStoreWarehouse facility.
3) Lets first check whether the order is ready to pick or need stock
move. To do this go to Picking tab.
4) If the order is ready to pick then click on Verify Pick tab.
5) Enter the order Id and click Verify Order. This will show the
list of the items that need to be verified, by default all of the
items are selected.
6) Click on Verify Items.
7) This will display the summary in another list at the bottom. User
have the option to either cancel or complete the verify order process.
8) Click on Complete button to verify the order.
If step 8 is a success then it will create a shipment in Picked
status and as well as generate an invoice with In-Process status.
The existing code was working fine but not implemented correctly as
it end up creating just an Invoice and Invoice Items at max but
there are certain other processes (entities where data is stored as
well) when an invoice is created as implemented in
createInvoiceForOrder service in InvoiceService class.
There is also an eca on updateShipment service which look for
shipment in PACKED status and then create the invoice. The service
triggered on eca is createInvoicesFromShipment. This service then
finally call createInvoiceForOrder and which create Invoice with In-
Process status, Invoice Items as well few other things as well.
Depending on the ProductStore.autoApproveInvoice flag, the status of
invoice is changed to INVOICE_READY and finally payment is captured
by capturePaymentsByInvoice triggered on eca rule defined on
createInvoiceForOrder. Finally, the invoice goes to PAID status,
Payments are captured and applied.
Coming back to my question a little bit, in the Verify Order step 8,
I do not want to capture payment and which is logical because
Invoice status is In-Process status.
My question is why payment is captured when the invoice status is In-
Process? Shouldn't the system look for Invoice Ready status to
capture the payments.
If what I said above is true, I could use the existing artifacts and
do some changes so that system validate against the invoice status
before doing a capture.
Yes, that sounds like the correct way to go. The payment capture
trigger should not do anything if the invoice that triggered it is not
in the Ready status (and perhaps just in that status, ie it shouldn't
do anything in the In-Process status or the received status or anything.
I haven't dug into the code to see if it is needed to add the option
that Jacopo mentioned. My opinion right now is that the current
behavior is wrong and should be corrected, ie the trigger shouldn't
cause payment capture for an invoice that isn't Ready.
-David