You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2007/03/27 16:27:56 UTC

svn commit: r522927 - in /ofbiz/trunk/applications/accounting: ./ entitydef/ servicedef/ src/org/ofbiz/accounting/test/ testdef/

Author: jaz
Date: Tue Mar 27 07:27:55 2007
New Revision: 522927

URL: http://svn.apache.org/viewvc?view=rev&rev=522927
Log:
added very simple fin account test (will try to add more later) moved entity eca to entitydef (pattern in other applications) added fin account ecas ** NOTE the replenish eca is disabled due to the fact is does not work yet.

Added:
    ofbiz/trunk/applications/accounting/entitydef/eecas.xml   (contents, props changed)
      - copied, changed from r522912, ofbiz/trunk/applications/accounting/servicedef/eecas.xml
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/
    ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java   (with props)
    ofbiz/trunk/applications/accounting/testdef/
    ofbiz/trunk/applications/accounting/testdef/accountingtests.xml   (with props)
Removed:
    ofbiz/trunk/applications/accounting/servicedef/eecas.xml
Modified:
    ofbiz/trunk/applications/accounting/ofbiz-component.xml
    ofbiz/trunk/applications/accounting/servicedef/secas.xml

Copied: ofbiz/trunk/applications/accounting/entitydef/eecas.xml (from r522912, ofbiz/trunk/applications/accounting/servicedef/eecas.xml)
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/eecas.xml?view=diff&rev=522927&p1=ofbiz/trunk/applications/accounting/servicedef/eecas.xml&r1=522912&p2=ofbiz/trunk/applications/accounting/entitydef/eecas.xml&r2=522927
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/eecas.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/eecas.xml Tue Mar 27 07:27:55 2007
@@ -1,22 +1,22 @@
 <?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
+  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
+  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.
--->
+  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.
+  -->
 
 <entity-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/entity-eca.xsd">

Propchange: ofbiz/trunk/applications/accounting/entitydef/eecas.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/entitydef/eecas.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/accounting/entitydef/eecas.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/applications/accounting/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/ofbiz-component.xml?view=diff&rev=522927&r1=522926&r2=522927
==============================================================================
--- ofbiz/trunk/applications/accounting/ofbiz-component.xml (original)
+++ ofbiz/trunk/applications/accounting/ofbiz-component.xml Tue Mar 27 07:27:55 2007
@@ -66,6 +66,8 @@
     <service-resource type="eca" loader="main" location="servicedef/secas.xml"/>
     <service-resource type="eca" loader="main" location="servicedef/secas_payment.xml"/>
 
+    <test-suite loader="main" location="testdef/accountingtests.xml"/>
+
     <webapp name="accounting"
         title="Accounting"
         server="default-server"

Modified: ofbiz/trunk/applications/accounting/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas.xml?view=diff&rev=522927&r1=522926&r2=522927
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas.xml Tue Mar 27 07:27:55 2007
@@ -99,6 +99,33 @@
         <action service="sendOrderPayRetryNotification" mode="async" persist="true"/>
     </eca>
 
+    <!-- financial account role ecas -->
+    <eca service="createFinAccountRole" event="invoke">
+        <action service="ensurePartyRole" mode="sync" run-as-user="system"/>
+    </eca>
+    
+    <!-- financial account transaction ecas -->
+    <!--
+    <eca service="finAccountWithdraw" event="return">
+        <condition field-name="productStoreId" operator="is-not-empty"/>
+        <action service="finAccountReplenish" mode="async" run-as-user="system"/>
+    </eca>
+    -->
+    <eca service="finAccountWithdraw" event="commit">
+        <action service="checkFinAccountStatus" mode="sync" run-as-user="system"/>
+    </eca>
+    <eca service="finAccountDeposit" event="commit">
+        <action service="checkFinAccountStatus" mode="sync" run-as-user="system"/>
+    </eca>
+
+    <eca service="createFinAccountTrans" event="commit">
+        <action service="postFinAccountTransToGl" mode="sync"/>
+    </eca>
+
+    <eca service="expireFinAccountAuth" event="commit">
+        <action service="checkFinAccountStatus" mode="sync"/>
+    </eca>
+        
     <!-- sample ECA rules for the sampleInvoiceAffiliateCommission service triggering
     <eca service="createPayment" event="commit">
         <condition field-name="statusId" operator="equals" value="PMNT_RECEIVED"/>
