Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0031193Openbravo ERPZ. Otherspublic2015-10-20 18:452015-11-23 21:17
ngarcia 
AtulOpenbravo 
urgentmajoralways
closedfixed 
5
 
 
vmromanos
Core
No
0031193: Execute Pending Payments background process is taken into account payments that are not Awaiting Execution
Execute Pending Payments background process is taken into account payments that are not Awaiting Execution
As system admin role:
   Install Authorize.net module and apply its dataset, as well as Member Portal dataset, in order to have a payment method configured as:
      Payment In Allowed = 'Y'
      Execution Type = Automatic
      Execution Process = 'a process that will fail'
      Deferred = 'N'
      Automatic Receipt = 'Y'
   Do not configure the authorize.net parameters
   Add that Payment Method to the Financial Account
   1. Create a Sales Invoice with that Payment Method, complete it and execute the payment (an error will be raised)
   Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is present in aprm_pending_paymentinvoice table) but an error is shown. This is correct
   Go to Payment In window, select the payment and Void it
  Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is still present in aprm_pending_paymentinvoice table) but an error is shown. This is incorrect
   2. Create another Sales Invoice with that Payment Method, complete it and execute the payment (an error will be raised)
   Go to Payment In window, reactivate the associated payment, change its payment method and process it
  Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is still present in aprm_pending_paymentinvoice table). This is incorrect too
No tags attached.
Issue History
2015-10-20 18:45ngarciaNew Issue
2015-10-20 18:45ngarciaAssigned To => Triage Finance
2015-10-20 18:45ngarciaModules => Core
2015-10-20 18:45ngarciaResolution time => 1445551200
2015-10-20 18:45ngarciaTriggers an Emergency Pack => No
2015-10-20 18:47ngarciaIssue Monitored: networkb
2015-10-21 10:11AtulOpenbravoAssigned ToTriage Finance => AtulOpenbravo
2015-10-21 10:12AtulOpenbravoStatusnew => scheduled
2015-10-21 15:54AtulOpenbravoNote Added: 0081178
2015-10-22 14:01psanjuanSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9815#r9815
2015-10-22 14:01psanjuanNote Edited: 0081178bug_revision_view_page.php?bugnote_id=0081178#r9817
2015-10-22 14:06psanjuanNote Edited: 0081178bug_revision_view_page.php?bugnote_id=0081178#r9818
2015-10-22 14:08psanjuanNote Edited: 0081178bug_revision_view_page.php?bugnote_id=0081178#r9819
2015-10-22 14:11psanjuanNote Edited: 0081178bug_revision_view_page.php?bugnote_id=0081178#r9822
2015-10-22 14:14psanjuanNote Edited: 0081178bug_revision_view_page.php?bugnote_id=0081178#r9823
2015-10-22 14:15psanjuanSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9824#r9824
2015-10-22 14:16psanjuanSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=9825#r9825
2015-10-22 14:18psanjuanNote Added: 0081210
2015-10-23 14:40psanjuanNote Added: 0081264
2015-10-23 14:42psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9847
2015-10-26 10:22psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9852
2015-10-26 10:24psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9853
2015-10-26 10:29psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9854
2015-10-26 10:31psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9855
2015-10-26 10:49psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9861
2015-10-26 10:56psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9862
2015-10-26 11:02psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9863
2015-10-26 11:17psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9864
2015-10-26 11:21psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9865
2015-10-26 11:22psanjuanNote Added: 0081304
2015-10-26 11:26psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9866
2015-10-26 11:35psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9867
2015-10-26 11:42psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9868
2015-10-27 11:18psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9899
2015-10-27 11:22psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9900
2015-10-27 11:22psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9901
2015-10-27 11:26psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9902
2015-10-27 11:48psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9903
2015-10-27 11:54psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9904
2015-10-27 11:58psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9905
2015-10-27 11:58psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9906
2015-10-27 11:58psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9907
2015-10-27 12:05psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9908
2015-10-29 14:38psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9964
2015-10-29 14:42psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9965
2015-10-29 14:56psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9966
2015-10-29 14:57psanjuanNote Edited: 0081264bug_revision_view_page.php?bugnote_id=0081264#r9967
2015-11-04 18:59vmromanosNote Added: 0081486
2015-11-05 10:59psanjuanNote Added: 0081498
2015-11-05 11:01psanjuanNote Edited: 0081498bug_revision_view_page.php?bugnote_id=0081498#r10075
2015-11-05 11:03psanjuanNote Edited: 0081498bug_revision_view_page.php?bugnote_id=0081498#r10076
2015-11-05 11:04psanjuanNote Edited: 0081498bug_revision_view_page.php?bugnote_id=0081498#r10077
2015-11-05 11:05psanjuanNote Edited: 0081498bug_revision_view_page.php?bugnote_id=0081498#r10078
2015-11-05 11:20hgbotCheckin
2015-11-05 11:20hgbotNote Added: 0081501
2015-11-05 11:20hgbotStatusscheduled => resolved
2015-11-05 11:20hgbotResolutionopen => fixed
2015-11-05 11:20hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/24d5b02440cae22da69aebe6dc9ab50ccac99203 [^]
2015-11-05 11:20hgbotCheckin
2015-11-05 11:20hgbotNote Added: 0081502
2015-11-05 11:20hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/devel/pi/rev/24d5b02440cae22da69aebe6dc9ab50ccac99203 [^] => http://code.openbravo.com/erp/devel/pi/rev/07dbbd5442169fc56bba45679429bf23fa544477 [^]
2015-11-05 11:24vmromanosReview Assigned To => vmromanos
2015-11-05 11:24vmromanosNote Added: 0081503
2015-11-05 11:24vmromanosStatusresolved => closed
2015-11-23 21:17hudsonbotCheckin
2015-11-23 21:17hudsonbotNote Added: 0082176
2015-11-23 21:17hudsonbotCheckin
2015-11-23 21:17hudsonbotNote Added: 0082177

