Implement an automatic GL posting service triggered when a physical inventory variance is performed ---------------------------------------------------------------------------------------------------
Key: OFBIZ-1458 URL: https://issues.apache.org/jira/browse/OFBIZ-1458 Project: OFBiz Issue Type: Sub-task Components: accounting Affects Versions: SVN trunk Reporter: Jacopo Cappellato The name of the service can be "createAcctgTransForPhysicalInventoryVariance" or similar. Input field: physicalInventoryId Output field: acctgTransId We can use the following template for this service: createAcctgTransForShipmentReceipt in GeneralLedgerServices.xml The service is triggered by a SECA rule on createPhysicalInventoryAndVariance The service will do the following tasks: 1) select all the InventoryItemDetails for the given physicalInventoryId 2) iterate the list of InventoryItemDetails and for each InventoryItemDetail: 2a) select the associated InventoryItem 2b) compute the following amount: origAmount = InventoryItemDetail.quantityOnHandDiff * InventoryItem.unitCost 2c) create one AcctgTransEntry for the credit: debitCreditFlag=C, glAcctgTransTypeId=InventoryItemDetail.reasonId, productId=InventoryItem.productId, origAmount=(the value computed in 2b), origCurrencyUomId=InventoryItem.currencyUomId, organizationPartyId=InventoryItem.ownerPartyId 2d) create one AcctgTransEntry for the debit: debitCreditFlag=D, glAcctgTransTypeId=INVENTORY_ACCOUNT, productId=InventoryItem.productId, origAmount=(the value computed in 2b), origCurrencyUomId=InventoryItem.currencyUomId, organizationPartyId=InventoryItem.ownerPartyId 2e) put the two entries in a list (go back to 2a) 3) when the iteration is done, call the createAcctgTransAndEntries with the following fields: acctgTransTypeId=ITEM_VARIANCE_ACCTG_, acctgTransEntries=(the list at 2e), physicalInventoryId=parameters.physicalInventoryId, glFiscalTypeId=ACTUAL the ECA will be: <eca service="createPhysicalInventoryAndVariance" event="commit"> <condition field-name="physicalInventoryId" operator="is-not-empty"/> <action service="createAcctgTransForPhysicalInventoryVariance" mode="sync"/> </eca> You can then test the service when you go into an Inventory Item in the facility, and perform a manual inventory variance. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.