Gift Certificate Error After Return Request Submitted

In some implementations of the Elbrus release of SuiteCommerce Advanced (SCA), a return authorization request is not submitted if the invoice status is set to Approved and there is a gift certificate included in the order. This error message appears on Commerce websites affected by this problem: "Gift Certificate From, Recipient Name, and Recipient Email are required."

These patch instructions describe how to correct this problem.

To implement this patch, create a custom module to override the ReturnAuthorization.Model.js JavaScript file, which is part of the ReturnAuthorization module.

If you are unfamiliar with implementing patches for SCA, refer to the following:

Step 1: Create the Override File

Following the instructions and recommendations in the Patch Using Override Mode procedure, create a new directory and file: /Modules/extensions/ReturnAuthorization@1.0.0/JavaScript/ReturnAuthorization.Model.js. In the new ReturnAuthorization.Model.js file, find and replace the following line of code with the provided code sample.

Find the following code:

            setLines: function (return_authorization, lines, transaction_lines) 

          

And replace it with the following code:

            setLines: function (return_authorization, lines, transaction_lines)
{
var line_count = return_authorization.getLineItemCount('item')
, add_line = true
, i = 1;
while (i <= line_count)
{
var line_item_value =
return_authorization.getLineItemValue('item', 'id', i);
add_line = this.findLine(line_item_value, lines);
if (add_line)
{
var transaction_line = _.findWhere(transaction_lines,
{ line: line_item_value });
if (transaction_line)
{
return_authorization.setLineItemValue('item',
'rate', i, transaction_line.rate);
}
return_authorization.setLineItemValue('item',
'quantity', i, add_line.quantity);
return_authorization.setLineItemValue('item',
'description', i, add_line.reason);
i++;
}
else
{
var item_type =
return_authorization.getLineItemValue('item', 'itemtype', i);
if (item_type == 'GiftCert') {
return_authorization.removeLineItem('item', i);
line_count--;
} else {
return_authorization.setLineItemValue('item',
'quantity', i, 0);
i++;
}
}
}
} 

          

Step 2: Prepare the Developer Tools For Your Patch

When preparing the Developer Tools for your patch as described in the Patch Using Override Mode procedure, perform the following actions:

  1. Paste the following sample code into the new ns.package.json file that you create in the Modules directory: /Modules/extensions/ReturnAuthorizationExtension@1.0.0/ns.package.json

                    {
        "gulp": {
            "javascript": [
                "JavaScript/*.js"
            ]
     },
       "overrides": {
          "suitecommerce/ReturnAuthorization@X.Y.Z/JavaScript/ReturnAuthorization.Model.js" : "JavaScript/ReturnAuthorization.Model.js"
       }
    } 
    
                  
    Important:

    You must replace the string, X.Y.Z, with the version of the module in your implementation of SCA.

  2. Open the distro.json file in the root SCA development directory and then add your custom module to the modules object as described in the Patch Using Override Mode procedure. The following sample shows the value to add to the list of existing values that follow the “modules” key.

                    "modules": {
        "extensions/ReturnAuthorizationExtension": "1.0.0",
        . . . 
    
                  

Step 3: Test and Deploy Your Patch

Follow the instructions provided in the Patch Using Override Mode procedure to test and deploy your patch.

Related Topics

SCA Patches

General Notices