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

        Jacopo Cappellato created issue -
        Jyotsna Rathore made changes -
        Field Original Value New Value
        Attachment glPosting1491.patch [ 12371139 ]
        Hide
        Pranay Pandey added a comment -

        Jyotsana,

        I have reviewed your patch according to the description given in the issue and did some small changes in it. The updated patch is attached. I will prefer that you just go through this patch once.

        Pranay

        Show
        Pranay Pandey added a comment - Jyotsana, I have reviewed your patch according to the description given in the issue and did some small changes in it. The updated patch is attached. I will prefer that you just go through this patch once. — Pranay
        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 ]
        Hide
        Pranay Pandey added a comment -

        There were some changes required to fulfill the requirement in the previous patch for this issue which are as follows :

        1. Calculation of Amount differece needs to be calculated out of the iterator.
        2. One debit entry needed to be taken out of the iterator.
        3. There were some problems related to field initializations.

        I have updated these points and the attaching the updated patch.

        Pranay

        Show
        Pranay Pandey added a comment - There were some changes required to fulfill the requirement in the previous patch for this issue which are as follows : 1. Calculation of Amount differece needs to be calculated out of the iterator. 2. One debit entry needed to be taken out of the iterator. 3. There were some problems related to field initializations. I have updated these points and the attaching the updated patch. – Pranay
        Pranay Pandey made changes -
        Attachment glPosting1491.patch [ 12372117 ]
        Hide
        Ashish Vijaywargiya added a comment -

        Thanks to Jyotsna Rathore and Pranay Pandey for your valuable patches.
        I had applied the recent patch from Pranay Pandey that resolve all the issues from the previous patch.

        Your patch is in rev # 606500.


        Ashish Vijaywargiya

        Show
        Ashish Vijaywargiya added a comment - Thanks to Jyotsna Rathore and Pranay Pandey for your valuable patches. I had applied the recent patch from Pranay Pandey that resolve all the issues from the previous patch. Your patch is in rev # 606500. – Ashish Vijaywargiya
        Ashish Vijaywargiya made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]
        Gavin made changes -
        Workflow jira [ 12418638 ] OFbiz Workflow [ 12505314 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        17d 6h 15m 1 Ashish Vijaywargiya 22/Dec/07 21:51

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development