This is an automated email from the ASF dual-hosted git repository.
pawan 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 1b637fa Improved: Converted testBillingAppl test from XML to Groovy(OFBIZ-11558) 1b637fa is described below commit 1b637fae5cde0d8e91a3519a353fa7ba9b172e32 Author: Pawan Verma <[hidden email]> AuthorDate: Sun Jun 14 14:26:42 2020 +0530 Improved: Converted testBillingAppl test from XML to Groovy(OFBIZ-11558) Thanks: Rohit for your contribution. --- .../minilang/test/PaymentApplicationTests.xml | 51 ---------------------- .../accounting/PaymentApplicationTests.groovy | 35 ++++++++++++++- 2 files changed, 34 insertions(+), 52 deletions(-) diff --git a/applications/accounting/minilang/test/PaymentApplicationTests.xml b/applications/accounting/minilang/test/PaymentApplicationTests.xml index f44a555..8dbdb9c 100644 --- a/applications/accounting/minilang/test/PaymentApplicationTests.xml +++ b/applications/accounting/minilang/test/PaymentApplicationTests.xml @@ -21,57 +21,6 @@ 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"> - <simple-method method-name="testBillingAppl" short-description="test the application of a payment against an billing account" login-required="false"> - <!-- from the test data --> - <set field="serviceInMap.paymentId" value="appltest10000"/> - <set field="serviceInMap.billingAccountId" value="appltest10000"/> - - <entity-one entity-name="UserLogin" value-field="userLogin"> - <field-map field-name="userLoginId" value="system"/> - </entity-one> - - <set field="serviceInMap.userLogin" from-field="userLogin"/> - <call-service service-name="createPaymentApplication" in-map-name="serviceInMap" include-user-login="false"> - <result-to-field result-name="amountApplied"/> - <result-to-field result-name="paymentApplicationId"/> - </call-service> - <entity-one entity-name="PaymentApplication" value-field="paymentApplication"> - <field-map field-name="paymentApplicationId" from-field="paymentApplicationId"/> - </entity-one> - <call-class-method method-name="getPaymentNotApplied" class-name="org.apache.ofbiz.accounting.payment.PaymentWorker" ret-field="notAppliedPayment"> - <field field="delegator" type="org.apache.ofbiz.entity.Delegator"/> - <field field="serviceInMap.paymentId"/> - </call-class-method> - <entity-one entity-name="Payment" value-field="payment"> - <field-map field-name="paymentId" from-field="serviceInMap.paymentId"/> - </entity-one> - <assert> - <not><if-empty field="paymentApplication"/></not> - <if-compare-field field="paymentApplication.billingAccountId" operator="equals" to-field="serviceInMap.billingAccountId"/> - <if-compare-field field="paymentApplication.paymentId" operator="equals" to-field="serviceInMap.paymentId"/> - <if-compare-field field="paymentApplication.amountApplied" operator="equals" to-field="payment.amount"/> - </assert> - <check-errors/> - <!-- both payment and invoice should be completely applied --> - <call-class-method method-name="getPaymentNotApplied" class-name="org.apache.ofbiz.accounting.payment.PaymentWorker" ret-field="notAppliedPayment"> - <field field="delegator" type="org.apache.ofbiz.entity.Delegator"/> - <field field="serviceInMap.paymentId"/> - </call-class-method> - <entity-one entity-name="BillingAccount" value-field="billingAccount"> - <field-map field-name="billingAccountId" from-field="serviceInMap.billingAccountId"/> - </entity-one> - <call-class-method method-name="getBillingAccountBalance" class-name="org.apache.ofbiz.order.order.OrderReadHelper" ret-field="appliedBillling"> - <field field="billingAccount" type="GenericValue"/> - </call-class-method> - <set field="zero" value="0" type="BigDecimal"/> - <assert> - <if-compare-field operator="equals" field="notAppliedPayment" to-field="zero"/> - <if-compare-field operator="equals" field="appliedBilling" to-field="paymentAmount"/> - </assert> - <check-errors/> - <remove-value value-field="paymentApplication"/> - </simple-method> - <simple-method method-name="testTaxGeoId" short-description="test the application of a payment against a tax geo id" login-required="false"> <!-- from the test data --> <set field="serviceInMap.paymentId" value="appltest10000"/> diff --git a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy index 874f3f6..c932100 100644 --- a/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy +++ b/applications/accounting/src/main/groovy/org/apache/ofbiz/accounting/PaymentApplicationTests.groovy @@ -20,11 +20,11 @@ package org.apache.ofbiz.accounting 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 import org.apache.ofbiz.accounting.invoice.InvoiceWorker import org.apache.ofbiz.accounting.payment.PaymentWorker +import org.apache.ofbiz.order.order.OrderReadHelper class PaymentApplicationTests extends OFBizTestCase { @@ -90,4 +90,37 @@ class PaymentApplicationTests extends OFBizTestCase { assert notAppliedToPayment == BigDecimal.ZERO delegator.removeAll('PaymentApplication') } + + void testBillingAppl() { + Map serviceInMap = [:] + //from the test data + serviceInMap.paymentId = "appltest10000" + serviceInMap.billingAccountId = "appltest10000" + serviceInMap.userLogin = userLogin + Map serviceResult = dispatcher.runSync('createPaymentApplication', serviceInMap) + assert ServiceUtil.isSuccess(serviceResult) + + GenericValue paymentApplication = from('PaymentApplication') + .where('paymentApplicationId', serviceResult.paymentApplicationId).queryOne() + assert paymentApplication + + BigDecimal notAppliedPayment = PaymentWorker.getPaymentNotApplied(delegator, serviceInMap.paymentId) + + GenericValue payment = from('Payment').where('paymentId', serviceInMap.paymentId).queryOne() + assert payment + + assert paymentApplication !=null + assert paymentApplication.billingAccountId == serviceInMap.billingAccountId + assert paymentApplication.paymentId == serviceInMap.paymentId + assert paymentApplication.amountApplied == payment.amount + // both payment and invoice should be completely applied + notAppliedPayment = PaymentWorker.getPaymentNotApplied(delegator, serviceInMap.paymentId) + + GenericValue billingAccount = from('BillingAccount').where('billingAccountId', serviceInMap.billingAccountId).queryOne() + BigDecimal appliedBillling= OrderReadHelper.getBillingAccountBalance(billingAccount) + assert appliedBillling + + assert notAppliedPayment == BigDecimal.ZERO + delegator.removeAll('PaymentApplication') + } } |
Free forum by Nabble | Edit this page |