Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0032713Openbravo ERPZ. Otherspublic2016-04-19 13:312016-06-17 19:37
ngarcia 
markmm82 
immediatemajoralways
closedfixed 
5
 
3.0PR16Q3 
aferraz
Advanced Payables and Receivables Mngmt
No
0032713: Cannot Add Payment with Invoice's Organization if there exists a voided payment with different org associated with the invoice
Cannot Add Payment with Invoice's Organization if there exists a voided payment with different org associated with the invoice. The new payment plan details (FIN_PAYMENT_SCHEDULEDETAIL) are created for the payment's organization which is different from the invoice's organization
As group admin role:
   Create a Payment Method with
      Execution Type: Automatic
      Execution Process: Simple Execution Process
      Deferred: Y
   Add it to the financial account
   Create a Sales Invoice for F&B España Region Norte
   Select the previously created payment method
   Create a Payment In for F&B España S.A.
   Select the previously created payment method
   Add the invoice and process it
   Do not execute it
   Void the Payment
   Go to Sales Invoice window and check you cannot add a payment to it
Change the organization in the processPayment function of FIN_PaymentProcess class:


final FIN_PaymentScheduleDetail mergedScheduleDetail = dao
                        .getNewPaymentScheduleDetail(payment.getOrganization(), outStandingAmt);
No tags attached.
? 32713.sql (697) 2016-05-02 17:20
https://issues.openbravo.com/file_download.php?file_id=9350&type=bug
Issue History
2016-04-19 13:31ngarciaNew Issue
2016-04-19 13:31ngarciaAssigned To => Triage Finance
2016-04-19 13:31ngarciaModules => Core
2016-04-19 13:31ngarciaResolution time => 1463954400
2016-04-19 13:31ngarciaTriggers an Emergency Pack => No
2016-04-19 13:31ngarciaIssue Monitored: networkb
2016-04-19 13:38ngarciaModulesCore => Advanced Payables and Receivables Mngmt
2016-04-21 10:23aferrazAssigned ToTriage Finance => markmm82
2016-04-27 10:15ngarciaPriorityurgent => immediate
2016-04-27 14:40markmm82Statusnew => scheduled
2016-04-29 14:23psanjuanNote Added: 0086084
2016-04-29 14:42psanjuanNote Added: 0086085
2016-04-29 14:48psanjuanNote Edited: 0086085bug_revision_view_page.php?bugnote_id=0086085#r11918
2016-04-29 14:51psanjuanNote Added: 0086086
2016-04-29 14:59psanjuanNote Edited: 0086086bug_revision_view_page.php?bugnote_id=0086086#r11920
2016-04-29 15:09psanjuanNote Deleted: 0086086
2016-04-29 15:10psanjuanNote Edited: 0086085bug_revision_view_page.php?bugnote_id=0086085#r11921
2016-04-30 03:10markmm82Note Added: 0086095
2016-04-30 03:39markmm82Note Added: 0086096
2016-04-30 03:41markmm82Note Edited: 0086095bug_revision_view_page.php?bugnote_id=0086095#r11923
2016-05-02 10:31psanjuanNote Edited: 0086096bug_revision_view_page.php?bugnote_id=0086096#r11931
2016-05-02 11:01psanjuanNote Edited: 0086096bug_revision_view_page.php?bugnote_id=0086096#r11932
2016-05-02 17:18hgbotCheckin
2016-05-02 17:18hgbotNote Added: 0086125
2016-05-02 17:18hgbotStatusscheduled => resolved
2016-05-02 17:18hgbotResolutionopen => fixed
2016-05-02 17:18hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/aaf4e4439bf83ed97bca10c10f85a6ea4f02c789 [^]
2016-05-02 17:19aferrazReview Assigned To => aferraz
2016-05-02 17:19aferrazNote Added: 0086126
2016-05-02 17:19aferrazStatusresolved => closed
2016-05-02 17:19aferrazFixed in Version => 3.0PR16Q3
2016-05-02 17:20aferrazFile Added: 32713.sql
2016-05-02 17:20aferrazNote Added: 0086127
2016-06-17 19:37hudsonbotCheckin
2016-06-17 19:37hudsonbotNote Added: 0087508

Notes
(0086084)
psanjuan   
2016-04-29 14:23   
issue verified.
(0086085)
psanjuan   
2016-04-29 14:42   
(edited on: 2016-04-29 15:10)
Test Plan

Create a Payment Method with below setup:
* Execution Type: Automatic
* Execution Process: Simple Execution Process
* Deferred: Y

Add it to the financial account (Cuenta de Banco).

Create a Sales Invoice for F&B España Region Norte for BP Alimentos y Supermercados. Select the previously created payment method. Complete the invoice.

Create a Payment In for F&B España S.A. Select the previously created payment method. Add the invoice previously created and process it.

Do not execute the payment but void it.

Go to Sales Invoice window and check that you can add a payment to it, that is to pay that invoice by using the same organization (F&B España Region Norte).

