Openbravo Issue Tracking System - Retail Modules
View Issue Details
0045074Retail ModulesLoyalty Programs for Web POSpublic2020-09-16 18:152020-10-09 07:37
aaroncalero 
ranjith_qualiantech_com 
highmajorrandom
closedfixed 
5
 
 
No
0045074: Random JS error after creating a customer
When the Loyalty programs for WebPOS module is installed, sometimes after creating a customer a js error is raised.
Remote mode for customers must be enabled.

The error occurs when the customer is rendered in the ticket. A call is done to the server to refresh the subscription information, but it fails if the customer has not been created yet.
In an environment with Loyalty programs for WebPOS installed.
Log in backend, go to the preference window and make sure that Enable remote for customers is defined with value Y
Log in WebPOS
Click on the Customer button > New Customer
Add the required fields and click on Save.
Finally assign the customer to the ticket.

If the import entry processing is slow, the customer is assigned to the ticket, the refresh code is triggered, but since the customer is not present yet in the database, a null is returned to webpos, and the js error is raised
The code causing the issue is the function OBRLP.Util.refreshCustomer defined in the obrlputils.js file. After doing the remote find:
    OB.Dal.find(OB.Model.BusinessPartner, criteria, function(bps) {
      const bpRefresh = bps.at(0);
      callback(bpRefresh);
    });
It assumes that the bp will exist and calls the callback anyway.

Two possible solutions:
1) Don't execute the callback if there is no customer
2) Check the points in code where OBRLP.Util.refreshCustomer is used (afaik there is just 1 call) and fix that code to prevent the js error if the bp is null.

No tags attached.
Issue History
2020-09-16 18:15aaroncaleroNew Issue
2020-09-16 18:15aaroncaleroAssigned To => Retail
2020-09-16 18:15aaroncaleroResolution time => 1602021600
2020-09-16 18:15aaroncaleroTriggers an Emergency Pack => No
2020-10-05 12:50ranjith_qualiantech_comAssigned ToRetail => ranjith_qualiantech_com
2020-10-05 12:50ranjith_qualiantech_comStatusnew => scheduled
2020-10-06 06:41hgbotNote Added: 0123559
2020-10-09 07:37hgbotNote Added: 0123633
2020-10-09 07:37hgbotResolutionopen => fixed
2020-10-09 07:37hgbotStatusscheduled => closed
2020-10-09 07:37hgbotNote Added: 0123634

Notes
(0123559)
hgbot   
2020-10-06 06:41   
Merge Request created: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.loyalty.programs/-/merge_requests/8 [^]
(0123633)
hgbot   
2020-10-09 07:37   
Merge request merged: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.loyalty.programs/-/merge_requests/8 [^]
(0123634)
hgbot   
2020-10-09 07:37   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.loyalty.programs [^]
Changeset: 175d71d2264256833e2a224ddd5a90caea5c0821
Author: Ranjith S R <ranjith@qualiantech.com>
Date: 2020-10-09T05:37:42+00:00
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.retail.loyalty.programs/-/commit/175d71d2264256833e2a224ddd5a90caea5c0821 [^]

Fixed ISSUE-45074: Added Customer validation when assigned to the receipt
* Added validation in showing loyalty points when customer assigned to the receipt

---
M web/org.openbravo.retail.loyalty.programs/js/utils/obrlputils.js
M web/org.openbravo.retail.loyalty.programs/js/view/businesspartner-selectors.js
---