Notes
(0081178)
AtulOpenbravo   
2015-10-21 15:54   
(edited on: 2015-10-22 14:14)
Test Plan
- Login as system admin role:
- Install Authorize.net module and apply its dataset, as well as "Member Portal" dataset, in order to have a payment method configured as:
      Payment In Allowed = 'Y'
      Execution Type = Automatic
      Execution Process = Authorize.net CIM Integration (this one is valid for this scenario, it will also work for any other process that will fail)
      Deferred = 'N'
      Automatic Receipt = 'Y'
- Do not configure the authorize.net parameters in the Client window, "Email Configuration" tab.
- Add that Payment Method to the Financial Account
- Create a Sales Invoice with that Payment Method, complete it and execute the payment (an error will be raised, "NoExecutionProcessFound").
- Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is present in aprm_pending_paymentinvoice table) but an error is shown.
- Go to Payment In window, select the payment and Void it.
- Launch the Execute Pending Payments background process and check it executes successfully. (as the payment is not present in aprm_pending_paymentinvoice table).
- Create another Sales Invoice with that Payment Method, complete it and execute the payment (an error will be raised).
- Go to Payment In window, reactivate the associated payment, change its payment method and process it
- Launch the Execute Pending Payments background process and check that it executes successfully. (as the payment is not present in aprm_pending_paymentinvoice table).

(0081210)
psanjuan   
2015-10-22 14:18   
Issue verified.
(0081264)
psanjuan   
2015-10-23 14:40   
(edited on: 2015-10-29 14:57)
Test Plan below verified.

Prerequisites

Login as system admin role

Install Authorize.net module and apply its dataset, as well as "Member Portal" dataset

Check that two payment methods have been created: "authorize.net Online" and "Authorize.net Subscription". this last one is configured as Automatic by default as described below:
      Payment In Allowed = 'Y'
      Execution Type = Automatic
      Execution Process = Authorize.net CIM Integration
      Deferred = 'N'
      Automatic Receipt = 'Y'
- Do not configure the authorize.net parameters in the Client window, "Email Configuration" tab, therefore this payment method will not work.

