Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0029619Openbravo ERPZ. Otherspublic2015-04-16 18:232015-04-20 14:20
ngarcia 
umartirena 
immediatemajoralways
closedfixed 
5
 
3.0PR15Q2 
vmromanos
Core
Production - Confirmed Stable
2014-06-19
3.0PR14Q3
https://code.openbravo.com/erp/devel/pi/rev/f94f08e02e3a [^]
Yes
0029619: Wrong amount in Used Credit Source tab when paying an invoice with credit and refunding the difference to the customer
Wrong amount in Used Credit Source tab when paying an invoice with credit and refunding the difference to the customer
As group admin role:
   Create a Payment In where you leave 100 EUR as credit to a Business Partner
   Create a Sales Invoice of 75 EUR for the same Business Partner
   Create a new Payment In, select the credit to use, the invoice to pay and Refund the amount to the Customer
   Check two payments are created:
      One with the refund that do not have any record in the Used Credit tab
      One with the invoice payment that has a record of 100 EUR in the Used Credit Source tab
   Post this last payment and check the difference of 25 is posted to Currency balancing account
No tags attached.
blocks defect 0029615 closed umartirena Wrong amount in Used Credit Source tab when paying an invoice with credit and refunding the difference to the customer 
Issue History
2015-04-16 19:38umartirenaTypedefect => backport
2015-04-16 19:38umartirenaTarget Version => 3.0PR15Q2
2015-04-17 14:25umartirenaAssigned ToTriage Finance => umartirena
2015-04-20 14:19hgbotCheckin
2015-04-20 14:19hgbotNote Added: 0076629
2015-04-20 14:19hgbotStatusscheduled => resolved
2015-04-20 14:19hgbotResolutionopen => fixed
2015-04-20 14:19hgbotFixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR15Q2/rev/05d86072ac4e72903089f8d363365f9472fabb26 [^]
2015-04-20 14:20vmromanosReview Assigned To => vmromanos
2015-04-20 14:20vmromanosNote Added: 0076631
2015-04-20 14:20vmromanosStatusresolved => closed

Notes
(0076629)
hgbot   
2015-04-20 14:19   
Repository: erp/backports/3.0PR15Q2
Changeset: 05d86072ac4e72903089f8d363365f9472fabb26
Author: Unai Martirena <unai.martirena <at> openbravo.com>
Date: Mon Apr 20 09:23:09 2015 +0200
URL: http://code.openbravo.com/erp/backports/3.0PR15Q2/rev/05d86072ac4e72903089f8d363365f9472fabb26 [^]

Fixes bug 29619: Correctly used credit when paying an invoice and refunding

There were two issues while managing this scenario:

[1] In 'addCredit' method inside AddPaymentActionHandler.java class, a loop of Credit to Use grid is done, creating Payment Credit Used records assigned to the new created payment of the invoice. This method was not taking into account that could be credit amount that exceeds the invoice amount (amount to be refunded) and it was assigning all the credit amount as used to the payment of the invoice. So the refund payment that is created right after was been left without any used credit payment.

[2] After fixing the previous method, the second issue appears. The 'updateUsedCredit' method inside FIN_PaymentProcess.java class retrieves all the payments of the business partner that has generated credit, and it assigns as used to the refund payment. The problem with this function is that before the Add Payment refactor it was not possible to select which credit payments we wanted to consume, it was only a total credit amount to be consumed and the system behind was being consuming any of them. But after the refactor it is possible to select the ones that want to be consumed.

In order to fix this last issue the selected credit line ids are added as a parameter to 'updateUsedCredit' method.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_AddPayment.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
---
(0076631)
vmromanos   
2015-04-20 14:20   
Code review + testing OK