@@ -110,9 +137,4 @@
         <action service="sampleInvoiceAffiliateCommission" mode="sync"/>
     </eca>
     -->
-    
-    <!-- FinAccountTrans SECAs -->
-    <eca service="createFinAccountTrans" event="commit">
-        <action service="postFinAccountTransToGl" mode="sync"/>
-    </eca>
 </service-eca>

Added: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java?view=auto&rev=522927
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java (added)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java Tue Mar 27 07:27:55 2007
@@ -0,0 +1,86 @@
+/*
+ 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.accounting.test;
+
+import junit.framework.TestCase;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.base.util.UtilMisc;
+
+import java.util.Map;
+
+import javolution.util.FastMap;
+
+/**
+ * FinAccountTests
+ */
+public class FinAccountTests extends TestCase {
+
+    protected LocalDispatcher dispatcher = null;
+    protected GenericValue userLogin = null;
+    protected String finAccountId = null;
+    protected double balance = 0.00;
+
+    public FinAccountTests(String name) {
+        super(name);
+    }
+
+    protected void setUp() throws Exception {
+        GenericDelegator delegator = GenericDelegator.getGenericDelegator("test");
+        dispatcher = GenericDispatcher.getLocalDispatcher("test-dispatcher", delegator);
+        userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
+    }
+
+    protected void tearDown() throws Exception {
+    }
+
+    public void testCreateFinAccount() throws Exception {
+        Map ctx = FastMap.newInstance();
+        ctx.put("finAccountName", "Test Financial Account");
+        ctx.put("finAccountTypeId", "BALANCE_ACCOUNT");
+        ctx.put("userLogin", userLogin);
+        Map resp = dispatcher.runSync("createFinAccount", ctx);
+        finAccountId = (String) resp.get("finAccountId");
+        assertNotNull(finAccountId);
+    }
+
+    public void testDeposit() throws Exception {
+        Map ctx = FastMap.newInstance();
+        ctx.put("finAccountId", finAccountId);
+        ctx.put("amount", new Double(100.00));
+        ctx.put("userLogin", userLogin);
+        Map resp = dispatcher.runSync("finAccountDeposit", ctx);
+        balance = ((Double) resp.get("balance")).doubleValue();
+        assertEquals(balance, 100.00, 0.0);
+    }
+
+    public void testWithdraw() throws Exception {
+        Map ctx = FastMap.newInstance();
+        ctx.put("finAccountId", finAccountId);
+        ctx.put("amount", new Double(50.00));
+        ctx.put("userLogin", userLogin);
+        Map resp = dispatcher.runSync("finAccountWithdraw", ctx);
+        Double previousBalance = (Double) resp.get("previousBalance");
+        balance = ((Double) resp.get("balance")).doubleValue();
+        assertEquals((balance + 50.00), previousBalance.doubleValue(), 0.0);
+    }
+}

Propchange: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/test/FinAccountTests.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ofbiz/trunk/applications/accounting/testdef/accountingtests.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/testdef/accountingtests.xml?view=auto&rev=522927
==============================================================================
--- ofbiz/trunk/applications/accounting/testdef/accountingtests.xml (added)
+++ ofbiz/trunk/applications/accounting/testdef/accountingtests.xml Tue Mar 27 07:27:55 2007
@@ -0,0 +1,24 @@
+<!--
+  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.
+  -->
+
+<test-suite suite-name="accountingtests"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/test-suite.xsd">
+    <test-case case-name="accounting-tests"><junit-test-suite class-name="org.ofbiz.accounting.test.FinAccountTests"/></test-case>
+</test-suite>

Propchange: ofbiz/trunk/applications/accounting/testdef/accountingtests.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/testdef/accountingtests.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/accounting/testdef/accountingtests.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml