Missing Promo Code on Return Request

In Mont Blanc releases of SuiteCommerce Advanced, promo codes applied to the original sales order are not included in the calculations for a return request. To correct this error, apply the patch described here to extend the setLines() method in the ReturnAuthorization.Model.js file.

Note:

Before proceeding, familiarize yourself with the Best Practices for Customizing SCA.

You can download the code samples described in this procedure here: Return.Authorization.Extension@1.0.0.zip

Step 1: Extend the ReturnAuthorization.Model.js File

  1. To extend the ReturnAuthorization.Model.js file, which is located in the ReturnAuthorization module, create a directory to store your custom module.

  2. Open this directory and create a subdirectory to maintain your customizations.

    Give this directory a name similar to the module being customized. For example:

    Modules/extensions/Return.Authorization.Extension@1.0.0

  3. In your new Return.Authorization.Extension@1.0.0 module, create a subdirectory called SuiteScript.

    Modules/extensions/Return.Authorization.Extension@1.0.0/SuiteScript

  4. In your new SuiteScript subdirectory, create a JavaScript file to extend ReturnAuthorization.Model.js .

    Name this file according to best practices. For example:

    ReturnAuthorization.Model.Extension.js

  5. Open this file and extend the setLines() method as shown in the following code snippet.

                     define('ReturnAuthorization.Model.Extension'
    , [
     'ReturnAuthorization.Model'
     , 'underscore'
    ]
    , function (
      ReturnAuthorizationModel
    ,  _
    )
    {
    'use strict';
     _.extend(ReturnAuthorizationModel.prototype,
      { 
    
        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);
         }
         else
         {
          return_authorization.setLineItemValue('item', 'quantity', i, 0);
         }
    
         i++;
        }
             }
    
      });
    }
    ); 
    
                  
  6. Save the file.

Step 2: Prepare the Developer Tools for Your Extension

  1. Open the Return.Authorization.Extension@1.0.0 module.

  2. Create a file in this module and name it ns.package.json.

    Modules/extensions/Return.Authorization.Extension@1.0.0/ns.package.json

  3. Build the ns.package.json file using the following code

                    {
        "gulp": {
            "ssp-libraries": [
                "SuiteScript/*.js"
            ]
        }
    } 
    
                  
  4. Save the ns.package.json file.

  5. Open the distro.json file.

    This file is located in the top-level directory of your SuiteCommerce Advanced source code.

  6. Add your custom module to the modules object.

    This ensures that the Gulp tasks include your extension when you deploy. In this example, the extensions/Return.Authorization.Extension module is added at the beginning of the list of modules. However, you can add the module anywhere in the modules object. The order of precedence in this list does not matter.

                    {
        "name": "SuiteCommerce Advanced Elbrus",
        "version": "2.0",
        "buildToolsVersion": "1.3.0",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
             "modules": {
                   "extensions/Return.Authorization.Extension": "1.0.0",
                   "suitecommerce/Account": "2.3.0",
                   "suitecommerce/Address": "2.4.0",
                   ... 
    
                  
  7. Include the module definition (“ReturnAuthorization.Model.Extension”) in the dependencies array of the SCA application of the ssp-libraries object.

    Your distro.json file should look similar to the following:

                    "tasksConfig": {
    //...
            "ssp-libraries": {
                "entryPoint": "SCA",
                "dependencies": [
                    "Application",
                    "Account.Model",
                    "Address.Model",
                         //..
                         "ReturnAuthorization.Model.Extension"
                   ], 
    
                  
    Note:

    Best practice is to place any new modules at the bottom of the list in the dependencies array.

  8. Save the distro.json file.

Step 3: Test and Deploy Your Extension

  1. Deploy your customizations to your NetSuite account and test. See Deploy SCA Customizations to NetSuite.

    Note:

    Since this patch modifies an SSP library file, changes are not visible in your local environment until you first deploy the customizations to NetSuite.

  2. Verify your changes.

    A returned order should include the original promo code that was used when the customer placed the order. The value on the sales order should match the value on the Return Authorization.

Related Topics

SCA Patches

General Notices