Add that Payment Method ( Authorize.net Subscription) to the Financial Account

(1) Scenario 1 - Execute Pending Payments process properly works for a payment method properly configured.

Go to Financial Account "Cuenta de Banco" for F&B España
Go to Payment Method tab. Configure "Cheque" payment method as below:
Payment In allowed
Automatic Receipt = Yes
Execution Type = Automatic
Execution Process = Simple Execution Process
Deferred = No

Go to Sales Invoice and create a new sales invoice for F&B España, Alimentos y Supermercado BP. Select Cheque as payment method. Enter any line.
Complete the invoice and cancel payment execution, therefore a new payment in with "Awaiting Execution" status is created.

Go to Process Request window and run Execute Pending Payments process for F&B España.

Check that the process ends successfully and the payment in has changed its status to Payment Received.

Go back to the sales invoice and verify that it is set as "Payment Complete" = Yes.

Repeat same scenario executing the payment:
- from the invoice
- from the payment in window
to check that execution works ok.


(2) Scenario 2 - Execute Pending Payments process properly works for a payment method do NOT properly configured when it is change to "Void".

Create a Sales Invoice for F&B España, Alimentos y Supermercados BP. Select "Authorize.net Subscription" payment method. Add any line. Complete the invoice. While completing the invoice do cancel the execution of the payment.

Check that a new payment in linked to the invoice has been created with "Awaiting Execution" status.

Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is present in aprm_pending_paymentinvoice table) but an error is shown. "Error during the payment execution. Please read the payment execution message to get more information about the problem" (Where do I can get more information about the problem??)

Repeat same scenario executing the payment:
- from the invoice
- from the payment in window
to check that execution does not successfully ends.

Go to Payment In window, select the payment created and Void it.

Launch the Execute Pending Payments background process once again and check that no error is shown as it executes successfully.

(3) Scenario 3 - Execute Pending Payments process properly works for a payment method do NOT properly configured when the payment in is changed to a "Manual" Payment Method.

Create a Sales Invoice for F&B España, Alimentos y Supermercados BP. Select "Authorize.net Subscription" payment method. Add any line. Complete the invoice. While completing the invoice do cancel the execution of the payment.

Check that a new payment in linked to the invoice has been created with "Awaiting Execution" status.

Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is present in aprm_pending_paymentinvoice table) but an error is shown. "Error during the payment execution. Please read the payment execution message to get more information about the problem" (Where do I can get more information about the problem??)

Go to Payment In window, reactivate the associated payment, change its payment method to "Transferencia" (Manual Execution Type payment method), relate it to the same invoice by using "Add Details" button and process it

Launch the Execute Pending Payments background process once again and check that no error is shown as it executes successfully.

(4) Scenario 4 - Execute Pending Payments process properly works for a payment method do NOT properly configured when the payment in is changed to an "Automatic" Payment Method.

Create a Sales Invoice for F&B España, Alimentos y Supermercados BP. Select "Authorize.net Subscription" payment method. Add any line. Complete the invoice. While completing the invoice do cancel the execution of the payment.

Check that a new payment in linked to the invoice has been created with "Awaiting Execution" status.

Launch the Execute Pending Payments background process and check it tries to execute it (as the payment is present in aprm_pending_paymentinvoice table) but an error is shown. "Error during the payment execution. Please read the payment execution message to get more information about the problem" (Where do I can get more information about the problem??)

Go to Payment In window, reactivate the associated payment, change its payment method to "Cheque" (Automatic Execution Type payment method), relate it to the same invoice by using "Add Details" button and process it

There is no need to do anything else as the payment changes to "Payment Received".

Launch the Execute Pending Payments background process and check it completes successfully.

(5) Scenario 5 - Execute Pending Payments process properly works when a payment in created with a payment method properly configured, is reactivated and changed for another payment method do NOT properly configured.

Go to Sales Invoice and create a new sales invoice for F&B España, Alimentos y Supermercado BP. Select Cheque as payment method. Enter any line.
Complete the invoice and cancel payment execution, therefore a new payment in with "Awaiting Execution" status is created.

