Improved: Convert getPayments service from mini-lang to groovy DSL(OFBIZ-11495)

Thanks: Devanshu for the report and Yogesh for the patch.
This commit is contained in:
Pawan Verma
2020-07-01 16:13:33 +05:30
parent 9e97730288
commit 6de4b73074
3 changed files with 20 additions and 23 deletions
@@ -321,4 +321,21 @@ def cancelPaymentBatch() {
}
}
}
}
}
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
}
@@ -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">
@@ -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"/>