Uploaded image for project: 'OFBiz'
  1. OFBiz
  2. OFBIZ-1434 General Ledger
  3. OFBIZ-1459

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

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Trunk
    • None
    • accounting
    • None

    Description

      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.

      Attachments

        Activity

          People

            anilpatel Anil K Patel
            jacopoc Jacopo Cappellato
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: