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 4ff22b4 Improved: Convert getInvoicePaymentInfoListByDueDateOffset service from mini-lang to groovy DSL (OFBIZ-11486) 4ff22b4 is described below commit 4ff22b46dc12dbc57a37e1fd6c587c7d3efba0c0 Author: Jacques Le Roux <[hidden email]> AuthorDate: Sun Aug 9 20:14:10 2020 +0200 Improved: Convert getInvoicePaymentInfoListByDueDateOffset service from mini-lang to groovy DSL (OFBIZ-11486) Thanks: Devanshu Vyas for report, Nitish Mishra for the patch --- .../groovyScripts/payment/PaymentServices.groovy | 43 ++++++++++++++++++++++ .../minilang/payment/PaymentServices.xml | 39 -------------------- .../accounting/servicedef/services_payment.xml | 4 +- 3 files changed, 45 insertions(+), 41 deletions(-) diff --git a/applications/accounting/groovyScripts/payment/PaymentServices.groovy b/applications/accounting/groovyScripts/payment/PaymentServices.groovy index 40ab002..3918b99 100644 --- a/applications/accounting/groovyScripts/payment/PaymentServices.groovy +++ b/applications/accounting/groovyScripts/payment/PaymentServices.groovy @@ -319,6 +319,49 @@ def massChangePaymentStatus() { } return serviceResult } +def getInvoicePaymentInfoListByDueDateOffset(){ + + filteredInvoicePaymentInfoList = [] + + Timestamp asOfDate = UtilDateTime.getDayEnd(UtilDateTime.nowTimestamp(), (long) parameters.daysOffset); + + exprList = [EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, parameters.invoiceTypeId), + EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "INVOICE_CANCELLED"), + EntityCondition.makeCondition("statusId", EntityOperator.NOT_EQUAL, "INVOICE_PAID") + ] + if (parameters.partyId) { + exprList.add(EntityCondition.makeCondition("partyId", EntityOperator.EQUALS, parameters.partyId)) + } + if (parameters.partyIdFrom) { + exprList.add(EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, parameters.partyIdFrom)) + } + + condition = EntityCondition.makeCondition(exprList, EntityOperator.AND); + + invoices = from("Invoice").where(condition).orderBy("invoiceDate").queryList(); + + if (invoices) { + for (GenericValue invoice : invoices) { + getInvoicePaymentInfoListInMap = [:] + getInvoicePaymentInfoListInMap.put("invoice", invoice); + getInvoicePaymentInfoListInMap.put("userLogin", userLogin); + serviceResult = run service: 'getInvoicePaymentInfoList', with: getInvoicePaymentInfoListInMap + if (ServiceUtil.isError(serviceResult)) return result + invoicePaymentInfoList = serviceResult.invoicePaymentInfoList; + if (invoicePaymentInfoList) { + invoicePaymentInfoList.each { invoicePaymentInfo -> + if (invoicePaymentInfo.outstandingAmount.compareTo(BigDecimal.ZERO) > 0 && invoicePaymentInfo.dueDate.before(asOfDate)) { + filteredInvoicePaymentInfoList.add(invoicePaymentInfo); + } + } + } + } + } + + result = success() + result.invoicePaymentInfoList = filteredInvoicePaymentInfoList + return result +} def getPaymentGroupReconciliationId() { paymentGroupMember = from("PaymentGroupMember").where("paymentGroupId", parameters.paymentGroupId).queryFirst() diff --git a/applications/accounting/minilang/payment/PaymentServices.xml b/applications/accounting/minilang/payment/PaymentServices.xml index 4d7bc1e..7040268 100644 --- a/applications/accounting/minilang/payment/PaymentServices.xml +++ b/applications/accounting/minilang/payment/PaymentServices.xml @@ -228,45 +228,6 @@ under the License. </if-compare-field> </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"> - <field field="nowTimestamp" type="Timestamp"/> - <field field="parameters.daysOffset" type="Long"/> - </call-class-method> - <entity-condition entity-name="Invoice" list="invoices"> - <condition-list combine="and"> - <condition-expr field-name="invoiceTypeId" operator="equals" from-field="parameters.invoiceTypeId"/> - <condition-expr field-name="partyId" operator="equals" from-field="parameters.partyId" ignore-if-empty="true"/> - <condition-expr field-name="partyIdFrom" operator="equals" from-field="parameters.partyIdFrom" ignore-if-empty="true"/> - <condition-expr field-name="statusId" operator="not-equals" value="INVOICE_CANCELLED"/> - <condition-expr field-name="statusId" operator="not-equals" value="INVOICE_PAID"/> - </condition-list> - <order-by field-name="invoiceDate"/> - </entity-condition> - <iterate list="invoices" entry="invoice"> - <clear-field field="getInvoicePaymentInfoListInMap"/> - <set field="getInvoicePaymentInfoListInMap.invoice" from-field="invoice"/> - <call-service service-name="getInvoicePaymentInfoList" in-map-name="getInvoicePaymentInfoListInMap"> - <result-to-field result-name="invoicePaymentInfoList" field="invoicePaymentInfoList"/> - </call-service> - <iterate list="invoicePaymentInfoList" entry="invoicePaymentInfo"> - <if> - <condition> - <and> - <if-compare field="invoicePaymentInfo.outstandingAmount" operator="greater" value="0.0" type="BigDecimal"/> - <if-compare-field field="invoicePaymentInfo.dueDate" to-field="asOfDate" operator="less" type="Timestamp"/> - </and> - </condition> - <then> - <set field="selectedInvoicePaymentInfoList[]" from-field="invoicePaymentInfo"/> - </then> - </if> - </iterate> - </iterate> - <field-to-result field="selectedInvoicePaymentInfoList" result-name="invoicePaymentInfoList"/> - </simple-method> - <simple-method method-name="voidPayment" short-description="Service to void a payment"> <entity-one entity-name="Payment" value-field="payment"/> <field-to-result field="payment.finAccountTransId" result-name="finAccountTransId"/> diff --git a/applications/accounting/servicedef/services_payment.xml b/applications/accounting/servicedef/services_payment.xml index 5579568..3353bd8 100644 --- a/applications/accounting/servicedef/services_payment.xml +++ b/applications/accounting/servicedef/services_payment.xml @@ -133,8 +133,8 @@ under the License. <attribute name="invoice" type="org.apache.ofbiz.entity.GenericValue" mode="IN" optional="true"/> <attribute name="invoicePaymentInfoList" type="List" mode="OUT" optional="false"/> </service> - <service name="getInvoicePaymentInfoListByDueDateOffset" engine="simple" - location="component://accounting/minilang/payment/PaymentServices.xml" invoke="getInvoicePaymentInfoListByDueDateOffset" auth="true"> + <service name="getInvoicePaymentInfoListByDueDateOffset" engine="groovy" + location="component://accounting/groovyScripts/payment/PaymentServices.groovy" invoke="getInvoicePaymentInfoListByDueDateOffset" auth="true"> <description>Create a list with information on payment due dates and amounts.</description> <attribute name="invoiceTypeId" type="String" mode="IN" optional="false"/> <attribute name="daysOffset" type="Long" mode="IN" optional="false"/> |
Free forum by Nabble | Edit this page |