This is an automated email from the ASF dual-hosted git repository.
pawan 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 6de4b73 Improved: Convert getPayments service from mini-lang to groovy DSL(OFBIZ-11495) 6de4b73 is described below commit 6de4b730742e2fe6d4a0bc56e22e402912c1e2f1 Author: Pawan Verma <[hidden email]> AuthorDate: Wed Jul 1 16:13:33 2020 +0530 Improved: Convert getPayments service from mini-lang to groovy DSL(OFBIZ-11495) Thanks: Devanshu for the report and Yogesh for the patch. --- .../groovyScripts/payment/PaymentServices.groovy | 19 ++++++++++++++++++- .../accounting/minilang/payment/PaymentServices.xml | 20 -------------------- .../accounting/servicedef/services_payment.xml | 4 ++-- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/applications/accounting/groovyScripts/payment/PaymentServices.groovy b/applications/accounting/groovyScripts/payment/PaymentServices.groovy index 7375a59..d416292 100644 --- a/applications/accounting/groovyScripts/payment/PaymentServices.groovy +++ b/applications/accounting/groovyScripts/payment/PaymentServices.groovy @@ -321,4 +321,21 @@ def cancelPaymentBatch() { } } } -} \ No newline at end of file +} + +def getPayments() { + payments = [] + if (parameters.paymentGroupId) { + paymentGroupMembers = from("PaymentGroupMember").where("paymentGroupId", parameters.paymentGroupId).filterByDate().queryList() + if (paymentGroupMembers) { + paymentIds = EntityUtil.getFieldListFromEntityList(paymentGroupMembers, "paymentId", true) + payments = from("Payment").where(EntityCondition.makeCondition("paymentId", EntityOperator.IN, paymentIds)).queryList() + } + } + if (parameters.finAccountTransId) { + payments = from("Payment").where("finAccountTransId", parameters.finAccountTransId).queryList() + } + result = success() + result.payments = payments + return result +} diff --git a/applications/accounting/minilang/payment/PaymentServices.xml b/applications/accounting/minilang/payment/PaymentServices.xml index d30eaa3..9f059cb 100644 --- a/applications/accounting/minilang/payment/PaymentServices.xml +++ b/applications/accounting/minilang/payment/PaymentServices.xml @@ -537,26 +537,6 @@ under the License. </if-compare> </simple-method> - <simple-method method-name="getPayments" short-description="Get list of payment"> - <set field="paymentGroupId" from-field="parameters.paymentGroupId"/> - <if-not-empty field="paymentGroupId"> - <entity-and entity-name="PaymentGroupMember" list="paymentGroupMembers" filter-by-date="true"> - <field-map field-name="paymentGroupId"/> - </entity-and> - <set field="paymentIds" value="${groovy:org.apache.ofbiz.entity.util.EntityUtil.getFieldListFromEntityList(paymentGroupMembers, 'paymentId', true);}" type="List"/> - <entity-condition entity-name="Payment" list="payments"> - <condition-expr field-name="paymentId" operator="in" from-field="paymentIds"/> - </entity-condition> - </if-not-empty> - <set field="finAccountTransId" from-field="parameters.finAccountTransId"/> - <if-not-empty field="finAccountTransId"> - <entity-and entity-name="Payment" list="payments"> - <field-map field-name="finAccountTransId"/> - </entity-and> - </if-not-empty> - <field-to-result field="payments"/> - </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"> diff --git a/applications/accounting/servicedef/services_payment.xml b/applications/accounting/servicedef/services_payment.xml index 77f80df..8a0dae3 100644 --- a/applications/accounting/servicedef/services_payment.xml +++ b/applications/accounting/servicedef/services_payment.xml @@ -207,8 +207,8 @@ under the License. <auto-attributes entity-name="FinAccountTrans" include="pk" mode="INOUT" optional="true"/> <attribute name="invoiceIds" type="List" mode="IN" optional="true"/> </service> - <service name="getPayments" engine="simple" - location="component://accounting/minilang/payment/PaymentServices.xml" invoke="getPayments" auth="true"> + <service name="getPayments" engine="groovy" + location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="getPayments" auth="true"> <description>Get list of payment</description> <attribute name="paymentGroupId" type="String" mode="IN" optional="true"/> <attribute name="finAccountTransId" type="String" mode="IN" optional="true"/> |
Free forum by Nabble | Edit this page |