From e3fdbc2ece54e209f449e6bf2ae4c19e11690b8c Mon Sep 17 00:00:00 2001 From: Ashish Vijaywargiya Date: Thu, 3 Dec 2009 10:59:07 +0000 Subject: [PATCH] Applied patch from jira issue OFBIZ-3284 - Error at page - https://demo.ofbiz.org/ar/control/FindArInvoices. After doing research on this error I got exact steps to produce this error, reason of the error and solution for the error. Here are my findings: Steps to reproduce the error: 1) Start placing sales order from Order manager application by taking DemoCustomer. 2) Add any two products into the cart, choose shipping address and shipping method. 3) And then land on Order terms screens. Now select Term Type = Payment (net days) or any of its subtype. 4) Do not enter Term days and click on add button. 5) Select offline payment and create your order. 6) Now from payment section of order detail page, click on "Receive Payment" button and receive payment for Personal check by entering the amount and clicking on save button. 7) Complete the order by clicking on "Quick ship entire order" button on Action block. 8) Note the Invoice Id created and go to Find Invoices screen of AR by accessing https://demo.ofbiz.org/ar/control/FindArInvoices 9) Enter the Invoice ID and click on search, You will find error page. Reason of error: 1) getInvoicePaymentInfoList Service returns error (in ListInvoices.ftl) for invoices of some specific order in which Term type = Payment (net days) or any of its subtype and user forgot to enter Term days. 2) Due to this reason code breaks while calling getDayEnd class method inside getInvoicePaymentInfoList simple method of PaymentServies.xml Solution of error: 1) I have handled this situation by adding validation on Order terms screen . 2) Validation is like if User selects, Term type = Payment (net days) or any of its subtype and not entered Term days , then Error message will be returned to user 3) Error message will prompt : Order Term Days is required for this term type. Thanks Divesh for the contribution. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@886738 13f79535-47bb-0310-9956-ffa450edef68 --- applications/order/config/OrderErrorUiLabels.xml | 3 +++ .../order/shoppingcart/ShoppingCartEvents.java | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/applications/order/config/OrderErrorUiLabels.xml b/applications/order/config/OrderErrorUiLabels.xml index 90c243947c..2de2ef5efa 100644 --- a/applications/order/config/OrderErrorUiLabels.xml +++ b/applications/order/config/OrderErrorUiLabels.xml @@ -1302,6 +1302,9 @@ วันเวลาที่กำหนดรายการสั่งซื้อ : ${orderTermDays} 订单条件天数:${orderTermDays} + + Order Term Days is required for this term type. + Order Term Type is required. El tipo de término del pedido es requerido. diff --git a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java index 3417c7b82a..43e1ea54ce 100644 --- a/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java +++ b/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java @@ -1184,6 +1184,8 @@ public class ShoppingCartEvents { String termDaysStr = request.getParameter("termDays"); String textValue = request.getParameter("textValue"); + GenericValue termType = null; + Delegator delegator = (Delegator) request.getAttribute("delegator"); BigDecimal termValue = null; Long termDays = null; @@ -1192,6 +1194,18 @@ public class ShoppingCartEvents { request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderOrderTermTypeIsRequired", locale)); return "error"; } + + try { + termType = delegator.findOne("TermType", UtilMisc.toMap("termTypeId", termTypeId), false); + } catch (GenericEntityException gee) { + request.setAttribute("_ERROR_MESSAGE_", gee.getMessage()); + return "error"; + } + + if (("FIN_PAYMENT_TERM".equals(termTypeId) && UtilValidate.isEmpty(termDaysStr)) || (UtilValidate.isNotEmpty(termType) && "FIN_PAYMENT_TERM".equals(termType.get("parentTypeId")) && UtilValidate.isEmpty(termDaysStr))) { + request.setAttribute("_ERROR_MESSAGE_", UtilProperties.getMessage(resource_error, "OrderOrderTermDaysIsRequired", locale)); + return "error"; + } if (UtilValidate.isNotEmpty(termValueStr)) { try {