Author: hansbak
Date: Sun Dec 18 06:27:29 2011
New Revision: 1220339

URL: http://svn.apache.org/viewvc?rev=1220339&view=rev
Log:
split up accounting auto post test in sales and purchase and added some asserts

Added:
    
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
   (with props)
    
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
   (with props)
Removed:
    
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTests.xml
Modified:
    ofbiz/trunk/applications/accounting/testdef/accountingtests.xml

Added: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml?rev=1220339&view=auto
==============================================================================
--- 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
 (added)
+++ 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
 Sun Dec 18 06:27:29 2011
@@ -0,0 +1,228 @@
+<?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
+
+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.
+-->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd";>
+
+    <!-- Test case for Accounting Transaction on Purchase -->
+    <simple-method method-name="testAcctgTransOnPoReceipts" 
short-description="Test case for Accounting Transaction on Receipts of Purchase 
Order." login-required="false">
+        <!-- Precondition : shipment is created from supplier and order items 
are issued  -->
+        <!-- create a purchase order using following:
+             Supplier : DemoSupplier
+             Item     : WG-1111
+             Quantity : 10 -->
+
+        <!-- Post condition : Credit in account 214000 - UNINVOICED ITEM 
RECEIPT amount = grand total of order.
+                              Debit in account 140000- INVENTORY amount = 
grand total of order.  -->
+
+        <!-- set few variables so that they can be changed easily to test with 
different values -->
+        <set field="orderId" value="DEMO10091"/>
+        <set field="productId" value="GZ-2644"/>
+        <set field="orderItemSeqId" value="00001"/>
+        <set field="shipmentId" value="9999"/>
+
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="serviceCtx.userLogin" from-field="userLogin"/>
+        <set field="serviceCtx.inventoryItemTypeId" 
value="NON_SERIAL_INV_ITEM"/>
+        <set field="serviceCtx.productId" from-field="productId"/>
+        <set field="serviceCtx.facilityId" value="WebStoreWarehouse"/>
+        <set field="serviceCtx.quantityAccepted" value="5" type="BigDecimal"/>
+        <set field="serviceCtx.quantityRejected" value="0" type="BigDecimal"/>
+        <set field="serviceCtx.shipmentId" from-field="shipmentId"/>
+        <set field="serviceCtx.orderId" from-field="orderId"/>
+        <set field="serviceCtx.orderItemSeqId" from-field="orderItemSeqId"/>
+
+        <call-service service-name="receiveInventoryProduct" 
in-map-name="serviceCtx"/>
+
+        <entity-and list="acctgTransList" entity-name="AcctgTrans">
+            <field-map field-name="shipmentId"/>
+        </entity-and>
+        <assert><not><if-empty field="acctgTransList"/></not></assert>
+        <first-from-list entry="acctgTrans" list="acctgTransList"/>
+
+        <assert><if-compare field="acctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related value-field="acctgTrans" relation-name="AcctgTransEntry" 
list="acctgTransEntryList"/>
+        <set field="productFilter.productId" from-field="productId"/>
+        <filter-list-by-and list="acctgTransEntryList" map="productFilter" 
to-list="acctgTransEntryList"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance"/>
+
+        <iterate list="acctgTransEntryList" entry="acctgTransEntry">
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="C">
+                <assert>
+                    <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="UNINVOICED_SHIP_RCPT"/>
+                    <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="214000"/>
+                </assert>
+            <else>
+                <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="D">
+                    <assert>
+                        <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="INVENTORY_ACCOUNT"/>
+                        <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="140000"/>
+                    </assert>
+                </if-compare>
+            </else>
+            </if-compare>
+        </iterate>
+        <!-- check if invoice created -->
+        <entity-and list="orderItemBillings" entity-name="OrderItemBilling">
+            <field-map field-name="orderId"/>
+        </entity-and>
+        <assert>
+            <not><if-empty field="orderItemBillings"/></not>
+        </assert>
+        <check-errors/>
+    </simple-method>
+
+    <simple-method method-name="testAcctgTransOnEditPoInvoice" 
short-description="Test case for Purchase Invoices: editing, adding taxes and 
shipping charges and posting to GL" login-required="false">
+        <!-- Precondition: To the Purchase Invoice created add taxes and two 
different shipping charges
+            1. for taxes: set "Invoice Item Type" = "Invoice Sales Tax" and 
"Unit Price" = 10$
+            2. for the first shipping charge: set "Invoice Item Type" = 
"Invoice Shipping And Handling" and "Unit Price" = 5$
+            3. for the second shipping charge: set "Invoice Item Type" = 
"Invoice Shipping And Handling", set "Override Gl Account Id" = "516100" and 
"Unit Price" = 5$
+        -->
+        <!-- Post condition: When status is set to ready, an accounting 
transaction is automatically posted to the GL:
+            * Credit; in account 210000 - "ACCOUNTS PAYABLE"; amount: 290$
+            * Debit; in account 214000 - "UNINVOICED ITEM RECEIPTS"; amount: 
270$
+            * Debit; in account 516100 - "PURCHASE ORDER ADJUSTMENTS"; amount: 
10$
+            * Debit; in account 510000 - "FREIGHT IN"; amount: 5$
+            * Debit; in account 516100 - "PURCHASE ORDER ADJUSTMENTS"; amount: 
5$
+        -->
+
+        <set field="orderId" value="DEMO10091"/>
+        <entity-and list="orderItemBillings" entity-name="OrderItemBilling">
+            <field-map field-name="orderId"/>
+        </entity-and>
+        <first-from-list entry="orderItemBilling" list="orderItemBillings"/>
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="serviceCtx.userLogin" from-field="userLogin"/>
+        <set field="serviceCtx.statusId" value="INVOICE_READY"/>
+        <set field="serviceCtx.invoiceId" 
from-field="orderItemBilling.invoiceId"/>
+        <call-service service-name="setInvoiceStatus" 
in-map-name="serviceCtx"/>
+        <entity-one entity-name="Invoice" value-field="invoice">
+            <field-map field-name="invoiceId" 
from-field="orderItemBilling.invoiceId"/>
+        </entity-one>
+        <get-related value-field="invoice" relation-name="AcctgTrans" 
list="acctgTransList"/>
+        <first-from-list list="acctgTransList" entry="acctgTrans"/>
+
+        <assert><if-compare field="acctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related value-field="acctgTrans" relation-name="AcctgTransEntry" 
list="acctgTransEntryList"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance"/>
+
+        <iterate list="acctgTransEntryList" entry="acctgTransEntry">
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="C">
+                <assert>
+                    <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="ACCOUNTS_PAYABLE"/>
+                    <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="210000"/>
+                </assert>
+            </if-compare>
+        </iterate>
+        <check-errors/>
+    </simple-method>
+
+    <simple-method method-name="testAcctgTransOnPaymentSentToSupplier" 
short-description="Test case for Payment sent to supplier for purchase 
invoice." login-required="false">
+        <!--
+            Precondition: New payment is created for: supplierId = 
"DemoSupplier", "Payment Type ID" = "Vendor Payment" and
+                          a proper "Payment Method Type" (e.g. "Electronic 
Funds Transfer"), amount = $290
+
+            Post condition: On payment's status is sent: a double-entry 
accounting transaction is automatically posted to the GL:
+                * Credit; in account 111100 - "GENERAL CHECKING ACCOUNT"; 
amount: 290$; however this depends on the "Payment method type" selected;
+                * Debit; in account 216000 - "ACCOUNTS PAYABLE - UNAPPLIED 
PAYMENTS"; amount: 290$
+         -->
+
+        <set field="paymentId" value="9000"/>
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="serviceCtx.userLogin" from-field="userLogin"/>
+        <set field="serviceCtx.paymentId" from-field="paymentId"/>
+        <set field="serviceCtx.statusId" value="PMNT_SENT"/>
+
+        <call-service service-name="setPaymentStatus" 
in-map-name="serviceCtx"/>
+        <entity-one entity-name="Payment" value-field="payment">
+            <field-map field-name="paymentId" from-field="paymentId"/>
+        </entity-one>
+        <get-related value-field="payment" relation-name="AcctgTrans" 
list="acctgTransList"/>
+        <first-from-list list="acctgTransList" entry="acctgTrans"/>
+
+        <assert><if-compare field="acctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related value-field="acctgTrans" relation-name="AcctgTransEntry" 
list="acctgTransEntryList"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance"/>
+
+        <iterate list="acctgTransEntryList" entry="acctgTransEntry">
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="C">
+                <assert>
+                    <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="111100"/>
+                </assert>
+            <else>
+                <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="D">
+                    <assert>
+                        <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="ACCPAYABLE_UNAPPLIED"/>
+                        <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="216000"/>
+                    </assert>
+                </if-compare>
+            </else>
+            </if-compare>
+        </iterate>
+        <check-errors/>
+    </simple-method>
+
+
+    <simple-method method-name="UtilCheckEntriesBalance" login-required="false"
+            short-description="Short util method that takes a list of 
AcctgTransEntry values (acctgTransEntryList) and checks that the debit and 
credit totals balance.">
+        <set field="debitTotal" type="BigDecimal" value="0.0"/>
+        <set field="creditTotal" type="BigDecimal" value="0.0"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+        <iterate list="acctgTransEntryList" entry="acctgTransEntry">
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="C">
+                <calculate field="creditTotal">
+                    <calcop operator="get" field="creditTotal"/>
+                    <calcop operator="add" field="acctgTransEntry.origAmount"/>
+                </calculate>
+            <else>
+                <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="D">
+                    <calculate field="debitTotal">
+                        <calcop operator="get" field="debitTotal"/>
+                        <calcop operator="add" 
field="acctgTransEntry.origAmount"/>
+                    </calculate>
+                </if-compare>
+            </else>
+            </if-compare>
+        </iterate>
+        <assert>
+            <if-compare-field field="debitTotal" operator="equals" 
to-field="creditTotal" type="BigDecimal"/>
+        </assert>
+    </simple-method>
+
+</simple-methods>

Propchange: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml?rev=1220339&view=auto
==============================================================================
--- 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
 (added)
+++ 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
 Sun Dec 18 06:27:29 2011
@@ -0,0 +1,247 @@
+<?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
+
+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.
+-->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+        
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd";>
+
+    <!-- Test case for Accounting Transaction on Sales -->
+    <simple-method method-name="testAcctgTransForSalesOrderShipments" 
short-description="Creation and Shipments of sales order" 
login-required="false">
+        <!-- Precondition :
+             1. create a sales order
+             2. from the order view screen, approve the order
+             3. from the order view screen, create a shipment to the customer 
(click on "New Shipment For Ship Group" and then click on the "Update" button 
in the next screen)
+        -->
+        <!-- Following process is tested by test case:
+             1. issue (assign) the order items to the shipment: select the 
"Order Items" tab and then click on "Issue All"; this action will generate and 
post to the GL the accounting transaction for the items taken from the 
warehouse and ready to be shipped
+        -->
+        <!-- Post condition: all order items will be issued and it will 
generate and post to the GL the accounting transaction for the items taken from 
the warehouse and ready to be shipped
+              * Credit; in account:140000 - Account Type:"INVENTORY_ACCOUNT"
+              * Debit; in account:500000 - Account Type:"COGS_ACCOUNT"
+        -->
+
+        <set field="shipmentId" value="9998"/>
+        <set field="orderId" value="DEMO10090"/>
+        <set field="shipGroupSeqId" value="00001"/>
+        <set field="orderItemSeqId" value="00001"/>
+        <set field="inventoryItemId" value="9001"/>
+        <set field="quantity" value="2" type="BigDecimal"/>
+        <set field="productId" value="GZ-2644"/>
+
+        <entity-one entity-name="UserLogin" value-field="userLogin" 
auto-field-map="false">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="serviceCtx.userLogin" from-field="userLogin"/>
+        <set field="serviceCtx.shipmentId" from-field="shipmentId"/>
+        <set field="serviceCtx.orderId" from-field="orderId"/>
+        <set field="serviceCtx.shipGroupSeqId" from-field="shipGroupSeqId"/>
+        <set field="serviceCtx.orderItemSeqId" from-field="orderItemSeqId"/>
+        <set field="serviceCtx.inventoryItemId" from-field="inventoryItemId"/>
+        <set field="serviceCtx.quantity" from-field="quantity"/>
+        <call-service service-name="issueOrderItemShipGrpInvResToShipment" 
in-map-name="serviceCtx"/>
+
+        <entity-condition list="acctgTransList" entity-name="AcctgTrans">
+            <condition-expr field-name="shipmentId" from-field="shipmentId"/>
+            <order-by field-name="-postedDate"/>
+        </entity-condition>
+        <assert><not><if-empty field="acctgTransList"/></not></assert>
+        <first-from-list entry="acctgTrans" list="acctgTransList"/>
+
+        <assert><if-compare field="acctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related list="acctgTransEntryList" 
relation-name="AcctgTransEntry" value-field="acctgTrans"/>
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance" 
xml-resource="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml"/>
+
+        <iterate list="acctgTransEntryList" entry="acctgTransEntry">
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="C">
+                <assert>
+                    <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="INVENTORY_ACCOUNT"/>
+                    <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="140000"/>
+                </assert>
+            <else>
+                <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="D">
+                    <assert>
+                        <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="COGS_ACCOUNT"/>
+                        <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="500000"/>
+                    </assert>
+                </if-compare>
+            </else>
+            </if-compare>
+        </iterate>
+        <check-errors/>
+    </simple-method>
+
+    <simple-method method-name="testAcctgTransOnSalesInvoice" 
short-description="Test case for Accounting Transaction for sales invoice" 
login-required="false">
+        <!-- Precondition:
+            1. Create a sales order
+            2. From the order view screen, approve the order
+            3. From the order view screen, create a shipment to the customer 
(click on "New Shipment For Ship Group" and then click on the "Update" button 
in the next screen)
+            4. Issue the order items to the shipment: select the "Order Items" 
tab and then click on "Issue All."
+            5. From the shipment detail screen of the shipment created in the 
previous step (there is a link to it from the order detail screen), set the 
status of the shipment to "pack"(Click on "Edit" and then from statusId drop 
down select statusId = "Pack" and then click update); this action will generate 
a sales invoice
+        -->
+        <!-- Following process is tested by test case:
+             1. Go to the invoice detail screen (there is a link to the 
invoice from the order detail screen) and click on the "set status to ready"; 
this action will generate and post to the GL the accounting transaction for the 
sales invoice
+        -->
+        <!-- Post condition: "Set status to ready"; This action will generate 
and post to the GL the accounting transaction for the sales invoice
+              * Credit; in account=400000 - Account Type="SALES_ACCOUNT"
+              * Debit; in  account=120000 - Account Type="ACCOUNTS_RECEIVABLE"
+        -->
+        <!-- Note: The above notes seem to assume that you are going to 
manually follow the preconditions above before running this test.
+                   Instead the test will now use order DEMO10090 which 
currently preconditions 1-4 fulfilled, and we'll then update the
+                   shipment to the packed status (precondition 4).  
Additionally it doesn't seem to be necessary to set the invoice status
+                   to ready because the invoice is created in that state.
+        -->
+        
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+
+        <set field="serviceCtx.userLogin"  from-field="userLogin"/>
+        <set field="serviceCtx.shipmentId" value="9998"/>
+        <set field="serviceCtx.statusId" value="SHIPMENT_PACKED"/>
+        <call-service service-name="updateShipment" in-map-name="serviceCtx"/>
+
+        <entity-condition list="shipmentItemBillings" 
entity-name="ShipmentItemBilling">
+            <condition-expr field-name="shipmentId" value="9998"/>
+            <order-by field-name="-createdStamp"/>
+        </entity-condition>
+        <assert><not><if-empty field="shipmentItemBillings"/></not></assert>
+        <first-from-list entry="shipmentItemBilling" 
list="shipmentItemBillings"/>
+        <set field="invoiceId" from-field="shipmentItemBilling.invoiceId"/>
+
+        <entity-one entity-name="Invoice" value-field="invoice">
+            <field-map field-name="invoiceId" from-field="invoiceId"/>
+        </entity-one>
+        <get-related value-field="invoice" relation-name="AcctgTrans" 
list="acctgTransList"/>
+        <assert><not><if-empty field="acctgTransList"/></not></assert>
+
+        <!-- Check the invoice transaction -->
+        <set field="acctgTransFilter.acctgTransTypeId" value="SALES_INVOICE"/>
+        <filter-list-by-and to-list="salesAcctgTransList" 
list="acctgTransList" map="acctgTransFilter"/>
+        <first-from-list entry="salesAcctgTrans" list="salesAcctgTransList"/>
+
+        <assert><if-compare field="salesAcctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related value-field="salesAcctgTrans" 
relation-name="AcctgTransEntry" list="acctgTransEntryList"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance" 
xml-resource="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml"/>
+
+        <set field="acctgTransEntryFilter.glAccountTypeId" 
value="ACCOUNTS_RECEIVABLE"/>
+        <set field="acctgTransEntryFilter.glAccountId" value="120000"/>
+        <filter-list-by-and list="acctgTransEntryList" 
to-list="accountsReceivableEntries" map="acctgTransEntryFilter"/>
+        <assert><not><if-empty 
field="accountsReceivableEntries"></if-empty></not></assert>
+
+        <clear-field field="acctgTransEntryFilter"/>
+        <set field="acctgTransEntryFilter.glAccountId" value="400000"/>
+        <filter-list-by-and list="acctgTransEntryList" 
to-list="salesAccountEntries" map="acctgTransEntryFilter"/>
+        <assert><not><if-empty 
field="salesAccountEntries"></if-empty></not></assert>
+
+        <!-- Check the payment transaction -->
+        <clear-field field="acctgTransEntryFilter"/>
+        <set field="acctgTransFilter.acctgTransTypeId" value="PAYMENT_APPL"/>
+        <filter-list-by-and to-list="paymentAcctgTransList" 
list="acctgTransList" map="acctgTransFilter"/>
+        <first-from-list entry="paymentAcctgTrans" 
list="paymentAcctgTransList"/>
+
+        <assert><if-compare field="paymentAcctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related value-field="paymentAcctgTrans" 
relation-name="AcctgTransEntry" list="acctgTransEntryList"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance" 
xml-resource="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml"/>
+
+        <set field="acctgTransEntryFilter.glAccountTypeId" 
value="ACCOUNTS_RECEIVABLE"/>
+        <set field="acctgTransEntryFilter.glAccountId" value="120000"/>
+        <filter-list-by-and list="acctgTransEntryList" 
to-list="accountsReceivableEntries" map="acctgTransEntryFilter"/>
+        <assert><not><if-empty 
field="accountsReceivableEntries"></if-empty></not></assert>
+
+        <check-errors/>
+    </simple-method>
+
+    <simple-method method-name="testAcctgTransOnPaymentReceivedFromCustomer" 
short-description="Test case on Payment Received from customer for Sales 
Invoice" login-required="false">
+        <!-- Precondition :-
+            1. Click on the Payment top menu in the Accounting application, 
then click on the "Create New Payment" link.
+            2. In the "New incoming payment" box, set the customer id in the 
"From Party ID" field; then set "Payment Type ID" = "Customer Payment" and a 
proper "Payment Method Type" (e.g. "Electronic Funds Transfer"); then set the 
"amount" and submit the form
+        -->
+        <!-- Following process is tested by test case:
+             1. From the payment detail screen, when you are ready to post the 
payment to the GL, click on the "Status to Received" link
+        -->
+        <!-- Post condition: "Status to Received", Received Payments. When you 
are ready to post the payment to the GL this action will generate and post to 
the GL the accounting transaction for the items taken from the warehouse and 
ready to be shipped:
+              * Credit; in glAccountId=126000 - 
glAccountTypeId="ACCOUNTS_RECEIVABLE - UNAPPLIED PAYMENTS"
+              * Debit; in glAccountId=112000 - 
glAccountTypeId="UNDEPOSITED_RECEIPTS"
+        -->
+
+        <!-- Creating a payment from scratch rather than using the demo data 
-->
+        
+        <entity-one entity-name="UserLogin" value-field="userLogin">
+            <field-map field-name="userLoginId" value="system"/>
+        </entity-one>
+        <set field="serviceCtx.userLogin" from-field="userLogin"/>
+
+        <!-- Find a customer -->
+        <entity-and list="customerRoles" entity-name="PartyRole">
+            <field-map field-name="roleTypeId" value="CUSTOMER"/>
+        </entity-and>
+        <first-from-list entry="customerRole" list="customerRoles"/>
+        <set field="serviceCtx.partyIdFrom" from-field="customerRole.partyId"/>
+        <set field="serviceCtx.amount" value="100.00" type="BigDecimal"/>
+        <set field="serviceCtx.partyIdTo" value="Company"/>
+        <set field="serviceCtx.paymentMethodTypeId" value="EFT_ACCOUNT"/>
+        <set field="serviceCtx.paymentTypeId" value="CUSTOMER_PAYMENT"/>
+        <set field="serviceCtx.paymentId" from-field="paymentId"/>
+        <set field="serviceCtx.statusId" value="PMNT_RECEIVED"/>
+        <call-service service-name="createPayment" in-map-name="serviceCtx">
+            <result-to-field result-name="paymentId"/>
+        </call-service>
+
+        <entity-and list="acctgTransList" entity-name="AcctgTrans">
+            <field-map field-name="paymentId"/>
+            <field-map field-name="acctgTransTypeId" value="INCOMING_PAYMENT"/>
+        </entity-and>
+        <first-from-list list="acctgTransList" entry="acctgTrans"/>
+
+        <assert><if-compare field="paymentAcctgTrans.glJournalId" 
operator="not-equals" value="ERROR_JOURNAL"/></assert>
+
+        <get-related value-field="acctgTrans" relation-name="AcctgTransEntry" 
list="acctgTransEntryList"/>
+
+        <assert><not><if-empty field="acctgTransEntryList"/></not></assert>
+
+        <call-simple-method method-name="UtilCheckEntriesBalance" 
xml-resource="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml"/>
+
+        <iterate entry="acctgTransEntry" list="acctgTransEntryList">
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="C">
+               <assert>
+                    <if-compare field="acctgTransEntry.glAccountTypeId" 
operator="equals" value="ACCREC_UNAPPLIED"/>
+                    <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="126000"/>
+                </assert>
+            </if-compare>
+            <if-compare field="acctgTransEntry.debitCreditFlag" 
operator="equals" value="D">
+                <assert>
+                    <if-compare field="acctgTransEntry.glAccountId" 
operator="equals" value="111100"/>
+                </assert>
+            </if-compare>
+        </iterate>
+        <check-errors/>
+    </simple-method>
+
+</simple-methods>

Propchange: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
------------------------------------------------------------------------------
    svn:keywords = Date Rev Author URL Id

Propchange: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/applications/accounting/testdef/accountingtests.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/testdef/accountingtests.xml?rev=1220339&r1=1220338&r2=1220339&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/testdef/accountingtests.xml (original)
+++ ofbiz/trunk/applications/accounting/testdef/accountingtests.xml Sun Dec 18 
06:27:29 2011
@@ -27,9 +27,14 @@
     </test-case>
 
 
-    <test-case case-name="accounting-tests"><junit-test-suite 
class-name="org.ofbiz.accounting.test.FinAccountTests"/></test-case>
+    <test-case case-name="accounting-tests">
+        <junit-test-suite 
class-name="org.ofbiz.accounting.test.FinAccountTests"/>
+    </test-case>
 
-    <test-case case-name="auto-accounting-transaction-tests">
-        <simple-method-test 
location="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTests.xml"/>
+    <test-case case-name="auto-accounting-transaction-tests-sales">
+        <simple-method-test 
location="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsSales.xml"/>
+    </test-case>
+    <test-case case-name="auto-accounting-transaction-tests-purchase">
+        <simple-method-test 
location="component://accounting/script/org/ofbiz/accounting/test/AutoAcctgTransTestsPurchase.xml"/>
     </test-case>
 </test-suite>


Reply via email to