You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by nm...@apache.org on 2021/09/17 15:08:46 UTC

[ofbiz-framework] branch trunk updated: Fixeded: Convert createInvoiceItemPayrol service from mini-lang to groovy DSL (OFBIZ-11503)

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

nmalin 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 aa9caa1  Fixeded: Convert createInvoiceItemPayrol service from mini-lang to groovy DSL (OFBIZ-11503)
aa9caa1 is described below

commit aa9caa1a2dcd264eab4a1aeffaeb87149f1f1077
Author: Nicolas Malin <ni...@nereide.fr>
AuthorDate: Fri Sep 17 17:08:26 2021 +0200

    Fixeded: Convert createInvoiceItemPayrol service from mini-lang to groovy DSL (OFBIZ-11503)
    
    Correct previous commit with remove empty file InvoiceEvents.xml, reoriented the function createInvoiceItemPayrol from InvoiceServices.groovy to new file InvoiceEvents.groovy
---
 .../groovyScripts/invoice/InvoiceEvents.groovy     | 55 ++++++++++++++++++++++
 .../groovyScripts/invoice/InvoiceServices.groovy   | 32 -------------
 .../accounting/minilang/invoice/InvoiceEvents.xml  | 25 ----------
 .../webapp/accounting/WEB-INF/controller.xml       |  2 +-
 4 files changed, 56 insertions(+), 58 deletions(-)

diff --git a/applications/accounting/groovyScripts/invoice/InvoiceEvents.groovy b/applications/accounting/groovyScripts/invoice/InvoiceEvents.groovy
new file mode 100644
index 0000000..76160e8
--- /dev/null
+++ b/applications/accounting/groovyScripts/invoice/InvoiceEvents.groovy
@@ -0,0 +1,55 @@
+package invoice
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.service.ServiceUtil
+
+//Create a new Invoice Item with Payrol Item Type
+def createInvoiceItemPayrol() {
+    List<GenericValue> payRolList = from("InvoiceItemType").queryList()
+    from("InvoiceItemType")
+            .where("parentTypeId", "PAYROL")
+            .queryList()
+            .each { payRolGroup ->
+                payRolList.each { payRol ->
+                    if (payRol.parentTypeId == payRolGroup.invoiceItemTypeId) {
+                        Map createInvoiceItem = [invoiceId        : parameters.invoiceId,
+                                                 invoiceItemTypeId: payRol.invoiceItemTypeId,
+                                                 description      : "${payRolGroup.description}: ${payRol.description}",
+                                                 quantity         : parameters."${payRol.invoiceItemTypeId}_Quantity" ?: 1d,
+                                                 amount           : parameters."${payRol.invoiceItemTypeId}_Amount" ?: 0d]
+
+                        if (parameters."${payRol.invoiceItemTypeId}_Quantity" ||
+                                parameters."${payRol.invoiceItemTypeId}_Amount") {
+                            if ("PAYROL_EARN_HOURS" != payRolGroup.invoiceItemTypeId) {
+                                createInvoiceItem.amount = createInvoiceItem.amount.negate()
+                            }
+                            Map serviceResult = run service: 'createInvoiceItem', with: createInvoiceItem
+                            if (ServiceUtil.isError(serviceResult)) {
+                                return serviceResult
+                            }
+                        }
+                    }
+                }
+            }
+
+    return  success()
+}
+
diff --git a/applications/accounting/groovyScripts/invoice/InvoiceServices.groovy b/applications/accounting/groovyScripts/invoice/InvoiceServices.groovy
index bf17d4b..5b3ee2b 100644
--- a/applications/accounting/groovyScripts/invoice/InvoiceServices.groovy
+++ b/applications/accounting/groovyScripts/invoice/InvoiceServices.groovy
@@ -128,35 +128,3 @@ def invoiceSequenceRestart() {
     return success(invoiceId: "${curYearString}-${partyAcctgPreference.lastInvoiceNumber}")
 }
 
-//Create a new Invoice Item with Payrol Item Type
-def createInvoiceItemPayrol() {
-    List<GenericValue> payRolList = from("InvoiceItemType").queryList()
-    from("InvoiceItemType")
-            .where("parentTypeId", "PAYROL")
-            .queryList()
-            .each { payRolGroup ->
-                payRolList.each { payRol ->
-                    if (payRol.parentTypeId == payRolGroup.invoiceItemTypeId) {
-                        Map createInvoiceItem = [invoiceId        : parameters.invoiceId,
-                                                 invoiceItemTypeId: payRol.invoiceItemTypeId,
-                                                 description      : "${payRolGroup.description}: ${payRol.description}",
-                                                 quantity         : parameters."${payRol.invoiceItemTypeId}_Quantity" ?: 1d,
-                                                 amount           : parameters."${payRol.invoiceItemTypeId}_Amount" ?: 0d]
-
-                        if (parameters."${payRol.invoiceItemTypeId}_Quantity" ||
-                                parameters."${payRol.invoiceItemTypeId}_Amount") {
-                            if ("PAYROL_EARN_HOURS" != payRolGroup.invoiceItemTypeId) {
-                                createInvoiceItem.amount = createInvoiceItem.amount.negate()
-                            }
-                            Map serviceResult = run service: 'createInvoiceItem', with: createInvoiceItem
-                            if (ServiceUtil.isError(serviceResult)) {
-                                return serviceResult
-                            }
-                        }
-                    }
-                }
-            }
-
-    return  success()
-}
-
diff --git a/applications/accounting/minilang/invoice/InvoiceEvents.xml b/applications/accounting/minilang/invoice/InvoiceEvents.xml
deleted file mode 100644
index b5d14aa..0000000
--- a/applications/accounting/minilang/invoice/InvoiceEvents.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements.  See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership.  The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License.  You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied.  See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
-    
-
-</simple-methods>
diff --git a/applications/accounting/webapp/accounting/WEB-INF/controller.xml b/applications/accounting/webapp/accounting/WEB-INF/controller.xml
index 8cfd63f..9e56720 100644
--- a/applications/accounting/webapp/accounting/WEB-INF/controller.xml
+++ b/applications/accounting/webapp/accounting/WEB-INF/controller.xml
@@ -187,7 +187,7 @@ under the License.
     </request-map>
     <request-map uri="createInvoiceItemPayrol">
         <security https="true" auth="true"/>
-        <event type="groovy" invoke="createInvoiceItemPayrol" path="component://accounting/groovyScripts/invoice/InvoiceServices.groovy"/>
+        <event type="groovy" invoke="createInvoiceItemPayrol" path="component://accounting/groovyScripts/invoice/InvoiceEvents.groovy"/>
         <response name="success" type="view" value="listInvoiceItems"/>
         <response name="error" type="view" value="listInvoiceItems"/>
     </request-map>