[ofbiz-framework] branch trunk updated: Improved: Convert AutoInvoiceTests.xml to Groovy (OFBIZ-11531)

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: Improved: Convert AutoInvoiceTests.xml to Groovy (OFBIZ-11531)

akashjain
This is an automated email from the ASF dual-hosted git repository.

akashjain 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 f764266  Improved: Convert AutoInvoiceTests.xml to Groovy (OFBIZ-11531)
f764266 is described below

commit f764266d171a68968f73d2c8349c174b352b2af1
Author: Akash Jain <[hidden email]>
AuthorDate: Thu Jul 2 12:20:18 2020 +0530

    Improved: Convert AutoInvoiceTests.xml to Groovy (OFBIZ-11531)
   
    Thanks, Rohit Hukkeri for the report.
---
 .../accounting/minilang/test/AutoInvoiceTests.xml  | 248 ---------------------
 .../ofbiz/accounting/AutoInvoiceTests.groovy       | 195 ++++++++++++++++
 applications/accounting/testdef/invoicetests.xml   |   1 -
 3 files changed, 195 insertions(+), 249 deletions(-)

diff --git a/applications/accounting/minilang/test/AutoInvoiceTests.xml b/applications/accounting/minilang/test/AutoInvoiceTests.xml
deleted file mode 100644
index 833d11c..0000000
--- a/applications/accounting/minilang/test/AutoInvoiceTests.xml
+++ /dev/null
@@ -1,248 +0,0 @@
-<?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"
-        xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
-
-    <!-- Test case for Commission Run -->
-    <simple-method method-name="testCommissionRun" short-description="Test case for Commission Run" login-required="false">
-
-        <!-- Precondition : For Creating Commission invoice following data should be there :
-                1 ) Sales invoices with paid status.(invoiceId = "8100")
-                2 ) Sales Representative with agreement to Company on product (DemoCustAgent and DemoRepAll). -->
-        <!-- Postcondition :
-                1 ) Two commission will be creating for the parties DemoCustAgent and DemoRepAll (like 10000 and 10001 invoiceId).
-                2 ) Its amountTotal will be same as commission cost of associated products. -->
-
-        <set field="invoiceId" value="8100"/>
-        <set field="invoiceIds[]" from-field="invoiceId"/>
-        <set field="partyIds[]" value="DemoRepAll"/>
-        <set field="partyIds[]" value="DemoCustAgent"/>
-        <set field="partyIds[]" value="DemoRepStore"/>
-        <set field="invoiceTotal" type="BigDecimal" value="0"/>
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-        <entity-and  entity-name="InvoiceItem" list="invoiceItems">
-            <field-map field-name="invoiceId" from-field="invoiceId"/>
-        </entity-and>
-        <iterate list="invoiceItems" entry="invoiceItem">
-            <if-compare field="invoiceItem.productId" operator="equals" value="WG-9943-B3">
-                <set field="invoiceTotal" value="${invoiceTotal + (invoiceItem.quantity * (invoiceItem.amount * 3 / 100 + 1))}" type="BigDecimal"/>
-            </if-compare>
-        </iterate>
-        <set field="createCommissionInvoicesMap.invoiceIds" from-field="invoiceIds"/>
-        <set field="createCommissionInvoicesMap.partyIds" from-field="partyIds"/>
-        <set field="createCommissionInvoicesMap.userLogin" from-field="userLogin"/>
-        <call-service service-name="createCommissionInvoices"  in-map-name="createCommissionInvoicesMap">
-            <result-to-field result-name="invoicesCreated"/>
-        </call-service>
-        <assert>
-            <not><if-empty field="invoicesCreated"/></not>
-        </assert>
-        <check-errors/>
-        <iterate list="invoicesCreated" entry="invoice">
-            <call-class-method method-name="getInvoiceTotal" ret-field="amountTotal" class-name="org.apache.ofbiz.accounting.invoice.InvoiceWorker">
-                <field field="delegator" type="org.apache.ofbiz.entity.Delegator"/>
-                <field field="invoice.commissionInvoiceId" type="String"/>
-            </call-class-method>
-            <assert>
-                <or>
-                    <if-compare-field field="amountTotal" operator="equals" to-field="invoiceTotal"/>
-                </or>
-            </assert>
-            <check-errors/>
-        </iterate>
-        <log level="info" message="Commission Invoice ${invoicesCreated} is created successfully for ${partyIds}"/>
-    </simple-method>
-
-    <!--Test case to verify GL postings for Cancel Invoice process-->
-    <simple-method method-name="testGlPostingOnCancelInvoice" short-description="Test case to verify GL postings for Cancel Invoice functionality" login-required="false">
-        <!-- Precondition :
-            * Invoice is in ready status so accounting transaction is already posted to the GL
-            * GL Accounts associated with Invoice :8008 are ACCOUNTS PAYABLE and UNINVOICED ITEM RECEIPTS
-            * Credit in account 210000 - ACCOUNTS PAYABLE ;debitTotal $303.41 ; creditTotal:$1651.7 ; debitCreditDifference : $ -1348.42
-            * Debit in account 214000 - UNINVOICED ITEM RECEIPTS;debitTotal :$408 ; creditTotal:$48 ; debitCreditDifference : $360
-        -->
-
-        <!-- Post condition : After Cancel Invoice process reverse accounting transactions are automatically posted to the GL.
-            * ACCOUNTS PAYABLE 210000  - debitTotal $351.41 ; creditTotal:$1651.7 ; debitCreditDifference : $ -1300
-            * UNINVOICED ITEM RECEIPTS 214000 - debitTotal :$408 ; creditTotal:$96 ; debitCreditDifference : $312
-        -->
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-
-        <now-timestamp field="nowTimestamp"/>
-        <set field="findCustomTimePeriodsMap.userLogin" from-field="userLogin"/>
-        <set field="findCustomTimePeriodsMap.findDate" from-field="nowTimestamp" type="Timestamp"/>
-        <set field="findCustomTimePeriodsMap.organizationPartyId" value="Company"/>
-        <call-service service-name="findCustomTimePeriods" in-map-name="findCustomTimePeriodsMap">
-            <result-to-field result-name="customTimePeriodList"/>
-        </call-service>
-        <first-from-list list="customTimePeriodList" entry="customTimePeriod"/>
-
-        <set field="getAcctgTransEntriesAndTransTotalMap.userLogin" from-field="userLogin"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.organizationPartyId" value="Company"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.customTimePeriodStartDate" from-field="customTimePeriod.fromDate" type="Timestamp"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.customTimePeriodEndDate" from-field="customTimePeriod.thruDate" type="Timestamp"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="210000"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="payableDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="payableCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="payableDebitCreditDifference"/>
-        </call-service>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="214000"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="uninvoicedDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="uninvoicedCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="uninvoicedDebitCreditDifference"/>
-        </call-service>
-        <log level="info" message="BEFORE RUNNING CANCEL INVOICE : ACCOUNTS PAYABLE ;debitTotal :${payableDebitTotal} ; creditTotal:${payableCreditTotal} ; debitCreditDifference : ${payableDebitCreditDifference}"/>
-        <log level="info" message="BEFORE RUNNING CANCEL INVOICE :UNINVOICED RECEIPTS;debitTotal :${uninvoicedDebitTotal} ; creditTotal:${uninvoicedCreditTotal} ; debitCreditDifference : ${uninvoicedDebitCreditDifference}"/>
-        <set field="invoiceId" value="8008"/>
-        <set field="cancelInvoiceMap.userLogin" from-field="userLogin"/>
-        <set field="cancelInvoiceMap.invoiceId" from-field="invoiceId"/>
-        <call-service service-name="cancelInvoice" in-map-name="cancelInvoiceMap"/>
-
-        <set field="totalPayableDebitAmount" value="${payableDebitTotal + 48}" type="BigDecimal"/>
-        <set field="totalPayableDebitCreditDifference" value="${payableDebitCreditDifference + 48}" type="BigDecimal"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="210000"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="payableDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="payableCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="payableDebitCreditDifference"/>
-        </call-service>
-        <assert>
-            <if-compare-field field="totalPayableDebitAmount" operator="equals" to-field="payableDebitTotal" type="BigDecimal"/>
-            <if-compare-field field="totalPayableDebitCreditDifference" operator="equals" to-field="payableDebitCreditDifference" type="BigDecimal"/>
-        </assert>
-        <check-errors/>
-        <set field="totalUnInvoicedCreditAmount" value="${uninvoicedCreditTotal + 48}" type="BigDecimal"/>
-        <set field="totalUnInvoicedDebitCreditDifference" value="${uninvoicedDebitCreditDifference - 48}" type="BigDecimal"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="214000"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="uninvoicedDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="uninvoicedCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="uninvoicedDebitCreditDifference"/>
-        </call-service>
-        <assert>
-            <if-compare-field field="totalUnInvoicedCreditAmount" operator="equals" to-field="uninvoicedCreditTotal" type="BigDecimal"/>
-            <if-compare-field field="totalUnInvoicedDebitCreditDifference" operator="equals" to-field="uninvoicedDebitCreditDifference" type="BigDecimal"/>
-        </assert>
-        <check-errors/>
-        <log level="info" message="AFTER RUNNING CANCEL INVOICE : ACCOUNTS PAYABLE ;debitTotal :${payableDebitTotal} ; creditTotal:${payableCreditTotal} ; debitCreditDifference : ${payableDebitCreditDifference}"/>
-        <log level="info" message="AFTER RUNNING CANCEL INVOICE : UNINVOICED RECEIPTS ;debitTotal :${uninvoicedDebitTotal} ; creditTotal:${uninvoicedCreditTotal} ; debitCreditDifference : ${uninvoicedDebitCreditDifference}"/>
-    </simple-method>
-
-    <!--Test case to verify GL postings for Cancel Check Run process-->
-    <simple-method method-name="testGlPostingOnCancelCheckRun" short-description="Test case to verify GL postings for Cancel Check Run functionality" login-required="false">
-        <!-- Precondition :
-            * Two invoices are associated with PaymentGroupId 9000 which are 8001 and 8002
-            * Invoices are in ready status so accounting transactions are already posted to the GL
-            * GL Accounts associated with Invoices are ACCOUNTS PAYABLE (210000) and GENERAL CHECKING ACCOUNT (111100)
-        -->
-
-        <!-- Post condition : After Cancel Check Run process accounting transactions are automatically posted to the GL.
-            * ACCOUNTS PAYABLE 210000  - debitTotal increased of $82.86 ; creditTotal increased of $165.72 ; debitCreditDifference decreased of $82.86
-            * GENERAL CHECKING ACCOUNT 111100 - debitTotal increased of $82.86 ; debitCreditDifference increased of $82.86
-        -->
-        <entity-one entity-name="UserLogin" value-field="userLogin">
-            <field-map field-name="userLoginId" value="system"/>
-        </entity-one>
-
-        <now-timestamp field="nowTimestamp"/>
-        <set field="findCustomTimePeriodsMap.userLogin" from-field="userLogin"/>
-        <set field="findCustomTimePeriodsMap.findDate" from-field="nowTimestamp" type="Timestamp"/>
-        <set field="findCustomTimePeriodsMap.organizationPartyId" value="Company"/>
-        <call-service service-name="findCustomTimePeriods" in-map-name="findCustomTimePeriodsMap">
-            <result-to-field result-name="customTimePeriodList"/>
-        </call-service>
-        <first-from-list list="customTimePeriodList" entry="customTimePeriod"/>
-
-        <set field="getAcctgTransEntriesAndTransTotalMap.userLogin" from-field="userLogin"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.organizationPartyId" value="Company"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.customTimePeriodStartDate" from-field="customTimePeriod.fromDate" type="Timestamp"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.customTimePeriodEndDate" from-field="customTimePeriod.thruDate" type="Timestamp"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="210000"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="payableDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="payableCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="payableDebitCreditDifference"/>
-        </call-service>
-
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="111100"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="undepositedDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="undepositedCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="undepositedDebitCreditDifference"/>
-        </call-service>
-
-        <log level="info" message="BEFORE  RUNNING CANCEL CHECK RUN  : ACCOUNTS PAYABLE ;debitTotal :${payableDebitTotal} ; creditTotal:${payableCreditTotal} ; debitCreditDifference : ${payableDebitCreditDifference}"/>
-        <log level="info" message="BEFORE  RUNNING CANCEL CHECK RUN : UNDEPOSITED RECEIPTS ;debitTotal :${undepositedDebitTotal} ; creditTotal:${undepositedCreditTotal} ; debitCreditDifference : ${undepositedDebitCreditDifference}"/>
-
-        <set field="paymentGroupId" value="9000"/>
-        <set field="cancelCheckRunPaymentsMap.userLogin" from-field="userLogin"/>
-        <set field="cancelCheckRunPaymentsMap.paymentGroupId" from-field="paymentGroupId"/>
-        <call-service service-name="cancelCheckRunPayments" in-map-name="cancelCheckRunPaymentsMap"/>
-        <entity-and entity-name="PmtGrpMembrPaymentAndFinAcctTrans"  list="paymentGroupMemberAndTransList">
-            <field-map field-name="paymentGroupId"/>
-        </entity-and>
-        <first-from-list list="paymentGroupMemberAndTransList" entry="paymentGroupMemberAndTrans"/>
-        <if-compare field="paymentGroupMemberAndTrans.finAccountTransStatusId" operator="not-equals" value="FINACT_TRNS_APPROVED">
-
-        <set field="tempBig" value="82.86" type="BigDecimal"/><!-- Necessary, see OFBIZ-6386 -->
-        <set field="totalPayableDebitAmount" value="${payableDebitTotal + tempBig}" type="BigDecimal"/>
-        <set field="totalPayableCreditAmount" value="165.72" type="BigDecimal"/>
-        <set field="totalPayableCreditAmount" value="${payableCreditTotal + totalPayableCreditAmount}" type="BigDecimal"/>
-        <set field="totalPayableDebitCreditDifference" value="${payableDebitCreditDifference - tempBig}" type="BigDecimal"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="210000"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="payableDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="payableCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="payableDebitCreditDifference"/>
-        </call-service>
-
-        <assert>
-            <if-compare-field field="totalPayableDebitAmount" operator="equals" to-field="payableDebitTotal" type="BigDecimal"/>
-            <if-compare-field field="totalPayableCreditAmount" operator="equals" to-field="payableCreditTotal" type="BigDecimal"/>
-            <if-compare-field field="totalPayableDebitCreditDifference" operator="equals" to-field="payableDebitCreditDifference" type="BigDecimal"/>
-        </assert>
-        <check-errors/>
-        <set field="totalUndepositedDebitAmount" value="${undepositedDebitTotal + tempBig}" type="BigDecimal"/>
-        <set field="totalUndepositedDebitCreditDifference" value="${undepositedDebitCreditDifference + tempBig}" type="BigDecimal"/>
-        <set field="getAcctgTransEntriesAndTransTotalMap.glAccountId" value="111100"/>
-        <call-service service-name="getAcctgTransEntriesAndTransTotal" in-map-name="getAcctgTransEntriesAndTransTotalMap">
-            <result-to-field result-name="debitTotal" field="undepositedDebitTotal"/>
-            <result-to-field result-name="creditTotal" field="undepositedCreditTotal"/>
-            <result-to-field result-name="debitCreditDifference" field="undepositedDebitCreditDifference"/>
-        </call-service>
-        <assert>
-            <if-compare-field field="totalUndepositedDebitAmount" operator="equals" to-field="undepositedDebitTotal" type="BigDecimal"/>
-            <if-compare-field field="totalUndepositedDebitCreditDifference" operator="equals" to-field="undepositedDebitCreditDifference" type="BigDecimal"/>
-        </assert>
-        <check-errors/>
-
-        </if-compare>
-        <log level="info" message="AFTER  RUNNING CANCEL CHECK RUN: ACCOUNTS PAYABLE ;debitTotal :${payableDebitTotal} ; creditTotal:${payableCreditTotal} ; debitCreditDifference : ${payableDebitCreditDifference}"/>
-        <log level="info" message="AFTER  RUNNING CANCEL CHECK RUN  : UNDEPOSITED RECEIPTS ;debitTotal :${undepositedDebitTotal} ; creditTotal:${undepositedCreditTotal} ; debitCreditDifference : ${undepositedDebitCreditDifference}"/>
-    </simple-method>
-
-</simple-methods>
diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoInvoiceTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoInvoiceTests.groovy
index a3291fd..5f3d32a 100644
--- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoInvoiceTests.groovy
+++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/AutoInvoiceTests.groovy
@@ -20,8 +20,10 @@
  package org.apache.ofbiz.accounting;
 
 import org.apache.ofbiz.accounting.invoice.InvoiceWorker
+import org.apache.ofbiz.base.util.UtilDateTime
 import org.apache.ofbiz.entity.GenericValue
 import org.apache.ofbiz.entity.util.EntityQuery
+import org.apache.ofbiz.service.ServiceUtil
 import org.apache.ofbiz.service.testtools.OFBizTestCase
 
 class AutoInvoiceTests extends OFBizTestCase {
@@ -108,4 +110,197 @@ class AutoInvoiceTests extends OFBizTestCase {
         BigDecimal invoiceTotal = InvoiceWorker.getInvoiceTotal(invoice)
         assert  invoiceTotal == amount
     }
+
+    // Test case for Commission Run
+    void testCommissionRun() {
+        /*
+            Precondition : For Creating Commission invoice following data should be there :
+                1 ) Sales invoices with paid status.(invoiceId = "8100")
+                2 ) Sales Representative with agreement to Company on product (DemoCustAgent and DemoRepAll). -->
+            Postcondition :
+                1 ) Two commission will be creating for the parties DemoCustAgent and DemoRepAll (like 10000 and 10001 invoiceId).
+                2 ) Its amountTotal will be same as commission cost of associated products.
+        */
+        BigDecimal invoiceTotal = new BigDecimal('0')
+        BigDecimal amountTotal = new BigDecimal('0')
+
+        List<GenericValue> invoiceItems = from('InvoiceItem')
+                .where('invoiceId', '8100')
+                .queryList()
+        assert invoiceItems
+
+        for (GenericValue invoiceItem : invoiceItems) {
+            if (invoiceItem.productId && 'WG-9943-B3'.equals(invoiceItem.productId)) {
+                invoiceTotal = invoiceTotal.add(invoiceItem.quantity * (invoiceItem.amount * 0.03 + 1))
+            }
+        }
+
+        Map serviceCtx = [
+                invoiceIds: ['8100'],
+                partyIds: ['DemoRepAll', 'DemoCustAgent', 'DemoRepStore'],
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('createCommissionInvoices', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.invoicesCreated
+
+        for (Map invoice : serviceResult.invoicesCreated) {
+            amountTotal = amountTotal.add(InvoiceWorker.getInvoiceTotal(delegator, invoice.commissionInvoiceId))
+        }
+        assert invoiceTotal.compareTo(amountTotal) == 0
+    }
+
+    // Test case to verify GL postings for Cancel Invoice process
+    void testGlPostingOnCancelInvoice() {
+        /*
+            Precondition :
+              * Invoice is in ready status so accounting transaction is already posted to the GL
+              * GL Accounts associated with Invoice :8008 are ACCOUNTS PAYABLE and UNINVOICED ITEM RECEIPTS
+              * Credit in account 210000 - ACCOUNTS PAYABLE ;debitTotal $303.41 ; creditTotal:$1651.7 ; debitCreditDifference : $ -1348.42
+              * Debit in account 214000 - UNINVOICED ITEM RECEIPTS;debitTotal :$408 ; creditTotal:$48 ; debitCreditDifference : $360
+
+            Post condition : After Cancel Invoice process reverse accounting transactions are automatically posted to the GL.
+              * ACCOUNTS PAYABLE 210000  - debitTotal $351.41 ; creditTotal:$1651.7 ; debitCreditDifference : $ -1300
+              * UNINVOICED ITEM RECEIPTS 214000 - debitTotal :$408 ; creditTotal:$96 ; debitCreditDifference : $312
+        */
+        Map serviceCtx = [
+                organizationPartyId: 'Company',
+                findDate: UtilDateTime.nowTimestamp(),
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('findCustomTimePeriods', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.customTimePeriodList
+        GenericValue customTimePeriod = (serviceResult.customTimePeriodList).get(0)
+
+        serviceCtx.clear()
+        serviceResult.clear()
+        serviceCtx = [
+                organizationPartyId: 'Company',
+                customTimePeriodStartDate: customTimePeriod.fromDate,
+                customTimePeriodEndDate: customTimePeriod.thruDate,
+                glAccountId: '210000',
+                userLogin: userLogin
+        ]
+        serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        BigDecimal payableDebitTotal = serviceResult.debitTotal
+        BigDecimal payableCreditTotal = serviceResult.creditTotal
+        BigDecimal payableDebitCreditDifference = serviceResult.debitCreditDifference
+
+        serviceResult.clear()
+        serviceCtx.glAccountId = '214000'
+        serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        BigDecimal uninvoicedDebitTotal = serviceResult.debitTotal
+        BigDecimal uninvoicedCreditTotal = serviceResult.creditTotal
+        BigDecimal uninvoicedDebitCreditDifference = serviceResult.debitCreditDifference
+
+        serviceResult.clear()
+        Map cancelInvoiceCtx = [
+                invoiceId: '8008',
+                userLogin: userLogin
+        ]
+        serviceResult = dispatcher.runSync('cancelInvoice', cancelInvoiceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        BigDecimal totalPayableDebitAmount = payableDebitTotal.add(new BigDecimal('48'))
+        BigDecimal totalPayableDebitCreditDifference = payableDebitCreditDifference.add(new BigDecimal('48'))
+        serviceResult.clear()
+        serviceCtx.glAccountId = '210000'
+        serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert totalPayableDebitAmount.compareTo(serviceResult.debitTotal) == 0
+        assert totalPayableDebitCreditDifference.compareTo(serviceResult.debitCreditDifference) == 0
+
+        BigDecimal totalUnInvoicedCreditAmount = uninvoicedCreditTotal.add(new BigDecimal('48'))
+        BigDecimal totalUnInvoicedDebitCreditDifference = uninvoicedDebitCreditDifference.subtract(new BigDecimal('48'))
+        serviceResult.clear()
+        serviceCtx.glAccountId = '214000'
+        serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert totalUnInvoicedCreditAmount.compareTo(serviceResult.creditTotal) == 0
+        assert totalUnInvoicedDebitCreditDifference.compareTo(serviceResult.debitCreditDifference) == 0
+    }
+
+    // Test case to verify GL postings for Cancel Check Run process
+    void testGlPostingOnCancelCheckRun() {
+        /*
+            Precondition :
+              * Two invoices are associated with PaymentGroupId 9000 which are 8001 and 8002
+              * Invoices are in ready status so accounting transactions are already posted to the GL
+              * GL Accounts associated with Invoices are ACCOUNTS PAYABLE (210000) and GENERAL CHECKING ACCOUNT (111100)
+
+            Post condition : After Cancel Check Run process accounting transactions are automatically posted to the GL.
+              * ACCOUNTS PAYABLE 210000  - debitTotal increased of $82.86 ; creditTotal increased of $165.72 ; debitCreditDifference decreased of $82.86
+              * GENERAL CHECKING ACCOUNT 111100 - debitTotal increased of $82.86 ; debitCreditDifference increased of $82.86
+        */
+        Map serviceCtx = [
+                organizationPartyId: 'Company',
+                findDate: UtilDateTime.nowTimestamp(),
+                userLogin: userLogin
+        ]
+        Map serviceResult = dispatcher.runSync('findCustomTimePeriods', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        assert serviceResult.customTimePeriodList
+        GenericValue customTimePeriod = (serviceResult.customTimePeriodList).get(0)
+
+        serviceCtx.clear()
+        serviceResult.clear()
+        serviceCtx = [
+                organizationPartyId: 'Company',
+                customTimePeriodStartDate: customTimePeriod.fromDate,
+                customTimePeriodEndDate: customTimePeriod.thruDate,
+                glAccountId: '210000',
+                userLogin: userLogin
+        ]
+        serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        BigDecimal payableDebitTotal = serviceResult.debitTotal
+        BigDecimal payableCreditTotal = serviceResult.creditTotal
+        BigDecimal payableDebitCreditDifference = serviceResult.debitCreditDifference
+
+        serviceResult.clear()
+        serviceCtx.glAccountId = '111100'
+        serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+        BigDecimal undepositedDebitTotal = serviceResult.debitTotal
+        BigDecimal undepositedCreditTotal = serviceResult.creditTotal
+        BigDecimal undepositedDebitCreditDifference = serviceResult.debitCreditDifference
+
+        serviceResult.clear()
+        Map cancelCheckRunPaymentsCtx = [
+                paymentGroupId: '9000',
+                userLogin: userLogin
+        ]
+        serviceResult = dispatcher.runSync('cancelCheckRunPayments', cancelCheckRunPaymentsCtx)
+        assert ServiceUtil.isSuccess(serviceResult)
+
+        GenericValue paymentGroupMemberAndTrans = from('PmtGrpMembrPaymentAndFinAcctTrans')
+                .where('paymentGroupId', '9000')
+                .queryFirst()
+        if (paymentGroupMemberAndTrans && !'FINACT_TRNS_APPROVED'.equals(paymentGroupMemberAndTrans.finAccountTransStatusId)) {
+            BigDecimal tempBig = new BigDecimal('82.86')
+
+            BigDecimal totalPayableDebitAmount = tempBig.add(payableDebitTotal)
+            BigDecimal totalPayableCreditAmount = new BigDecimal('165.72').add(payableCreditTotal)
+            BigDecimal totalPayableDebitCreditDifference = payableDebitCreditDifference.subtract(tempBig)
+            serviceResult.clear()
+            serviceCtx.glAccountId = '210000'
+            serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+            assert ServiceUtil.isSuccess(serviceResult)
+            assert totalPayableDebitAmount.compareTo(serviceResult.debitTotal) == 0
+            assert totalPayableCreditAmount.compareTo(serviceResult.creditTotal) == 0
+            assert totalPayableDebitCreditDifference.compareTo(serviceResult.debitCreditDifference) == 0
+
+            BigDecimal totalUndepositedDebitAmount = tempBig.add(undepositedDebitTotal)
+            BigDecimal totalUndepositedDebitCreditDifference = tempBig.add(undepositedDebitCreditDifference)
+            serviceResult.clear()
+            serviceCtx.glAccountId = '111100'
+            serviceResult = dispatcher.runSync('getAcctgTransEntriesAndTransTotal', serviceCtx)
+            assert ServiceUtil.isSuccess(serviceResult)
+            assert totalUndepositedDebitAmount.compareTo(serviceResult.debitTotal) == 0
+            assert totalUndepositedDebitCreditDifference.compareTo(serviceResult.debitCreditDifference) == 0
+        }
+    }
 }
diff --git a/applications/accounting/testdef/invoicetests.xml b/applications/accounting/testdef/invoicetests.xml
index a3e8388..f2f7cfb 100644
--- a/applications/accounting/testdef/invoicetests.xml
+++ b/applications/accounting/testdef/invoicetests.xml
@@ -23,7 +23,6 @@
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/test-suite.xsd">
 
     <test-group case-name="auto-invoice-tests">
-        <simple-method-test location="component://accounting/minilang/test/AutoInvoiceTests.xml"/>
         <junit-test-suite class-name="org.apache.ofbiz.accounting.AutoInvoiceTests"/>
     </test-group>
     <test-case case-name="invoice-per-shipment-tests">