Go to Payment in window and check that an Awaiting Execution payment has been created.

Reactivate the payment and change invoice payment method to Authorize.net Subscription payment method. Press Add Details to keep the relation with the invoice. Select "Process Received Payment(s) Action and then press Done.

Press Execute Payment button and then "Execute".
Verify that an error is shown which is OK "Error during the payment execution. Please read the payment execution message to get more information about the problem.

Go now to Process Request window and launch Execute Pending Payments process. Verify it ends with an error

(6) Scenario 6 - Mix of invoices, one set with a payment method properly configured and the other one with a payment method do not properly configured.

Go to sales invoice and create for F&B España, Alimentos y Supermercados BP, set with "Cheque" payment method. Add any line. Complete and do not execute the payment.

Go to sales invoice and create for F&B España, Alimentos y Supermercados BP, set with "Authorized.net Subscription" payment method. Add any line. Complete and do not execute the payment.

Go to payment in window and check that there are two new payments in "Awaiting Execution" status.

Go to Process Request window and launch "Execute Pending Payments" process.
Check that the process ends with an error, which is ok, but the payment in related to the payment method properly configured "Cheque" has changed its status to "Payment Received", while the other keeps in "Awaiting Execution".

Same way the invoice related to "Cheque" payment method is now paid, while the invoice related to "Authorized.net Subscription" payment method is not paid.

(7) Scenario 7 - Payment in properly configured and executed, reactivated and configured with a payment method do not properly configured.

Go to sales invoice and create for F&B España, Alimentos y Supermercados BP, set with "Cheque" payment method. Add any line. Complete and do not execute the payment.

Go to payment in window and verify that a new payment in awaiting execution status have been created. Execute the payment. After that Reactivate it and change the payment method to "Authorized.net Subscription". Select same invoice by using "Add Details" button.

Try to execute the payment now from the payment in window, "Execute Payment" button. An error is shown, which is correct.

Go to Process Request window and launch "Execute Pending Payments" process.
Check that the process shows as well an error, which is correct.

(8) Scenario 8 - A payment in, including two invoices, related to a payment method properly configured is reactivated and changed by a payment method do not properly configured.

Go to sales invoice window and create two invoices for F&B España, Alimentos y Supermercados BP, Transferencia payment method.
Complete the invoices.

Go to payment in window and create a new payment for Alimentos y Supermercados, Payment method = Cheque. Select the two invoices created.
Press Done and check that payment status changes to "Payment Received".

Reactivate the payment and change the payment method to "Authorized. net Subscription". Press Add Details. Remove the filter and select once again these two invoices. Complete the payment.

Check that payment in status is Awaiting Execution. Try to execute the payment from payment in window. Check that fails, which is correct.

Try to execute the payment from Process Request window by launching "Execute Pending Payment". Check that it also fails, which is correct.

Go back to Payment in and reactivate it, change the payment to Cheque and select once more the two invoices. Check that this time payment status changes to "Payment Made" and the two invoices are paid.

(0081304)
psanjuan   
2015-10-26 11:22   
Test Plan above verified.
(0081486)
vmromanos   
2015-11-04 18:59   
After talking to EAR the solution has changed a little bit:

1. When a payment in awaiting execution is reactivated or voided, we immediately delete the associated APRMPendingPaymentFromInvoice record. This is a way to ensure the same behavior as when creating the payment manually, where no APRMPendingPaymentFromInvoice record is created and the user must process manually the payment.

2. In case the payment is in awaiting execution, and there is any update, we update the APRMPendingPaymentFromInvoice record to point to the current Payment Process. This is a way to ensure the payment originally created by the system can be processed by the background process with the right payment process.

3. In case the payment is in awaiting execution, and the payment method is updated to any other without a payment process, then the APRMPendingPaymentFromInvoice record is deleted. This is done to ensure the payment is not processed by the background process with the Payment Process associated before.
(0081498)
psanjuan   
2015-11-05 10:59   
(edited on: 2015-11-05 11:05)
After change in the solution of the issue, see note above.

