Version: eXtendSanMar 1.0.8 and above
Audience: Administrator, Developer

Overview

This article explains how to configure your NetSuite account to display additional charges from SanMar's invoice response—such as shipping, handling, and tax—on the vendor bill record.

Prerequisites

  • Item(s) created in your NetSuite account to handle recording the additional charges (shipping, handling, and tax) from SanMar invoice responses.
  • Basic knowledge of SuiteScript.

Configuration

To implement this configuration, configure the SuiteScript functions below. You will need to make modifications to the suite_sanmar_transformers.js file in your NetSuite account.

setSalesTax

This function sets the Sales Tax from the SanMar invoice on the vendor bill record. Replace the sample internal ID in the code below with the internal ID of the item you want to use in your account.
/**
 * @param    {Object} args
 * @property {Object} args.vendorBillRecord - This is vendor bill record object
 * @property {Object} args.sourceRecord - This is incoming sanmar invoice object
 * @property {String} args.recordType - This is transformed from record type(basically it is purchaseorder)
 * @property {String} args.recordId - This is transformed from record id(basically it is purchaseorder id)
 */
function setSalesTax(args) {
  var vendorBillRecord = args.vendorBillRecord;
  var sourceRecord = args.sourceRecord;

  log.debug({ title: 'setSalesTax initiated'});
  log.debug({ title: 'setSalesTax sourceRecord', details: sourceRecord });

  var salesTax = sourceRecord.Invoice__Header__SalesTax || '';
  if (!salesTax) {
    return;
  }

  if (typeof salesTax === 'string') {
    salesTax = parseFloat(salesTax);
  }

  log.debug({ title: 'setShippingHandlingCharges salesTax', details: salesTax });

  if (!salesTax) {
    return;
  }

  // vendorBillRecord.selectNewLine({ sublistId: 'item' });
  // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: '48186' });
  // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: '1' });
  // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'rate', value: salesTax });
  // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'amount', value: salesTax });
  // vendorBillRecord.commitLine({ sublistId: 'item' });
}

setShippingHandlingCharges

This function sets the Shipping and Handling from the SanMar invoice on the vendor bill record. Replace the sample internal ID in the code below with the internal ID of the item you want to use in your account.
/**
 * @param    {Object} args
 * @property {Object} args.vendorBillRecord - This is vendor bill record object
 * @property {Object} args.sourceRecord - This is incoming sanmar invoice object
 * @property {String} args.recordType - This is transformed from record type(basically it is purchaseorder)
 * @property {String} args.recordId - This is transformed from record id(basically it is purchaseorder id)
 */
function setShippingHandlingCharges(args) {
    var vendorBillRecord = args.vendorBillRecord;
    var sourceRecord = args.sourceRecord;
  
    log.debug({ title: 'setShippingHandlingCharges initiated'});
    log.debug({ title: 'setShippingHandlingCharges sourceRecord', details: sourceRecord });
  
    var shippingHandlingCharges = sourceRecord.Invoice__Header__ShippingHandlingCharges || '';
    if (!shippingHandlingCharges) {
      return;
    }
  
    if (typeof shippingHandlingCharges === 'string') {
      shippingHandlingCharges = parseFloat(shippingHandlingCharges);
    }
  
    log.debug({ title: 'setShippingHandlingCharges shippingHandlingCharges', details: shippingHandlingCharges });
  
    if (!shippingHandlingCharges) {
      return;
    }
  
    // vendorBillRecord.selectNewLine({ sublistId: 'item' });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: '48186' });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: '1' });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'rate', value: salesTax });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'amount', value: salesTax });
    // vendorBillRecord.commitLine({ sublistId: 'item' });
  }

setMiscellaneousFreightSavings

This function sets the Miscellaneous Freight Savings from the SanMar invoice on the vendor bill record. Replace the sample internal ID in the code below with the internal ID of the item you want to use in your account..
/**
 * @param    {Object} args
 * @property {Object} args.vendorBillRecord - This is vendor bill record object
 * @property {Object} args.sourceRecord - This is incoming sanmar invoice object
 * @property {String} args.recordType - This is transformed from record type(basically it is purchaseorder)
 * @property {String} args.recordId - This is transformed from record id(basically it is purchaseorder id)
 */
function setMiscellaneousFreightSavings(args) {
    var vendorBillRecord = args.vendorBillRecord;
    var sourceRecord = args.sourceRecord;
  
    log.debug({ title: 'setMiscellaneousFreightSavings initiated'});
    log.debug({ title: 'setMiscellaneousFreightSavings sourceRecord', details: sourceRecord });
  
    var miscellaneousFreightSavings = sourceRecord.Invoice__Header__Miscellaneous__FreightSavings || '';
    if (!miscellaneousFreightSavings) {
      return;
    }
  
    if (typeof miscellaneousFreightSavings === 'string') {
      miscellaneousFreightSavings = parseFloat(miscellaneousFreightSavings);
    }
  
    log.debug({ title: 'setMiscellaneousFreightSavings miscellaneousFreightSavings', details: miscellaneousFreightSavings });
  
    if (!miscellaneousFreightSavings) {
      return;
    }
  
    // vendorBillRecord.selectNewLine({ sublistId: 'item' });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'item', value: '48186' });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'quantity', value: '1' });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'rate', value: salesTax });
    // vendorBillRecord.setCurrentSublistValue({ sublistId: 'item', fieldId: 'amount', value: salesTax });
    // vendorBillRecord.commitLine({ sublistId: 'item' });
  }