[ 
https://issues.apache.org/jira/browse/OFBIZ-1490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jacopo Cappellato updated OFBIZ-1490:
-------------------------------------

    Description: 
Name of the service: "createAcctgTransAndEntriesForIncomingPayment" or similar
Service definition:
    <service name="createAcctgTransAndEntriesForIncomingPayment" 
engine="simple" auth="true"
        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" 
invoke="createAcctgTransAndEntriesForIncomingPayment">
        <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.isReceipt(payment)) then return; (hint: in Minilang, use 
the "call-class-method" operation)
3) organizationPartyId = payment.partyIdTo
4) partyId = payment.partyIdFrom and roleTypeId = "BILL_TO_CUSTOMER"
5) create an AcctgTransEntry with:
5.1) debitCreditFlag=D, glAccountTypeId: do not set for now (<!--TODO-->), 
origAmount=payment.amount, origCurrencyUomId=payment.currencyUomId

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

7) for the credit entries: select the PaymentApplications associated to the 
Payment and for each one:
7.1) create a AcctgTransEntry with: debitCreditFlag=C, 
origAmount=paymentApplication.amountApplied, 
origCurrencyUomId=payment.currencyUomId, 
glAccountId=paymentApplication.overrideGlAccountId or (if empty) 
payment.overrideGlAccountId, glAccountTypeId=creditGlAccountTypeId
7.2) amountAppliedTotal = amountAppliedTotal + paymentApplication.amountApplied
8) if ((payment.amount - amountAppliedTotal) > 0) then create another credit 
entry with: debitCreditFlag=C, origAmount=(payment.amount - 
amountAppliedTotal), origCurrencyUomId=payment.currencyUomId, 
glAccountId=payment.overrideGlAccountId, glAccountTypeId=creditGlAccountTypeId

9) call the createAcctgTransAndEntries with the following fields
9.1) acctgTransEntries prepared at points 5, 7 and 8
9.2) acctgTransTypeId="INCOMING_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_RECEIVED"/>
    <action service="createAcctgTransAndEntriesForIncomingPayment" mode="sync"/>
</eca>
<eca service="setPaymentStatus" event="commit">
    <condition field-name="statusId" operator="equals" value="PMNT_RECEIVED"/>
    <condition field-name="oldStatusId" operator="not-equals" 
value="PMNT_RECEIVED"/>
    <action service="createAcctgTransAndEntriesForIncomingPayment" mode="sync"/>
</eca>


  was:
Name of the service: "createAcctgTransAndEntriesForIncomingPayment" or similar
Service definition:
    <service name="createAcctgTransAndEntriesForIncomingPayment" 
engine="simple" auth="true"
        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" 
invoke="createAcctgTransAndEntriesForIncomingPayment">
        <description>Create an accounting transaction for a purchase 
invoice</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.isReceipt(payment)) then return; (hint: in Minilang, use 
the "call-class-method" operation)
3) organizationPartyId = payment.partyIdTo
4) partyId = payment.partyIdFrom and roleTypeId = "BILL_TO_CUSTOMER"
5) create an AcctgTransEntry with:
5.1) debitCreditFlag=D, glAccountTypeId: do not set for now (<!--TODO-->), 
origAmount=payment.amount, origCurrencyUomId=payment.currencyUomId

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

7) for the credit entries: select the PaymentApplications associated to the 
Payment and for each one:
7.1) create a AcctgTransEntry with: debitCreditFlag=C, 
origAmount=paymentApplication.amountApplied, 
origCurrencyUomId=payment.currencyUomId, 
glAccountId=paymentApplication.overrideGlAccountId or (if empty) 
payment.overrideGlAccountId, glAccountTypeId=creditGlAccountTypeId
7.2) amountAppliedTotal = amountAppliedTotal + paymentApplication.amountApplied
8) if ((payment.amount - amountAppliedTotal) > 0) then create another credit 
entry with: debitCreditFlag=C, origAmount=(payment.amount - 
amountAppliedTotal), origCurrencyUomId=payment.currencyUomId, 
glAccountId=payment.overrideGlAccountId, glAccountTypeId=creditGlAccountTypeId

