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, Jacques for the test.
diff --git a/applications/accounting/minilang/test/AutoAcctgFinAccountTests.xml b/applications/accounting/minilang/test/AutoAcctgFinAccountTests.xml
index b344f79..9347f34 100644
--- a/applications/accounting/minilang/test/AutoAcctgFinAccountTests.xml
+++ b/applications/accounting/minilang/test/AutoAcctgFinAccountTests.xml
@@ -70,7 +70,8 @@
<field-map field-name="finAccountId" value="1002"/>
</entity-one>
<assert>
- <if-empty field="finAccount"/>
+ <not><if-empty field="finAccount"/></not>
+ <not><if-empty field="finAccount.thruDate"/></not>
</assert>
<check-errors/>
</simple-method>
diff --git a/applications/accounting/servicedef/services_finaccount.xml b/applications/accounting/servicedef/services_finaccount.xml
index b1feeb1..f4c823c 100644
--- a/applications/accounting/servicedef/services_finaccount.xml
+++ b/applications/accounting/servicedef/services_finaccount.xml
@@ -48,7 +48,7 @@
<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/widget/FinAccountForms.xml b/applications/accounting/widget/FinAccountForms.xml
index efd67ec..bb9fcaa 100644
--- a/applications/accounting/widget/FinAccountForms.xml
+++ b/applications/accounting/widget/FinAccountForms.xml
@@ -73,7 +73,7 @@
<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 79e4b67..769507d 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
@@ -556,7 +556,9 @@
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());
}