Test plan above has been verified.

New test added:

(9) Scenario 9 - Payment method changed to another "Automatic" payment method, without reactivating an Awaiting execution payment in.

Go to Sales invoice window and create a new one for F&B España, Alimentos y Supermercados, Payment Method = Authorized.net Subcription.
Complete the invoice and do not execute the payment.

Go to payment in window and check that a new awaiting execution payment in has been created.

Run Execute Pending Payments and check that an error is shown, which is correct.

Go to payment in window and change the payment method to Cheque.

Run Execute Pending Payments and check it ends successfully and no error is shown.

Payment is now set as Payment Received and the sales invoice is paid.

(10) Scenario 10 Payment method changed to a "Manual" payment method, without reactivating an Awaiting execution payment in.

Go to Sales invoice window and create a new one for F&B España, Alimentos y Supermercados, Payment Method = Authorized.net Subcription.
Complete the invoice and do not execute the payment.

Go to payment in window and check that a new awaiting execution payment in has been created.

Run Execute Pending Payments and check that an error is shown, which is correct.

Go to payment in window and change the payment method to Transferencia.

Run Execute Pending Payments and check it ends successfully and no error is shown.

(0081501)
hgbot   
2015-11-05 11:20   
Repository: erp/devel/pi
Changeset: 24d5b02440cae22da69aebe6dc9ab50ccac99203
Author: Atul Gaware <atul.gaware <at> openbravo.com>
Date: Thu Oct 29 14:26:35 2015 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/24d5b02440cae22da69aebe6dc9ab50ccac99203 [^]

Fixes Issue 0031193:Execute Pending Payments background process is taken into
 account payments that are not Awaiting Execution

- Remove lines from APRMPendingPaymentFromInvoice when payment does not have
status as Awaiting Execution
- While processing payment check whether records exists in
APRMPendingPaymentsFromInvoice if no create them, if yes check whether they
have proper execution process, if not set it.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/event/FIN_PaymentEventListener.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/ExecutePendingPayments.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
---
(0081502)
hgbot   
2015-11-05 11:20   
Repository: erp/devel/pi
Changeset: 07dbbd5442169fc56bba45679429bf23fa544477
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Wed Nov 04 18:55:33 2015 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/07dbbd5442169fc56bba45679429bf23fa544477 [^]

Fixed bug 31193: code review improvements

Changes in the solution:
1. When a payment in awaiting execution is reactivated or voided, we immediately delete the associated APRMPendingPaymentFromInvoice record. This is a way to ensure the same behavior as when creating the payment manually, where no APRMPendingPaymentFromInvoice record is created and the user must process manually the payment.
2. In case the payment is in awaiting execution, and there is any update, we update the APRMPendingPaymentFromInvoice record to point to the current Payment Process. This is a way to ensure the payment originally created by the system can be processed by the background process with the right payment process.
3. In case the payment is in awaiting execution, and the payment method is updated to any other without a payment process, then the APRMPendingPaymentFromInvoice record is deleted. This is done to ensure the payment is not processed by the background process with the Payment Process associated before.
4. The changes in the FIN_PaymentProcess have been reverted, because there is no need to create always a APRMPendingPaymentFromInvoice record before processing the payment
5. The ExecutePendingPayments class, which is the background process that processes the payments in the APRMPendingPaymentFromInvoice entity, will remove any APRMPendingPaymentFromInvoice record linked to a payment in Voided status, and it will execute only the payments in Awaiting Execution.
6. The code in the ExecutePendingPayments will probably require a deeper review to properly write it.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/event/FIN_PaymentEventListener.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/ExecutePendingPayments.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentProcess.java
---
(0081503)
vmromanos   
2015-11-05 11:24   
Code review + testing OK
(0082176)
hudsonbot   
2015-11-23 21:17   
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/7b56bebaaa88 [^]
Maturity status: Test
(0082177)
hudsonbot   
2015-11-23 21:17   
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/7b56bebaaa88 [^]
Maturity status: Test