You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2020/07/09 12:18:36 UTC

[ofbiz-framework] branch trunk updated: Improved: Convert getPaymentGroupReconciliationId service from mini-lang to groovy DSL (OFBIZ-11496) Thanks: Devanshu Vyas for report and Rohit Koushal for the patch

This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 7c4a117  Improved: Convert getPaymentGroupReconciliationId service from mini-lang to groovy DSL (OFBIZ-11496) Thanks: Devanshu Vyas for report and Rohit Koushal for the patch
7c4a117 is described below

commit 7c4a117448429be6bd9f9d435d21cbd0bbe81d44
Author: Jacques Le Roux <ja...@les7arts.com>
AuthorDate: Thu Jul 9 13:56:36 2020 +0200

    Improved: Convert getPaymentGroupReconciliationId service from mini-lang to groovy DSL (OFBIZ-11496)
    Thanks: Devanshu Vyas for report and Rohit Koushal for the patch
    
    Improved: Convert createPaymentAndApplication service from mini-lang to groovy DSL (OFBIZ-11484)
    Thanks: Devanshu Vyas for report and Anushi Gupta for the patch
    
    Sorry due to a bad handling there are 2 commits in one (squashed)
---
 .../groovyScripts/payment/PaymentServices.groovy   | 34 ++++++++++++++++++++++
 .../minilang/payment/PaymentServices.xml           | 34 ----------------------
 .../accounting/servicedef/services_payment.xml     |  8 ++---
 3 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/applications/accounting/groovyScripts/payment/PaymentServices.groovy b/applications/accounting/groovyScripts/payment/PaymentServices.groovy
index 02846d7..b3b6b6a 100644
--- a/applications/accounting/groovyScripts/payment/PaymentServices.groovy
+++ b/applications/accounting/groovyScripts/payment/PaymentServices.groovy
@@ -320,6 +320,40 @@ def massChangePaymentStatus() {
     return serviceResult
 }
 
