Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0024768Openbravo ERP09. Financial managementpublic2013-09-13 12:562013-10-22 23:42
vmromanos 
dmiguelez 
highminoralways
closedfixed 
20Debian 5.0
pi 
3.0MP29 
pramakrishnan
Core
No
0024768: Payment Monitor NullPointer Exception in method calculateAmounts()
The FIN_PaymentMonitorProcess class contains the public static method updateInvoice() which can be invoked from outside of the class.
This method calls the calculateAmounts() which uses the "logger" variable in some flows. In this case we will get a NullPointer Exception because this variable is set in a non static method [execute()], so it is not initialized at this point if we use the FIN_PaymentMonitorProcess.updateInvoice() method.

Apart from that, the class has hardcoded messages like:
"ERROR Invoice " + invoice.getDocumentNo()
              + ": wrong payment plan info, paid amount is "
              + paymentSchedule.getPaidAmount().toPlainString() + " when it should be "
              + paid.toPlainString()

These messages should be declared in the application dictionary instead.
Not necessary
Easiest solution: add if (logger != null) before using the logger. Example:
 if (paymentSchedule.getPaidAmount().compareTo(paid) != 0) {
        if (logger != null) {
          logger.log("ERROR Invoice " + invoice.getDocumentNo()
              + ": wrong payment plan info, paid amount is "
              + paymentSchedule.getPaidAmount().toPlainString() + " when it should be "
              + paid.toPlainString());
        }
        paymentSchedule.setPaidAmount(paid);
        OBDal.getInstance().save(paymentSchedule);
      }

Hardest solution: refactor the class to avoid this kind of problems

Don't forget to add the messages to the Application Dictionary
No tags attached.
related to defect 00247783.0MP29 closed pramakrishnan Payment Monitor doesn't udpate invoice status when voiding a payment 
Issue History
2013-09-13 12:56vmromanosNew Issue
2013-09-13 12:56vmromanosAssigned To => dmiguelez
2013-09-13 12:56vmromanosModules => Core
2013-09-13 12:56vmromanosTriggers an Emergency Pack => No
2013-09-16 12:59vmromanosRelationship addedrelated to 0024778
2013-09-16 13:00vmromanosNote Added: 0061167
2013-09-16 13:42jonalegriaesarteTarget Version3.0MP28 => 3.0MP29
2013-10-22 10:01hgbotCheckin
2013-10-22 10:01hgbotNote Added: 0061839
2013-10-22 10:01hgbotStatusnew => resolved
2013-10-22 10:01hgbotResolutionopen => fixed
2013-10-22 10:01hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/0c6559f88e5ab2d45a7c1e3a0a5ce801c05127a3 [^]
2013-10-22 10:02pramakrishnanReview Assigned To => pramakrishnan
2013-10-22 10:02pramakrishnanNote Added: 0061841
2013-10-22 10:02pramakrishnanStatusresolved => closed
2013-10-22 23:42hudsonbotCheckin
2013-10-22 23:42hudsonbotNote Added: 0061859

Notes
(0061167)
vmromanos   
2013-09-16 13:00   
See 0024778 for a proposed patch
(0061839)
hgbot   
2013-10-22 10:01   
Repository: erp/devel/pi
Changeset: 0c6559f88e5ab2d45a7c1e3a0a5ce801c05127a3
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Mon Oct 21 12:26:36 2013 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/0c6559f88e5ab2d45a7c1e3a0a5ce801c05127a3 [^]

Fixes Issue 24778, Fixes Issue 24768

Payment Monitor doesn't udpate invoice status when voiding a payment
Payment Monitor NullPointer Exception in method calculateAmounts()

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentMonitorProcess.java
---
(0061841)
pramakrishnan   
2013-10-22 10:02   
Code Review + Testing - OK.
(0061859)
hudsonbot   
2013-10-22 23:42   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/a362c560793b [^]

Maturity status: Test