Invoices Page Displays Incorrect Date Sort (pre-Denali)

This topic applies to

Applies to

SuiteCommerce Advanced | pre-Denali

 

In Reference My Account v1.05, when shoppers sort invoices By Due Date or By Invoice Date on the Invoices page of the web store, the invoices display out of order. To correct the sort order, customize the list() method in the Models.js file as described in this section.

To customize the Models.js file:

  1. If you have not done so already, copy the Models.js file from the reference folder to your custom folder in the NetSuite File Cabinet.

    Models.js is located in the File Cabinet at My Account 1.05 > Reference My Account > ssp_libraries.

  2. Update the list() method in the Models.js file from your custom folder to use the nlapiStringToDate() method.

    Find the following code:

    return _.map(results || [], function (record) { var due_date = record.getValue('duedate') , close_date = record.getValue('closedate') , tran_date = record.getValue('trandate') , due_in_milliseconds = new Date(due_date).getTime() - now , total = toCurrency(record.getValue(amount_field)) , total_formatted = formatCurrency(record.getValue(amount_field)); return { internalid: record.getId() , tranid: record.getValue('tranid') , order_number: record.getValue('tranid') // Legacy attribute , date: tran_date // Legacy attribute , summary: { // Legacy attribute total: total , total_formatted: total_formatted } , total: total , total_formatted: total_formatted , recordtype: record.getValue('type') , mainline: record.getValue('mainline') , amountremaining: toCurrency(record.getValue(amount_remaining)) , amountremaining_formatted: formatCurrency(record.getValue(amount_remaining)) , closedate: close_date , closedateInMilliseconds: new Date(close_date).getTime() , trandate: tran_date , tranDateInMilliseconds: new Date(tran_date).getTime() , duedate: due_date , dueinmilliseconds: due_in_milliseconds , isOverdue: due_in_milliseconds <= 0 && ((-1 * due_in_milliseconds) / 1000 / 60 / 60 / 24) >= 1 , status: { internalid: record.getValue('status') , name: record.getText('status') } , currency: { internalid: record.getValue('currency') , name: record.getText('currency') } }; });

    Replace these lines with the following code:

    return _.map(results || [], function (record) { var due_date = record.getValue('duedate') , close_date = record.getValue('closedate') , tran_date = record.getValue('trandate') , due_in_milliseconds = (!!due_date ? nlapiStringToDate(due_date).getTime() : (new Date()).getTime()) - now , total = toCurrency(record.getValue(amount_field)) , total_formatted = formatCurrency(record.getValue(amount_field)); return { internalid: record.getId() , tranid: record.getValue('tranid') , order_number: record.getValue('tranid') // Legacy attribute , date: tran_date // Legacy attribute , summary: { // Legacy attribute total: total , total_formatted: total_formatted } , total: total , total_formatted: total_formatted , recordtype: record.getValue('type') , mainline: record.getValue('mainline') , amountremaining: toCurrency(record.getValue(amount_remaining)) , amountremaining_formatted: formatCurrency(record.getValue(amount_remaining)) , closedate: close_date , closedateInMilliseconds: close_date ? nlapiStringToDate(close_date).getTime() : 0 , trandate: tran_date , tranDateInMilliseconds: tran_date ? nlapiStringToDate(tran_date).getTime() : 0 , duedate: due_date , dueinmilliseconds: due_in_milliseconds , isOverdue: due_in_milliseconds <= 0 && ((-1 * due_in_milliseconds) / 1000 / 60 / 60 / 24) >= 1 , status: { internalid: record.getValue('status') , name: record.getText('status') } , currency: { internalid: record.getValue('currency') , name: record.getText('currency') } }; });
  3. Configure your SSP Application to use the custom Models.js file.

    1. Open the My Account SSP application record at Setup > SuiteCommerce Advanced > SSP Applications.

    2. On the Scripts subtab, update the Libraries list to include the Models.js file from your custom folder.

      This file must maintain the correct position at the bottom of the list of library files.

    3. Click Save.

  4. Verify that the customization was successful.

    The By Due Date and By Invoice Date sort order should be correct on the Invoices page in your web store. The invoices appear in ascending or descending order based on what the customer selects on the Invoice page in the web store.

Related Topics