9) call the createAcctgTransAndEntries with the following fields
9.1) acctgTransEntries prepared at points 5, 7 and 8
9.2) acctgTransTypeId="INCOMING_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_RECEIVED"/>
    <action service="createAcctgTransAndEntriesForIncomingPayment" mode="sync"/>
</eca>
<eca service="setPaymentStatus" event="commit">
    <condition field-name="statusId" operator="equals" value="PMNT_RECEIVED"/>
    <condition field-name="oldStatusId" operator="not-equals" 
value="PMNT_RECEIVED"/>
    <action service="createAcctgTransAndEntriesForIncomingPayment" mode="sync"/>
</eca>



> Implement an automatic GL posting service for incoming payments
> ---------------------------------------------------------------
>
>                 Key: OFBIZ-1490
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-1490
>             Project: OFBiz
>          Issue Type: Sub-task
>          Components: accounting
>    Affects Versions: SVN trunk
>            Reporter: Jacopo Cappellato
>
> Name of the service: "createAcctgTransAndEntriesForIncomingPayment" or similar
> Service definition:
>     <service name="createAcctgTransAndEntriesForIncomingPayment" 
> engine="simple" auth="true"
>         location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" 
> invoke="createAcctgTransAndEntriesForIncomingPayment">
>         <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.isReceipt(payment)) then return; (hint: in Minilang, 
> use the "call-class-method" operation)
> 3) organizationPartyId = payment.partyIdTo
> 4) partyId = payment.partyIdFrom and roleTypeId = "BILL_TO_CUSTOMER"
> 5) create an AcctgTransEntry with:
> 5.1) debitCreditFlag=D, glAccountTypeId: do not set for now (<!--TODO-->), 
> origAmount=payment.amount, origCurrencyUomId=payment.currencyUomId
> 6) get the creditGlAccountTypeId in the following way:
> 6.1) get the PaymentGlAccountTypeMap for the given Payment.paymentTypeId and 
> organizationPartyId
> 6.2) creditGlAccountTypeId = PaymentGlAccountTypeMap.glAccountTypeId
> 7) for the credit entries: select the PaymentApplications associated to the 
> Payment and for each one:
> 7.1) create a AcctgTransEntry with: debitCreditFlag=C, 
> origAmount=paymentApplication.amountApplied, 
> origCurrencyUomId=payment.currencyUomId, 
> glAccountId=paymentApplication.overrideGlAccountId or (if empty) 
> payment.overrideGlAccountId, glAccountTypeId=creditGlAccountTypeId
> 7.2) amountAppliedTotal = amountAppliedTotal + 
> paymentApplication.amountApplied
> 8) if ((payment.amount - amountAppliedTotal) > 0) then create another credit 
> entry with: debitCreditFlag=C, origAmount=(payment.amount - 
> amountAppliedTotal), origCurrencyUomId=payment.currencyUomId, 
> glAccountId=payment.overrideGlAccountId, glAccountTypeId=creditGlAccountTypeId
> 9) call the createAcctgTransAndEntries with the following fields
> 9.1) acctgTransEntries prepared at points 5, 7 and 8
> 9.2) acctgTransTypeId="INCOMING_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_RECEIVED"/>
>     <action service="createAcctgTransAndEntriesForIncomingPayment" 
> mode="sync"/>
> </eca>
> <eca service="setPaymentStatus" event="commit">
>     <condition field-name="statusId" operator="equals" value="PMNT_RECEIVED"/>
>     <condition field-name="oldStatusId" operator="not-equals" 
> value="PMNT_RECEIVED"/>
>     <action service="createAcctgTransAndEntriesForIncomingPayment" 
> mode="sync"/>
> </eca>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to