diff --git a/applications/order/ofbiz-component.xml b/applications/order/ofbiz-component.xml index 0fc3b16862..ea14da45e3 100644 --- a/applications/order/ofbiz-component.xml +++ b/applications/order/ofbiz-component.xml @@ -52,6 +52,7 @@ under the License. + diff --git a/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java b/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java index 225ca0c99c..98aed08b4f 100644 --- a/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java +++ b/applications/order/src/org/ofbiz/order/finaccount/FinAccountHelper.java @@ -140,11 +140,8 @@ public class FinAccountHelper { } finAccountCode = finAccountCode.toUpperCase().replaceAll("[^0-9A-Z]", ""); - // now we need to get the encrypted version of the fin account code the user passed in to look up against FinAccount - String encryptedFinAccountCode = (String) delegator.encryptFieldValue("FinAccount", finAccountCode); - // now look for the account - List accounts = delegator.findByAnd("FinAccount", UtilMisc.toMap("finAccountCode", encryptedFinAccountCode), null, false); + List accounts = delegator.findByAnd("FinAccount", UtilMisc.toMap("finAccountCode", finAccountCode), null, false); accounts = EntityUtil.filterByDate(accounts); if (UtilValidate.isEmpty(accounts)) { diff --git a/applications/order/src/org/ofbiz/order/test/FinAccountTest.java b/applications/order/src/org/ofbiz/order/test/FinAccountTest.java new file mode 100644 index 0000000000..125a1d6f8a --- /dev/null +++ b/applications/order/src/org/ofbiz/order/test/FinAccountTest.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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. + *******************************************************************************/ +package org.ofbiz.order.test; + +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.testtools.OFBizTestCase; +import org.ofbiz.order.finaccount.FinAccountHelper; + +public class FinAccountTest extends OFBizTestCase { + public FinAccountTest(String name) { + super(name); + } + + public void testCreateFinAccountBasic() throws Exception { + String finAccountCode; + GenericValue account; + + finAccountCode = FinAccountHelper.getNewFinAccountCode(20, delegator); + System.err.printf("finAccountCode=%s\n", finAccountCode); + assertNotNull(finAccountCode); + + account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator); + assertNull(account); + + delegator.createSetNextSeqId(delegator.makeValue("FinAccount", UtilMisc.toMap("finAccountCode", finAccountCode))); + + account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator); + assertNotNull(account); + assertEquals(finAccountCode, account.get("finAccountCode")); + account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toUpperCase(), delegator); + assertNotNull(account); + assertEquals(finAccountCode, account.get("finAccountCode")); + account = FinAccountHelper.getFinAccountFromCode(finAccountCode.toLowerCase(), delegator); + assertNotNull(account); + assertEquals(finAccountCode, account.get("finAccountCode")); + + delegator.createSetNextSeqId(delegator.makeValue("FinAccount", UtilMisc.toMap("finAccountCode", finAccountCode))); + account = FinAccountHelper.getFinAccountFromCode(finAccountCode, delegator); + assertNull(account); + } +} diff --git a/applications/order/testdef/FinAccountTests.xml b/applications/order/testdef/FinAccountTests.xml new file mode 100644 index 0000000000..1467a3ff70 --- /dev/null +++ b/applications/order/testdef/FinAccountTests.xml @@ -0,0 +1,28 @@ + + + + + + + + +