Repeat same test as above for purchase invoice, and sales/purchase order.

(0086095)
markmm82   
2016-04-30 03:10   
(edited on: 2016-04-30 03:41)
Test plan to fix the wrong data generated by the issue.
   1-Run the Steps to reproduce steps without apply the patch.
   2-Check you cannot add a payment to the created invoice after reproduce the steps.
   3-Run the following script:
    --Updates all fin_payment_scheduledetail's ad_org_id fields to the invoice's ad_org_id
    --if the fin_payment_scheduledetail is related to an invoice.

    update fin_payment_scheduledetail as psd
    set ad_org_id = (select distinct i.ad_org_id
        from fin_payment_schedule ps
           join c_invoice as i on ps.c_invoice_id = i.c_invoice_id
        where
        psd.fin_payment_schedule_invoice = ps.fin_payment_schedule_id
        and psd.ad_org_id <> i.ad_org_id
        and psd.isactive = 'Y'
        and psd.iscanceled = 'N'
    )
    where exists(select i.ad_org_id
        from fin_payment_schedule ps
           join c_invoice as i on ps.c_invoice_id = i.c_invoice_id
        where ps.fin_payment_schedule_id = psd.fin_payment_schedule_invoice
           and psd.ad_org_id <> i.ad_org_id
           and psd.isactive = 'Y'
           and psd.iscanceled = 'N'
    );

    --Updates all fin_payment_scheduledetail's ad_org_id fields to the order's ad_org_id
    --if the fin_payment_scheduledetail is related to an order.

    update fin_payment_scheduledetail as psd
    set ad_org_id = (select distinct o.ad_org_id
        from fin_payment_schedule ps
           join c_order as o on ps.c_order_id = o.c_order_id
        where
        psd.fin_payment_schedule_order = ps.fin_payment_schedule_id
        and psd.ad_org_id <> o.ad_org_id
        and psd.isactive = 'Y'
        and psd.iscanceled = 'N'
    )
    where exists(select o.ad_org_id
        from fin_payment_schedule ps
           join c_order as o on ps.c_order_id = o.c_order_id
        where
        psd.fin_payment_schedule_order = ps.fin_payment_schedule_id
        and psd.ad_org_id <> o.ad_org_id
        and psd.isactive = 'Y'
        and psd.iscanceled = 'N'
    );
    
    4-Go to Sales Invoice window, select the previously created and check you can add a payment to it.
    
    The above script updates all the fin_payment_scheduledetail ' organizations with the invoice's organizations (if is related to an invoice) or with the order's organizations (if is related to an order).

(0086096)
markmm82   
2016-04-30 03:39   
(edited on: 2016-05-02 11:01)
Test plan 1:

As group admin role:
   Create a Payment Method with
      Execution Type: Automatic
      Execution Process: Simple Execution Process
      Deferred: Y
   Add it to the financial account
   Create a Sales Invoice for F&B España Region Norte
   Select the previously created payment method
   Create a Payment In for F&B España S.A.
   Select the previously created payment method
   Add the invoice and process it
   Do not execute it
   Void the Payment
   Go to Sales Invoice window and check you can add a payment to it.

Repeat same test as above for purchase invoice.

Repeat same test as above by paying the invoice created for F&B España - Region Norte, also from Payment in/out window.

Test plan 2:

As group admin role:
   Create a Payment Method (if not created in Test Plan 1) with
      Execution Type: Automatic
      Execution Process: Simple Execution Process
      Deferred: Y
   Add it to the financial account
   Create a Sales Order for F&B España Region Norte
   Select the previously created payment method
   Create a Payment In for F&B España S.A.
   Select the previously created payment method
   Add the order and process it
   Do not execute it
   Void the Payment
   Go to Sales Order window and check you can add a payment to it.

Repeat same test as above for purchase order.

Repeat same test as above by paying the order created for F&B España - Region Norte, also from Payment in/out window.

(0086125)
hgbot   
2016-05-02 17:18   
Repository: erp/devel/pi
Changeset: aaf4e4439bf83ed97bca10c10f85a6ea4f02c789
Author: Mark <m.molina <at> nectus.com>
Date: Fri Apr 29 12:36:06 2016 -0400
URL: http://code.openbravo.com/erp/devel/pi/rev/aaf4e4439bf83ed97bca10c10f85a6ea4f02c789 [^]

Fixes issue 32713: Allow add payment with invoice org when exist a void payment
The new payment plan details are created for the invoice's organization instead of the payment's organization.
Similar for Payments created from orders: the new payment plan details are created for the order's organization instead of the payment's organization.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
---
(0086126)
aferraz   
2016-05-02 17:19   
Code review + Testing OK
(0086127)
aferraz   
2016-05-02 17:20   
Attached query to fix wrong data.
(0087508)
hudsonbot   
2016-06-17 19:37   
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/0dc7be081b1c [^]
Maturity status: Test