Openbravo Issue Tracking System - Retail Modules
View Issue Details
0047854Retail ModulesGift cards and gift voucherspublic2021-10-14 18:292021-10-29 07:40
aaroncalero 
justin_patterson 
urgentmajoralways
closedfixed 
5
 
RR22Q1 
marvintm
No
0047854: Error trying to pay a ticket with Credit Notes after multiple Cancel and Replace executions
When a ticket had originally some payments and the Cancel and Replace process is executed, the new ticket contains a 'Cancelled' payment with the amount paid originally. The payment method of this cancelled payment matches the original payment method, although no other details (paymentData or other extra fields) are transferred to the cancelled payment.

When this cancelled payment's payment method is Credit Note, and a new Credit Note payment is added to the receipt, a javascript error appears in WebPOS
In an environment with the Giftcards module installed and Credit Notes configured (e.g. livebuilds modules instance, YS-11 terminal):

1) Create a new ticket and add a product.
Click on the product line, and then on the EDIT tab, click on Return Line
Go to the payments tab, select Credit Notes, and finish the ticket. This will create a new Credit Note in the system.

2) Create another ticket and add a product
Click on the total amount button, select Credit Notes as payment method, and pay with the CN created in step 1. Finish the ticket

3) Load the ticket created in 2, go to the Menu > Cancel and Replace, click on the total amount button and click on Done without any other change.

4) Load the ticket created in step 3 (the ticket will have the same docNo as the one created in (2), with a "-1" at the end.
Verify that the ticket contains a payment, labelled as cancelled.
Click again on Menu > Cancel and replace.
Add a second unit of the same product
Click on the total amount button, and try to pay the remaining amount again with Credit Notes. The following error will appear in the console and the upper right corner:
OBDAL error: TypeError: Cannot read properties of undefined (reading 'groupingCriteria');


* Steps 3 and 4 can be simplified if Prepayments and/or Delivery modes are configured on the terminal: instead of executing a second cancel and replace, add the extra unit during the first CR, and leave the amount unpaid. Then load the "-1" and complete the payment.
The postAddPayment hook defined on the Giftcards module[1] assume that all Credit notes payments contain a paymentData object, which is not true.
Simply add the "... && payment.get('paymentData') && ..." condition to skip not valid payments.



[1] https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.giftcards/-/blob/master/web/org.openbravo.retail.giftcards/js/hooks/postaddpaymenthook.js [^]
No tags attached.
Issue History
2021-10-14 18:29aaroncaleroNew Issue
2021-10-14 18:29aaroncaleroAssigned To => Retail
2021-10-14 18:29aaroncaleroTriggers an Emergency Pack => No
2021-10-25 08:26marvintmStatusnew => scheduled
2021-10-25 08:26marvintmAssigned ToRetail => justin_patterson
2021-10-25 18:06hgbotNote Added: 0132621
2021-10-25 18:24hgbotNote Added: 0132623
2021-10-26 11:40hgbotNote Added: 0132637
2021-10-29 07:38hgbotNote Added: 0132724
2021-10-29 07:40marvintmNote Added: 0132725
2021-10-29 07:40marvintmStatusscheduled => resolved
2021-10-29 07:40marvintmFixed in Version => RR22Q1
2021-10-29 07:40marvintmResolutionopen => fixed
2021-10-29 07:40marvintmReview Assigned To => marvintm
2021-10-29 07:40marvintmStatusresolved => closed

Notes
(0132621)
hgbot   
2021-10-25 18:06   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.giftcards/-/merge_requests/100 [^]
(0132623)
hgbot   
2021-10-25 18:24   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/446 [^]
(0132637)
hgbot   
2021-10-26 11:40   
Merge request closed: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/446 [^]
(0132724)
hgbot   
2021-10-29 07:38   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.giftcards/-/merge_requests/100 [^]
(0132725)
marvintm   
2021-10-29 07:40   
Fixed by the following commit:

https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.giftcards/-/commit/ffe9e571c6c7ff007bb18784d680df5173472966 [^]