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

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

    Details

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

      Description

      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"/>
      </service>

      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:
      debitCreditFlag=D,
      origAmount=paymentApplication.amountApplied,
      origCurrencyUomId=payment.currencyUomId,
      glAccountTypeId=debitGlAccountTypeId,
      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
      payment.overrideGlAccountId
      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>
      <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"/>
      </eca>

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

        Activity

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development