Author: ashish
Date: Thu Dec  3 10:59:07 2009
New Revision: 886738

URL: http://svn.apache.org/viewvc?rev=886738&view=rev
Log:
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. 

Modified:
    ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml
    
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java

Modified: ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml?rev=886738&r1=886737&r2=886738&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml (original)
+++ ofbiz/trunk/applications/order/config/OrderErrorUiLabels.xml Thu Dec  3 
10:59:07 2009
@@ -1302,6 +1302,9 @@
         <value 
xml:lang="th">วันเวลาที่กำหนดรายการสั่งซื้อ
 : ${orderTermDays}</value>
         <value xml:lang="zh">订单条件天数:${orderTermDays}</value>
     </property>
+    <property key="OrderOrderTermDaysIsRequired">
+        <value xml:lang="en">Order Term Days is required for this term type. 
</value>
+    </property>
     <property key="OrderOrderTermTypeIsRequired">
         <value xml:lang="en">Order Term Type is required. </value>
         <value xml:lang="es">El tipo de término del pedido es 
requerido.</value>

Modified: 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java?rev=886738&r1=886737&r2=886738&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
 (original)
+++ 
ofbiz/trunk/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartEvents.java
 Thu Dec  3 10:59:07 2009
@@ -1184,6 +1184,8 @@
         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 @@
             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 {


Reply via email to