Hi,

I am working on an extension to Ofbiz that allows to manage a bonus currency
and use it for discounts in the eCommerce module. I create a special account
for each user and write the respective transactions to it. In more detail: I
create a transaction that reserves the respective amount on the account when
an order is submitted. When the order is invoiced I simpley change the
status of the transaction to mark that the amount has been invoiced. I
implemented this using the SECAs. Now I wanted to complete my implementation
by also reverting an ordered/invoiced transaction in case the order is
refunded. Doing this, I discovered that my SECA conditions are not
restrictive enough and the services used to post transactions to the account
are called again. Furthermore, it seems that the OrderBillingItems are
deleted if an order is refunded?! This was a suprise since I expected that
they would just undergo a status change. My question now is: What should my
SECA conditions look like to only get triggered once when the order is
initially created (SECA 1) and once when the order is invoiced (SECA 2)? And
what would be the best way to revert transactions when an order is refunded?

Furthermore I would appreciate any remark on my approach. Here are the SECAs
I currently use (copied from other parts of Ofbiz):

SECA 1:
<eca service="changeOrderStatus" event="commit" run-on-error="false">
        <condition field-name="statusId" operator="equals"
value="ORDER_APPROVED"/>
        <condition field-name="orderTypeId" operator="equals"
value="SALES_ORDER"/>
        <condition-field field-name="statusId" operator="not-equals"
to-field-name="oldStatusId"/>
        <action service="postOrderToMilesAccount" mode="sync"/>
    </eca>

SECA 2:
<eca service="setInvoiceStatus" event="commit">
        <condition field-name="invoiceId" operator="is-not-empty"/>
        <condition field-name="statusId" operator="equals"
value="INVOICE_READY"/>
        <condition field-name="oldStatusId" operator="not-equals"
value="INVOICE_READY"/>

        <!-- Don't repost the transaction if the invoice is reverting from
PAID to READY due to a voided payment -->
        <condition field-name="oldStatusId" operator="not-equals"
value="INVOICE_PAID"/>
        <action service="postInvoiceToMilesAccount" mode="sync"
run-as-user="system"/>
</eca>
    
Regards,
Benni
    
-- 
View this message in context: 
http://www.nabble.com/Hooking-in-into-order-processing-tp22725572p22725572.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to