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/05/31 06:52:24 UTC

[ofbiz-framework] 12/28: Improved: Converted massChangePaymentStatus service from mini-lang to groovy. (OFBIZ-11498) Thanks Devanshu Vyas for reporting and Rushikesh Mawal for initial patch.

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

jleroux pushed a commit to branch ecomify-OFBIZ-11468_Convert_ShipmentReceiptServices-squashed
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit d0fb482257128b5471bb71f15218fcd6057a495c
Author: Suraj Khurana <su...@apache.org>
AuthorDate: Sat May 23 15:23:13 2020 +0530

    Improved: Converted massChangePaymentStatus service from mini-lang to groovy.
    (OFBIZ-11498)
    Thanks Devanshu Vyas for reporting and Rushikesh Mawal for initial patch.
---
 .../accounting/groovyScripts/payment/PaymentServices.groovy | 13 +++++++++++++
 .../accounting/minilang/payment/PaymentServices.xml         | 10 ----------
 applications/accounting/servicedef/services_payment.xml     |  4 ++--
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/applications/accounting/groovyScripts/payment/PaymentServices.groovy b/applications/accounting/groovyScripts/payment/PaymentServices.groovy
index c28ce07..212207d 100644
--- a/applications/accounting/groovyScripts/payment/PaymentServices.groovy
+++ b/applications/accounting/groovyScripts/payment/PaymentServices.groovy
@@ -133,4 +133,17 @@ def updatePaymentContent() {
         return ServiceUtil.returnError("Error getting Payment Content")
     }
 }
+def massChangePaymentStatus() {
+    serviceResult = success()
+    Map setPaymentStatusMap = [:]
+    parameters.paymentIds.each{ paymentId ->
+        setPaymentStatusMap.paymentId = paymentId
+        setPaymentStatusMap.statusId = parameters.statusId
+        setPaymentStatusMap.userLogin = parameters.userLogin
+        result = run service: 'setPaymentStatus', with: setPaymentStatusMap
+        if (ServiceUtil.isError(result)) return result
+        setPaymentStatusMap.clear()
+    }
+    return serviceResult
+}
 
diff --git a/applications/accounting/minilang/payment/PaymentServices.xml b/applications/accounting/minilang/payment/PaymentServices.xml
index 1c32621..ae862251 100644
--- a/applications/accounting/minilang/payment/PaymentServices.xml
+++ b/applications/accounting/minilang/payment/PaymentServices.xml
@@ -785,16 +785,6 @@ under the License.
         </else>
         </if-not-empty>
     </simple-method>
-
-    <simple-method method-name="massChangePaymentStatus" short-description="Service set status of Payments in bulk.">
-        <iterate list="parameters.paymentIds" entry="paymentId">
-            <set field="setPaymentStatusMap.paymentId" from-field="paymentId"/>
-            <set field="setPaymentStatusMap.statusId" from-field="parameters.statusId"/>
-            <call-service service-name="setPaymentStatus" in-map-name="setPaymentStatusMap"/>
-            <clear-field field="setPaymentStatusMap"/>
-        </iterate>
-    </simple-method>
-
     <simple-method method-name="createPaymentFromOrder" short-description="Service auto create Payment from Order when payment does exist yet and not disabled by accounting config">
         <entity-one entity-name="OrderHeader" value-field="orderHeader"/>
 
diff --git a/applications/accounting/servicedef/services_payment.xml b/applications/accounting/servicedef/services_payment.xml
index dd9b2cd..e1c8344 100644
--- a/applications/accounting/servicedef/services_payment.xml
+++ b/applications/accounting/servicedef/services_payment.xml
@@ -227,8 +227,8 @@ under the License.
         <implements service="createPaymentGroupAndMember"/>
     </service>
     
-    <service name="massChangePaymentStatus" engine="simple"
-            location="component://accounting/minilang/payment/PaymentServices.xml" invoke="massChangePaymentStatus" auth="true">
+    <service name="massChangePaymentStatus" engine="groovy"
+        location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="massChangePaymentStatus" auth="true">
         <description>Set status of Payments in bulk.</description>
         <attribute name="paymentIds" type="List" mode="IN" optional="false"/>
         <attribute name="statusId" type="String" mode="IN" optional="false"/>