1. OFBiz
  2. OFBIZ-1434 General Ledger
  3. OFBIZ-1491

Auto posting: Implement an automatic GL posting service for outgoing payments


    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: accounting
    • Labels:


      The service is very similar to the one described in OFBIZ-1490.

      Name of the service: "createAcctgTransAndEntriesForOutgoingPayment" or similar
      Service definition:
      <service name="createAcctgTransAndEntriesForOutgoingPayment" engine="simple" auth="true"
      location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransAndEntriesForOutgoingPayment">
      <description>Create an accounting transaction for an outgoing payment</description>
      <attribute name="paymentId" type="String" mode="IN" optional="false"/>
      <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>

      1) get the Payment by paymentId
      2) if (!UtilAccounting.isDisbursement(payment)) then return; (hint: in Minilang, use the "call-class-method" operation)
      3) organizationPartyId = payment.partyIdFrom
      4) partyId = payment.partyIdTo and roleTypeId = "BILL_FROM_VENDOR"

      5) create an AcctgTransEntry with:
      5.1) debitCreditFlag=C, glAccountTypeId: do not set for now (<!-TODO->), origAmount=payment.amount, origCurrencyUomId=payment.currencyUomId

      6) get the debitGlAccountTypeId in the following way:
      6.1) get the PaymentGlAccountTypeMap for the given Payment.paymentTypeId and organizationPartyId
      6.2) debitGlAccountTypeId = PaymentGlAccountTypeMap.glAccountTypeId

      7) for the debit entries: select the PaymentApplications associated to the Payment and for each one:
      7.1) create a AcctgTransEntry with:
      glAccountId=paymentApplication.overrideGlAccountId OR
      if (paymentApplication.taxAuthGeoId is not empty) get the glAccountId from the TaxAuthorityGlAccount record using as constraints organizationPartyId, taxAuthGeoId, taxAuthPartyId=partyId, OR
      7.2) amountAppliedTotal = amountAppliedTotal + paymentApplication.amountApplied
      8) if ((payment.amount - amountAppliedTotal) > 0) then create another debit entry with: debitCreditFlag=D, origAmount=(payment.amount - amountAppliedTotal), origCurrencyUomId=payment.currencyUomId, glAccountId=payment.overrideGlAccountId, glAccountTypeId=debitGlAccountTypeId

      9) call the createAcctgTransAndEntries with the following fields
      9.1) acctgTransEntries prepared at points 5, 7 and 8
      9.2) acctgTransTypeId="OUTGOING_PAYMENT"
      9.3) partyId e roleTypeId (point 4), paymentId

      Add the following secas to trigger the service:

      <eca service="createPayment" event="commit">
      <condition field-name="statusId" operator="equals" value="PMNT_SENT"/>
      <action service="createAcctgTransAndEntriesForOutgoingPayment" mode="sync"/>
      <eca service="setPaymentStatus" event="commit">
      <condition field-name="statusId" operator="equals" value="PMNT_SENT"/>
      <condition field-name="oldStatusId" operator="not-equals" value="PMNT_SENT"/>
      <action service="createAcctgTransAndEntriesForOutgoingPayment" mode="sync"/>

      1. glPosting1491.patch
        9 kB
        Jyotsna Rathore
      2. glPosting1491.patch
        9 kB
        Pranay Pandey
      3. glPosting1491.patch
        10 kB
        Pranay Pandey


        Jacopo Cappellato created issue -
        Jyotsna Rathore made changes -
        Field Original Value New Value
        Attachment glPosting1491.patch [ 12371139 ]
        Pranay Pandey made changes -
        Attachment glPosting1491.patch [ 12371194 ]
        Jacopo Cappellato made changes -
        Summary Implement an automatic GL posting service for outgoing payments Auto posting: Implement an automatic GL posting service for outgoing payments
        Ashish Vijaywargiya made changes -
        Assignee Ashish Vijaywargiya [ toashishvijay ]
        Pranay Pandey made changes -
        Attachment glPosting1491.patch [ 12372117 ]
        Ashish Vijaywargiya made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Gavin made changes -
        Workflow jira [ 12418638 ] OFbiz Workflow [ 12505314 ]


          • Assignee:
            Ashish Vijaywargiya
            Jacopo Cappellato
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: