Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0034992Openbravo ERPZ. Otherspublic2017-01-18 11:292017-04-01 12:07
maite 
collazoandy4 
urgentmajoralways
closedfixed 
5
 
3.0PR17Q2 
markmm82
Advanced Payables and Receivables Mngmt
No
0034992: Payment Plan deleted when Voiding an invoice which is prepaid via sales order
When an invoice related with a prepaid order is voided, payment plan info is deleted instead of creating a dummy payment

Moreover, in case prepaid amount is higher than invoice's amount POSTING error is found
1. Register Sales Order and add line for any product, qty=3, price=50 and tax=exempt. Process order with a total amount of 150
2. Run "Add payment" process from sales order and register prepayment for total amount of 150
3. Register Sales Invoice for same org and BP. Run "Create lines from" process and select previous order. Edit line to only invoice qty=1 and process invoice with total amount of 50. Post invoice and realize that accounting entry is correct
4. Run "Void" process from this invoice. Navigate to payment plan info and realize that no record exists
5. Access to Reversed Invoice and realize that also no info is found in Payment Plan tab.
6. Additionally, try to post this reserved invoice and "Process failed during execution" will be received (or Suspense account will be used in case it is configured)
No tags attached.
related to defect 00309713.0PR16Q1 closed aferraz When voiding an unpaid invoice, payment schedule details should be canceled instead of deleted 
causes defect 0036297 closed collazoandy4 Wrong schedule details information when Voiding an invoice which is prepaid via sales order 
? 34992.sql (10,402) 2017-03-21 12:36
https://issues.openbravo.com/file_download.php?file_id=10587&type=bug
Issue History
2017-01-18 11:29maiteNew Issue
2017-01-18 11:29maiteAssigned To => Triage Finance
2017-01-18 11:29maiteModules => Advanced Payables and Receivables Mngmt
2017-01-18 11:29maiteResolution time => 1486508400
2017-01-18 11:29maiteTriggers an Emergency Pack => No
2017-01-18 11:30maiteRelationship addedrelated to 0030971
2017-01-18 11:30maiteIssue Monitored: networkb
2017-01-18 21:15markmm82Assigned ToTriage Finance => collazoandy4
2017-01-26 15:54markmm82Assigned Tocollazoandy4 => AtulOpenbravo
2017-01-26 16:13collazoandy4Assigned ToAtulOpenbravo => collazoandy4
2017-01-26 16:21collazoandy4Statusnew => scheduled
2017-02-01 12:17psanjuanNote Added: 0093983
2017-02-01 13:20psanjuanNote Added: 0093986
2017-02-01 13:24psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14425
2017-02-01 13:35psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14426
2017-02-01 13:38psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14427
2017-02-01 13:44psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14428
2017-02-01 13:46psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14429
2017-02-06 21:51collazoandy4Note Added: 0094104
2017-02-07 13:35psanjuanNote Added: 0094123
2017-02-07 13:59psanjuanNote Edited: 0094123bug_revision_view_page.php?bugnote_id=0094123#r14513
2017-02-07 14:04psanjuanNote Edited: 0094104bug_revision_view_page.php?bugnote_id=0094104#r14515
2017-02-07 14:06psanjuanNote Edited: 0094123bug_revision_view_page.php?bugnote_id=0094123#r14516
2017-02-09 12:25psanjuanNote Added: 0094173
2017-02-09 12:40psanjuanNote Edited: 0094123bug_revision_view_page.php?bugnote_id=0094123#r14534
2017-02-09 12:41psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14535
2017-02-09 12:41psanjuanNote Deleted: 0094173
2017-02-09 12:41psanjuanNote Edited: 0094123bug_revision_view_page.php?bugnote_id=0094123#r14536
2017-02-09 12:44psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14537
2017-02-09 12:53psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14540
2017-02-09 12:58psanjuanNote Edited: 0093986bug_revision_view_page.php?bugnote_id=0093986#r14541
2017-03-04 00:19hgbotCheckin
2017-03-04 00:19hgbotNote Added: 0094753
2017-03-04 00:19hgbotStatusscheduled => resolved
2017-03-04 00:19hgbotResolutionopen => fixed
2017-03-04 00:19hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/321aa371a03d8177511afed5eb03c4792cfeaa39 [^]
2017-03-04 00:21markmm82Review Assigned To => markmm82
2017-03-04 00:21markmm82Note Added: 0094754
2017-03-04 00:21markmm82Statusresolved => closed
2017-03-04 00:21markmm82Fixed in Version => 3.0PR17Q2
2017-03-06 11:05maiteStatusclosed => new
2017-03-06 11:05maiteResolutionfixed => open
2017-03-06 11:05maiteFixed in Version3.0PR17Q2 =>
2017-03-15 20:21hudsonbotCheckin
2017-03-15 20:21hudsonbotNote Added: 0095269
2017-03-20 17:38markmm82Statusnew => scheduled
2017-03-20 17:41markmm82Statusscheduled => resolved
2017-03-20 17:41markmm82Resolutionopen => fixed
2017-03-20 17:42markmm82Note Added: 0095432
2017-03-20 17:42markmm82Statusresolved => closed
2017-03-20 17:42markmm82Fixed in Version => 3.0PR17Q2
2017-03-21 12:36aferrazFile Added: 34992.sql
2017-03-24 15:33hgbotCheckin
2017-03-24 15:33hgbotNote Added: 0095565
2017-03-25 01:51hudsonbotCheckin
2017-03-25 01:51hudsonbotNote Added: 0095581
2017-03-31 13:22hgbotCheckin
2017-03-31 13:22hgbotNote Added: 0095768
2017-04-01 12:07hudsonbotCheckin
2017-04-01 12:07hudsonbotNote Added: 0095782
2017-06-20 13:10maiteRelationship addedcauses 0036297

Notes
(0093983)
psanjuan   
2017-02-01 12:17   
Issue verified.
(0093986)
psanjuan   
2017-02-01 13:20   
(edited on: 2017-02-09 12:58)
Proposed Solution

Create a sales order for F&B España, Alimentos y Supermercados business partner.
Go to lines and select a product.
Enter Qty = 3, Net Unit Price = 50.00 and VAT = exempt 0%
Book the order and pay it. Check that Total Gross Amount = 150.00

Go to the payment in created and make sure that it has only one line with below
data:

Order number 10000237
Invoice empty
Invoiced Amount = Invoiced Amount = Received Amount = 150.00

Post it and verify that below posting is shown:
150.00 (5555) Partidas Pendientes Aplicación DEBIT
150.00 (4380) Anticipo de clientes CREDIT

Go to Sales Invoice window and create a new one for F&B España, Alimentos y Supermercados business partner. Use Create Lines From and select the order just created.

Go to lines and change Qty to 1. Complete the invoice.

Verify that:
- Payment Complete = Yes - this is OK
- Prepayment Amount = 150.00 - This is OK, but once the invoice is completed, it should changed to 50.00 because that is really the amount prepaid for the invoice.

Posting the invoice. Verify posting looks like the one below, which is OK.
50.00 (4380) Anticipo de clientes DEBIT
50.00 (7000) Venta de Mercaderias CREDIT

Write down sales invoice number, for instance 219. Void invoice 219.
Check that a reverse invoice has been created.

Verify that original invoice (invoice being voided 219) has below information:

- Payment Complete = Yes
- Prepayment Amount = 0.00

Go to Payment Plan tab and verify that it is not empty, because:

A "dummy" (zero) payment has been created for an amount = 0.00, including two lines, one line related to the invoice (+50.00) and the other one related to the reverse invoice (-50.00).

Payment Plan tab has below info:
Number of payments = 1
Expected Amount = 50.00
Received Amount = 50.00
Outstanding Amount = 0.00

Navigate to the reverse invoice for instance 10.

Verify that:
- Payment Complete = yes
- Prepayment Amount = 0.00

Add payment button is shown for the reverse invoice, while it should NOT be possible and in fact it is not possible to pay this reverse invoice anymore.
Payment button should not be there.

Navigate to Payment Plan tab of the reverse invoice. Verify it does have dummy payment related with below informaction:

Number of payments = 1
Expected Amount = -50.00
Received Amount = -50.00
Outstanding Amount = 0.00

Go the the original order, payment plan tab and verify that below information is shown:
Expected Amount = 150.00
Received Amount = 150.00
Outstanding Amount = 0.00

Go to Payment details and verify there is only one line with below info:

Expected Amount = 150.00
Received Amount = 150.00
Write-off Amount = 0.00


Post the reverse invoice and verify that below posting is shown:

100.00 (9040) Cuenta de Cuadre (suspense account) DEBIT
50.00 (7000) Venta de Mercaderias DEBIT
150.00 (4380) Anticipo de clientes CREDIT

This is NOT correct. Correct Posting is:

50.00 (7000) Venta de Mercaderias DEBIT
50.00 (4380) Anticipo de clientes CREDIT

(0094104)
collazoandy4   
2017-02-06 21:51   
(edited on: 2017-02-07 14:04)
Test Plan

Test Case 1

