[ofbiz-framework] branch trunk updated: Fixed: Error in deleting Financial Account (OFBIZ-12153)

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: Fixed: Error in deleting Financial Account (OFBIZ-12153)

jleroux@apache.org
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 1bf977a  Fixed: Error in deleting Financial Account (OFBIZ-12153)
1bf977a is described below

commit 1bf977ae0719c7d7b742107d1eb3d132d15a13c6
Author: Jacques Le Roux <[hidden email]>
AuthorDate: Fri Mar 5 06:12:43 2021 +0100

    Fixed: Error in deleting Financial Account (OFBIZ-12153)
   
    1. Navigate to URL: accounting/control/FindFinAccount
    2. Click on Find button. List of fin account will be displayed.
    3. Click on delete button near available balance column.
   
    Thanks: Lalit Dashora for report, Sourabh Jain for the initial fix, Pawan Verma
    for the defintive fix
---
 applications/accounting/servicedef/services_finaccount.xml            | 2 +-
 .../org/apache/ofbiz/accounting/AutoAcctgFinAccountTests.groovy       | 2 +-
 applications/accounting/widget/FinAccountForms.xml                    | 2 +-
 .../main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java   | 4 +++-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/applications/accounting/servicedef/services_finaccount.xml b/applications/accounting/servicedef/services_finaccount.xml
index 8c600ab..2b879c8 100644
--- a/applications/accounting/servicedef/services_finaccount.xml
+++ b/applications/accounting/servicedef/services_finaccount.xml
@@ -48,7 +48,7 @@ under the License.
         <attribute name="replenishPaymentId" type="String" mode="OUT" optional="true"/>
         <attribute name="replenishLevel" type="BigDecimal" mode="OUT" optional="true"/>
     </service>
-    <service name="deleteFinAccount" default-entity-name="FinAccount" engine="entity-auto" invoke="delete">
+    <service name="deleteFinAccount" default-entity-name="FinAccount" engine="entity-auto" invoke="expire">
         <description>Delete a Financial Account</description>
         <auto-attributes mode="IN" optional="false" include="pk"/>
     </service>
diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFinAccountTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFinAccountTests.groovy
index 05e1849..9ed7741 100644
--- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFinAccountTests.groovy
+++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoAcctgFinAccountTests.groovy
@@ -77,7 +77,7 @@ class AutoAcctgFinAccountTests extends OFBizTestCase {
         GenericValue finAccount = from('FinAccount')
                 .where('finAccountId', '1002')
                 .queryOne()
-        assert finAccount == null
+        assert finAccount.thruDate != null
     }
 
     void testCreateFinAccountRole() {
diff --git a/applications/accounting/widget/FinAccountForms.xml b/applications/accounting/widget/FinAccountForms.xml
index f2e2922..2938c89 100644
--- a/applications/accounting/widget/FinAccountForms.xml
+++ b/applications/accounting/widget/FinAccountForms.xml
@@ -73,7 +73,7 @@ under the License.
                 <parameter param-name="partyId" from-field="ownerPartyId"/>
             </hyperlink>
         </field>
-        <field name="deleteLink" title=" " widget-style="buttontext">
+        <field name="deleteLink" title=" " widget-style="buttontext" use-when="thruDate==null">
             <hyperlink description="${uiLabelMap.CommonDelete}" target="deleteFinAccount" also-hidden="false">
                 <parameter param-name="finAccountId"/>
             </hyperlink>
diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java b/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java
index c8e7a80..19736b7 100644
--- a/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java
+++ b/framework/service/src/main/java/org/apache/ofbiz/service/engine/EntityAutoEngine.java
@@ -591,7 +591,9 @@ public final class EntityAutoEngine extends GenericAsyncEngine {
             if (parameters.get(fieldDateNameIn) == null) {
                 parameters.put(fieldDateNameIn, UtilDateTime.nowTimestamp());
             }
-        } else if (thruDatePresent && UtilValidate.isEmpty(lookedUpValue.getTimestamp("thruDate"))) {
+        }
+        // Expire thruDate fields
+        if (thruDatePresent && UtilValidate.isEmpty(lookedUpValue.getTimestamp("thruDate"))) {
             if (UtilValidate.isEmpty(parameters.get("thruDate"))) {
                 parameters.put("thruDate", UtilDateTime.nowTimestamp());
             }