+def getPaymentGroupReconciliationId() {
+    paymentGroupMember = from("PaymentGroupMember").where("paymentGroupId", parameters.paymentGroupId).queryFirst()
+    glReconciliationId = null;
+    Map result = success()
+    if (paymentGroupMember) {
+        payment = paymentGroupMember.getRelatedOne('Payment', false)
+        finAccountTrans = payment.getRelatedOne('FinAccountTrans', false)
+        if (finAccountTrans) {
+            glReconciliationId = finAccountTrans.glReconciliationId
+        }
+    }
+    result.glReconciliationId = glReconciliationId
+    return result
+}
+
+def createPaymentAndApplication() {
+    Map result = success()
+    Map createPaymentCtx = dispatcher.getDispatchContext().makeValidContext('createPayment', 'IN', parameters)
+    Map createPaymentResp = dispatcher.runSync('createPayment', createPaymentCtx)
+
+    if (ServiceUtil.isError(createPaymentResp)) return createPaymentResp
+
+    Map createPaymentApplicationCtx = dispatcher.getDispatchContext().makeValidContext('createPaymentApplication', 'IN', parameters)
+    createPaymentApplicationCtx.paymentId = createPaymentResp.paymentId
+    createPaymentApplicationCtx.amountApplied = parameters.amount
+    Map createPaymentApplicationResp = dispatcher.runSync('createPaymentApplication', createPaymentApplicationCtx)
+
+    if (ServiceUtil.isError(createPaymentApplicationResp)) return createPaymentApplicationResp
+
+    result.put("paymentId", createPaymentResp.paymentId)
+    result.put("paymentApplicationId", createPaymentApplicationResp.paymentApplicationId)
+    return result
+
+}
 
 def createFinAccoutnTransFromPayment() {
     serviceResult = success()
diff --git a/applications/accounting/minilang/payment/PaymentServices.xml b/applications/accounting/minilang/payment/PaymentServices.xml
index a848315..eb05f11 100644
--- a/applications/accounting/minilang/payment/PaymentServices.xml
+++ b/applications/accounting/minilang/payment/PaymentServices.xml
@@ -228,23 +228,6 @@ under the License.
         </if-compare-field>
     </simple-method>
 
-    <simple-method method-name="createPaymentAndApplication" short-description="Create a payment and a payment application for the full amount">
-        <set-service-fields service-name="createPayment" map="parameters" to-map="createPaymentInMap"/>
-        <call-service service-name="createPayment" in-map-name="createPaymentInMap">
-            <result-to-field result-name="paymentId" field="paymentId"/>
-        </call-service>
-        <check-errors/>
-        <set-service-fields service-name="createPaymentApplication" map="parameters" to-map="createPaymentAppInMap"/>
-        <set field="createPaymentAppInMap.paymentId" from-field="paymentId"/>
-        <set field="createPaymentAppInMap.amountApplied" from-field="parameters.amount"/>
-        <call-service service-name="createPaymentApplication" in-map-name="createPaymentAppInMap">
-            <result-to-field result-name="paymentApplicationId" field="paymentApplicationId"/>
-        </call-service>
-        <check-errors/>
-        <field-to-result field="paymentId" result-name="paymentId"/>
-        <field-to-result field="paymentApplicationId" result-name="paymentApplicationId"/>
-    </simple-method>
-
     <simple-method method-name="getInvoicePaymentInfoListByDueDateOffset" short-description="Select a list with information on payment due dates and amounts for invoices.">
         <now-timestamp field="nowTimestamp"/>
         <call-class-method class-name="org.apache.ofbiz.base.util.UtilDateTime" method-name="getDayEnd" ret-field="asOfDate">
@@ -431,23 +414,6 @@ under the License.
         </if-compare>
     </simple-method>
 
-    <simple-method method-name="getPaymentGroupReconciliationId" short-description="Get ReconciliationId associated to paymentGroup">
-        <set field="paymentGroupId" from-field="parameters.paymentGroupId"/>
-        <entity-and entity-name="PaymentGroupMember" list="paymentGroupMembers">
-            <field-map field-name="paymentGroupId"/>
-        </entity-and>
-        <if-not-empty field="paymentGroupMembers">
-            <first-from-list list="paymentGroupMembers" entry="paymentGroupMember"/>
-            <get-related-one relation-name="Payment" value-field="paymentGroupMember" to-value-field="payment"/>
-            <get-related-one relation-name="FinAccountTrans" value-field="payment" to-value-field="finAccountTrans"/>
-            <if-not-empty field="finAccountTrans">
-                <if-not-empty field="finAccountTrans.glReconciliationId">
-                    <set field="glReconciliationId" from-field="finAccountTrans.glReconciliationId"/>
-                </if-not-empty>
-            </if-not-empty>
-        </if-not-empty>
-        <field-to-result field="glReconciliationId"/>
-    </simple-method>
     <simple-method method-name="checkAndCreateBatchForValidPayments" short-description="Check the valid(unbatched) payment and create batch for same">
         <set field="paymentIds" from-field="parameters.paymentIds"/>
         <entity-condition entity-name="Payment" list="payments">
diff --git a/applications/accounting/servicedef/services_payment.xml b/applications/accounting/servicedef/services_payment.xml
index 0e44ee4..5a4d03a 100644
--- a/applications/accounting/servicedef/services_payment.xml
+++ b/applications/accounting/servicedef/services_payment.xml
@@ -108,8 +108,8 @@ under the License.
         <auto-attributes mode="OUT" include="nonpk" optional="true"/>
     </service>
 
-    <service name="createPaymentAndApplication" engine="simple"
-            location="component://accounting/minilang/payment/PaymentServices.xml" invoke="createPaymentAndApplication" auth="true">
+    <service name="createPaymentAndApplication" engine="groovy"
+            location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="createPaymentAndApplication" auth="true">
         <description>Create a payment and a payment application for the full amount</description>
         <auto-attributes entity-name="Payment" include="nonpk" mode="IN" optional="true"/>
         <auto-attributes entity-name="Payment" include="pk" mode="INOUT" optional="true"/>
@@ -214,8 +214,8 @@ under the License.
         <attribute name="finAccountTransId" type="String" mode="IN" optional="true"/>
         <attribute name="payments" type="List" mode="OUT" optional="true"/>
     </service>
-    <service name="getPaymentGroupReconciliationId" engine="simple"
-            location="component://accounting/minilang/payment/PaymentServices.xml" invoke="getPaymentGroupReconciliationId" auth="true">
+    <service name="getPaymentGroupReconciliationId" engine="groovy"
+            location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="getPaymentGroupReconciliationId" auth="true">
         <description>Get ReconciliationId associated to paymentGroup</description>
         <attribute name="paymentGroupId" type="String" mode="IN" optional="false"/>
         <attribute name="glReconciliationId" type="String" mode="OUT" optional="true"/>