[ 
https://issues.apache.org/jira/browse/OFBIZ-2790?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12748143#action_12748143
 ] 

Ahmed Dini commented on OFBIZ-2790:
-----------------------------------

Hello Sumit,

Thanks for your feedback.   I have made the changes you pointed out.  

You said you had a doubt about the logic of the file. What I was trying to do 
is to add a row to the  ListPayments form and display the total amount of the 
returned payments in that row.  I could not figure out a possible way of adding 
a row to the form because the rows of the form are being populated from a 
'listIt'  (EntityListIterator).  The only way I could think of adding this row 
to the form is to manually add a new element to the 'listIt'.   But the 
'listIt' (EntityListIterator)'s 'add' method was designed not to allow manual 
addition of new elements (this means it only gets the result from the database) 
and if you try to add it manually it throws this error message 
"CursorListIterator currently only supports read-only access".

So what I did was I copied the content of 'listIt' into java.util.List object 
and added the total row manually  and then put the content of the new list 
object in the context with the name of 'listIt'.  Below is the 

1) For performance reasons do not use the EntityListIterator.hasNext() method, 
just call next() until it returns null.
  -   Done --
    while ((listValue = listIt.next()) != null) 

2) In your case - lastRowId != null never happen.
     - You were right, I removed it from the ListPayments form. 

3) I have a doubt in following assignment - 
      listValue.paymentId ="lastRowId";
      I think you want to code like - listValue.paymentId = lastRowId;
    -  This is still there, I couldn't think of any other way of making the 
paymnet Id unique other than to manually hard code a string value which could 
be evaluated in the Forms file. 

4) Please have a look at console - there are some errors are showing. They 
occurred in calculation of Outstanding amount. Please correct it.
   - Done, I added bsh:if(!lastRowId.equals(paymentId)) to stop the system for 
searching a payment Id with value of 'lastRowId".

5) No indentation require after - totalAmount = totalAmount + amount;
    - Done, 

6) Remove last three lines from file - /FindPaymentTotals.groovy
     - Done

7) Use BigDecimal's method for operations.
    - Done, for totalAmount.

8) Please have a look at your logic in groovy file, I have a doubt on it.
    - See the explanation above please.

9) Pleas verify your values in iteration.
    - I didn't get this.

Everything is working fine for me, except one problem which I think I have 
introduced after playing with EntityListIterator.  I keep getting the following 
error message, everytime I click on the Search button to search for new 
payments.

2009-08-26 21:12:35,139 (Finalizer) [ EntityListIterator.java:521:ERROR] ---- 
runtime exception report -------------------------------------------------- 
Error closing the SQLProcessor in finalize EntityListIterator Exception: 
java.lang.NullPointerException Message: null ---- stack trace 
--------------------------------------------------------------- 
java.lang.NullPointerException 
org.apache.commons.dbcp.managed.ManagedConnection.close(ManagedConnection.java:147)
 org.ofbiz.entity.jdbc.SQLProcessor.close(SQLProcessor.java:234) 
org.ofbiz.entity.util.EntityListIterator.close(EntityListIterator.java:140) 
org.ofbiz.entity.util.EntityListIterator.finalize(EntityListIterator.java:517) 
java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method) 
java.lang.ref.Finalizer.runFinalizer(Unknown Source) 
java.lang.ref.Finalizer.access$100(Unknown Source) 
java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) 
-------------------------------------------------------------------------------
 - 

Please find the attached patch. 

> Payment totals in Accounting
> ----------------------------
>
>                 Key: OFBIZ-2790
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-2790
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: accounting
>    Affects Versions: SVN trunk
>            Reporter: Ahmed Dini
>            Assignee: Anil K Patel
>             Fix For: SVN trunk
>
>         Attachments: paymentTotals.patch, paymentTotals.patch
>
>
> Under Accounting Manager --> Payments, Find Payments.  I thought it would be 
> a handy improvement if I display a total of the Amount fields of all payments 
> under the search result screen no matter what their status is. This new 
> improvement might not makes sense when payment status are mixed i.e. The 
> total of cancelled payments plus the total of received payments, but I thinks 
> it might make sense if you want to filter the query. i.e if you want the 
> total of all payments in NOT-PAID status by a particular party or customer. 
> Attached is patch which introduces a new groovy file namely  
> FindPaymentTotals.groovy and the modification of the existing 
> PaymentForms.xml.
> NB. Since this is my first major improvement for Ofbiz project, I might have 
> done things differently than most of the commiters or contributors expect. 
> Please let me know if I break Ofbiz coding conventions, I am willing to 
> improve the code. Otherwise the attached patch works fine and has passed all 
> my tests

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to