[ofbiz-framework] branch trunk updated: Improved: Converted all AcctgTrans related CRUD services from simple to entity-auto (#103)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated: Improved: Converted all AcctgTrans related CRUD services from simple to entity-auto (#103)

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

surajk 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 10a8f7a  Improved: Converted all AcctgTrans related CRUD services from simple to entity-auto (#103)
10a8f7a is described below

commit 10a8f7a0931d898d3d9f701012efd93ab960f1d7
Author: Suraj Khurana <[hidden email]>
AuthorDate: Sun May 10 16:05:54 2020 +0530

    Improved: Converted all AcctgTrans related CRUD services from simple to entity-auto (#103)
   
    * Improved: Converted all AcctgTrans related CRUD services from simple to entity-auto
    (OFBIZ-11640)
---
 .../minilang/ledger/AcctgTransServices.xml         | 29 +---------------------
 applications/accounting/servicedef/secas.xml       |  8 +++++-
 .../accounting/servicedef/services_ledger.xml      | 16 +++++++-----
 3 files changed, 18 insertions(+), 35 deletions(-)

diff --git a/applications/accounting/minilang/ledger/AcctgTransServices.xml b/applications/accounting/minilang/ledger/AcctgTransServices.xml
index d6a51a4..2537a10 100644
--- a/applications/accounting/minilang/ledger/AcctgTransServices.xml
+++ b/applications/accounting/minilang/ledger/AcctgTransServices.xml
@@ -21,39 +21,12 @@ 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">
     <!-- ========= AcctgTrans methods ========= -->
-    <simple-method method-name="createAcctgTrans" short-description="Create an AcctgTrans">
-        <make-value entity-name="AcctgTrans" value-field="newEntity"/>
-        <set-nonpk-fields map="parameters" value-field="newEntity"/>
-        <set field="newEntity.isPosted" value="N"/>
-
-        <!-- AcctgTrans uses a sequenced id, so get the next one now and set it... -->
-        <sequenced-id sequence-name="AcctgTrans" field="newEntity.acctgTransId"/>
-        <field-to-result field="newEntity.acctgTransId" result-name="acctgTransId"/>
-
-        <set from-field="userLogin.userLoginId" field="newEntity.lastModifiedByUserLogin"/>
-        <set from-field="userLogin.userLoginId" field="newEntity.createdByUserLogin"/>
-
-        <create-value value-field="newEntity"/>
-    </simple-method>
-    <simple-method method-name="updateAcctgTrans" short-description="Update an AcctgTrans">
+    <simple-method method-name="checkAcctgTransPosted" short-description="Check an AcctgTrans">
         <entity-one entity-name="AcctgTrans" value-field="lookedUpValue"/>
         <if-compare field="lookedUpValue.isPosted" operator="equals" value="Y">
             <add-error><fail-property resource="AccountingUiLabels" property="AccountingTransactionHasBeenAlreadyPosted"/></add-error>
             <check-errors/>
         </if-compare>
-        <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
-
-        <set from-field="userLogin.userLoginId" field="lookedUpValue.lastModifiedByUserLogin"/>
-
-        <store-value value-field="lookedUpValue"/>
-    </simple-method>
-    <simple-method method-name="deleteAcctgTrans" short-description="Delete an AcctgTrans">
-        <entity-one entity-name="AcctgTrans" value-field="lookedUpValue"/>
-        <if-compare field="lookedUpValue.isPosted" operator="equals" value="Y">
-            <add-error><fail-property resource="AccountingUiLabels" property="AccountingTransactionHasBeenAlreadyPosted"/></add-error>
-            <check-errors/>
-        </if-compare>
-        <remove-value value-field="lookedUpValue"/>
     </simple-method>
     <simple-method method-name="updateAcctgTransLastModified" short-description="Update AcctgTrans LastModified Info">
         <!-- this is just a little method that is meant to be called as an inline call-simple-method target with the context already setup -->
diff --git a/applications/accounting/servicedef/secas.xml b/applications/accounting/servicedef/secas.xml
index 2e8ebb8..50213a7 100644
--- a/applications/accounting/servicedef/secas.xml
+++ b/applications/accounting/servicedef/secas.xml
@@ -172,5 +172,11 @@ under the License.
     <eca service="updateFixedAssetMeter" event="commit">
         <action service="createMaintsFromMeterReading" mode="sync"/>
     </eca>
-
+    <!-- Check AcctgTrans posted -->
+    <eca service="updateAcctgTrans" event="invoke">
+        <action service="checkAcctgTransPosted" mode="sync"/>
+    </eca>
+    <eca service="deleteAcctgTrans" event="invoke">
+        <action service="checkAcctgTransPosted" mode="sync"/>
+    </eca>
 </service-eca>
diff --git a/applications/accounting/servicedef/services_ledger.xml b/applications/accounting/servicedef/services_ledger.xml
index 44b7c9f..6d68e2a 100644
--- a/applications/accounting/servicedef/services_ledger.xml
+++ b/applications/accounting/servicedef/services_ledger.xml
@@ -188,27 +188,31 @@ under the License.
         <override name="transactionDate" optional="false"/>
         <override name="glFiscalTypeId" optional="false"/>
     </service>
-    <service name="createAcctgTrans" default-entity-name="AcctgTrans" engine="simple"
-            location="component://accounting/minilang/ledger/AcctgTransServices.xml" invoke="createAcctgTrans" auth="true">
+    <!-- AcctgTrans services -->
+    <service name="createAcctgTrans" default-entity-name="AcctgTrans" engine="entity-auto" invoke="create" auth="true">
         <description>Create a AcctgTrans record.  isPosted is forced to "N"</description>
         <permission-service service-name="acctgTransactionPermissionCheck" main-action="CREATE"/>
         <implements service="interfaceAcctgTrans"/>
         <auto-attributes include="pk" mode="OUT" optional="false"/>
+        <override name="isPosted" default-value="N"/>
     </service>
-    <service name="updateAcctgTrans" default-entity-name="AcctgTrans" engine="simple"
-            location="component://accounting/minilang/ledger/AcctgTransServices.xml" invoke="updateAcctgTrans" auth="true">
+    <service name="updateAcctgTrans" default-entity-name="AcctgTrans" engine="entity-auto" invoke="update" auth="true">
         <description>Update a AcctgTrans record</description>
         <permission-service service-name="acctgTransactionPermissionCheck" main-action="UPDATE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
         <auto-attributes include="nonpk" mode="IN" optional="true"/>
     </service>
-    <service name="deleteAcctgTrans" default-entity-name="AcctgTrans" engine="simple"
-            location="component://accounting/minilang/ledger/AcctgTransServices.xml" invoke="deleteAcctgTrans" auth="true">
+    <service name="deleteAcctgTrans" default-entity-name="AcctgTrans" engine="entity-auto" invoke="delete" auth="true">
         <description>Delete a AcctgTrans record</description>
         <permission-service service-name="acctgTransactionPermissionCheck" main-action="DELETE"/>
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 
+    <service name="checkAcctgTransPosted" default-entity-name="AcctgTrans" engine="simple"
+        location="component://accounting/minilang/ledger/AcctgTransServices.xml" invoke="checkAcctgTransPosted" auth="true">
+        <description>Check AcctgTrans posted</description>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+    </service>
     <service name="interfaceAcctgTransEntry" default-entity-name="AcctgTransEntry" engine="interface" location="" invoke="">
         <auto-attributes include="nonpk" mode="IN" optional="true">
             <exclude field-name="reconcileStatusId"/>