Version: eXtendSanMar 1.0.8 and above
Audience: Administrator, Developer

Overview

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

Prerequisites

  • A placeholder item created in your account, which will be used for the additional charges coming from the SanMar invoice response.
  • Basic knowledge of SuiteScript.

Configuration

Follow the steps below to implement the configuration. Modifications will be added 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 internal ID of the item with the internal item of the placeholder item 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 Handling Charge from the SanMar invoice on the vendor bill record. Replace the internal ID of the item with the internal item of the placeholder item 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 internal ID of the item with the internal item of the placeholder item 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' });
  }