Implement an automatic GL posting service triggered when the ownerPartyId of an 
inventory item is changed
---------------------------------------------------------------------------------------------------------

                 Key: OFBIZ-1459
                 URL: https://issues.apache.org/jira/browse/OFBIZ-1459
             Project: OFBiz
          Issue Type: Sub-task
          Components: accounting
    Affects Versions: SVN trunk
            Reporter: Jacopo Cappellato


The name of the service can be "createAcctgTransForInventoryItemOwnerChange" or 
similar.
Input field: inventoryItemId, oldOwnerPartyId
Output field: acctgTransId 

We can use the following template for this service: 
createAcctgTransForShipmentReceipt in GeneralLedgerServices.xml 

The service will do the following tasks:
1) compute the origAmount as: origAmount = inventoryItem.quantityOnHandTotal * 
inventoryItem.unitCost
2) prepare 2 AcctgTransEntry (a debit and a credit) for the oldOwnerPartyId:
CREDIT: debitCreditFlag=C, glAcctgTransTypeId=INVENTORY_XFER_IN, 
productId=InventoryItem.productId, origAmount=(the value computed in 1), 
origCurrencyUomId=InventoryItem.currencyUomId, 
organizationPartyId=oldOwnerPartyId 
DEBIT: debitCreditFlag=D, glAcctgTransTypeId=INVENTORY_ACCOUNT, 
productId=InventoryItem.productId, origAmount=(the value computed in 1), 
origCurrencyUomId=InventoryItem.currencyUomId, 
organizationPartyId=oldOwnerPartyId 

3) prepare 2 AcctgTransEntry (a debit and a credit) for the 
inventoryItem.ownerPartyId:
CREDIT: debitCreditFlag=C, glAcctgTransTypeId=INVENTORY_ACCOUNT, 
productId=InventoryItem.productId, origAmount=(the value computed in 1), 
origCurrencyUomId=InventoryItem.currencyUomId, 
organizationPartyId=inventoryItem.ownerPartyId 
DEBIT: debitCreditFlag=D, glAcctgTransTypeId=INVENTORY_XFER_OUT, 
productId=InventoryItem.productId, origAmount=(the value computed in 1), 
origCurrencyUomId=InventoryItem.currencyUomId, 
organizationPartyId=inventoryItem.ownerPartyId

4) put the 4 entries in a list and call the createAcctgTransAndEntries service 
with the following fields: acctgTransTypeId=INVENTORY, acctgTransEntries=(the 
list with the 4 entries), inventoryItemId=parameters.inventoryItemId, 
glFiscalTypeId=ACTUAL 

The ECA will be:
<eca service="updateInventoryItem" event="commit">
    <condition field-name="ownerPartyId" operator="is-not-empty"/>
    <condition-field field-name="ownerPartyId" operator="not-equals" 
to-field-name="oldOwnerPartyId"/>
    <action service="createAcctgTransForInventoryItemOwnerChange" mode="sync"/>
</eca>

You can then test the service when you go into an Inventory Item in the 
facility, and change the ownerPartyId of an inventory item.



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to