As F&B International Group Admin
 - Go to sales order and create a new record
    Busines partner: Alimentos y Supermercados business partner.
    Invoice terms: Inmediate

    Create a new line
      Product: Limonade
       Qty = 3
       Net Unit Price = 50.00
       Tax: Ventas exentas
     Remove the line in Basic Discount tab
    Book the order
    Add a payment and pay it
    Check that Total Gross Amount = 150.00

 - Go to Sales Invoice window and create a new record
    Busines partner: Alimentos y Supermercados
    Click on Create Lines From button and select the order just created.
    Edit the created line and change Qty to 1
    Complete the invoice
     Check that
      Payment Complete = Yes
      Prepaymetn Amount = 150.00
    Post the invoice
     Check in Account tab
       50.00 (4380) Anticipo de clientes DEBIT
       50.00 (7000) Venta de Mercaderias CREDIT
    Click on Reactivate button and select Void action and clic Ok button
     Check that
      - Payment Complete = Yes
      - Prepayment Amount = 0.00
      - Go to Payment Plan tab and verify it is empty
 - Go to the created reversed invoice
    Check that
     - Payment Complete = Yes
     - Payment Plan tab it is empty
    Post the reverse invoice
     Check that
      - 50.00 (7000) Venta de Mercaderias DEBIT
      - 50.00 (4380) Anticipo de clientes CREDIT

(0094123)
psanjuan   
2017-02-07 13:35   
(edited on: 2017-02-09 12:41)
Test Case 2

Repeat same test as above for a Purchase Order totally paid (as test case 1) and a Purchase Invoice being modified to 1 unit and then voided.


Test Case 3

Repeat same test as above for partially paid sales orders and purchase orders.

(0094753)
hgbot   
2017-03-04 00:19   
Repository: erp/devel/pi
Changeset: 321aa371a03d8177511afed5eb03c4792cfeaa39
Author: Armaignac <collazoandy4 <at> gmail.com>
Date: Wed Mar 01 10:45:48 2017 -0500
URL: http://code.openbravo.com/erp/devel/pi/rev/321aa371a03d8177511afed5eb03c4792cfeaa39 [^]

Fixes issue 34992: Voiding an invoice which is prepaid via sales order

When a prepaid invoice via sales order was voided the payment plan tab is empty,
the prepayment amount was wrong for both invoices and the created reversed invoice
paid state was also incorrect

Now a new method was created in ProcessInvoice to fix wrong data, the original and
reverse invoice prepayment amount it's 0, the reversal invoice is mark as paid,
also a dummy payment is created and processed for a 0 amount, including two lines,
one line related to the invoice (+50.00) and the other one related to the reverse
invoice (-50.00)

---
M modules/org.openbravo.advpaymentmngt/src-db/database/model/functions/APRM_GEN_PAYMENTSCHEDULE_INV.xml
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java
---
(0094754)
markmm82   
2017-03-04 00:21   
Code review + Testing OK
(0095269)
hudsonbot   
2017-03-15 20:21   
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/54e102bef53e [^]
Maturity status: Test
(0095432)
markmm82   
2017-03-20 17:42   
Code review + Testing OK
(0095565)
hgbot   
2017-03-24 15:33   
Repository: erp/devel/pi
Changeset: 41352442cc7ec6d2cc5f8327a8c825fdbfbf28d4
Author: Mark <markmm82 <at> gmail.com>
Date: Thu Mar 23 11:33:43 2017 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/41352442cc7ec6d2cc5f8327a8c825fdbfbf28d4 [^]

Related to issue 34992 and 34589: Code review improvements

Related to 34992: Taken into accounts invoices with negatives prepayments.
Replaced some loops by queries to improve the performance.

Related to 34589: Functionality covered by two loops to validate payment status
has been replaced by a query to improve the performance.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java
---
(0095581)
hudsonbot   
2017-03-25 01:51   
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/a169bf5db5fd [^]
Maturity status: Test
(0095768)
hgbot   
2017-03-31 13:22   
Repository: erp/devel/pi
Changeset: 4690240411138ef7779f411988811cc31ecc2d3e
Author: Alvaro Ferraz <alvaro.ferraz <at> openbravo.com>
Date: Fri Mar 31 13:14:06 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/4690240411138ef7779f411988811cc31ecc2d3e [^]

Related to issue 34589 & Related to issue 34992: Code review improvements

Use lowercase letter in hql to be more readable.
Use ids in where clauses instead of dal objects.
Change in clause with a join in psdQuery query to improve performance.
Use query.list() directly in for statement.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ProcessInvoice.java
---
(0095782)
hudsonbot   
2017-04-01 12:07   
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/44185ff76d75 [^]
Maturity status: Test