Importing Corporate Card Data

Using custom plug-ins, you can import corporate card data from American Express, Visa, Mastercard, or other providers. You can create a custom SuiteScript code and import corporate card charges to an imported employee expenses record. Use a Financial Institution Parser Plug-in implementation to create and upload your own parsers for different bank and credit card statement formats. Run the parser script on your file, for example xml or csv. The parser calls createNewTransaction that creates imported employee expense record for your data.

Note:

There are required fields based on your preferred form. The object should contain at least all required fields form your IEE record when the parser script calls createNewTransaction.

Then, store them in NetSuite. For more information about mapping custom expense codes from the Financial Institution Parser Plug-in file, see Financial Institution Parser Plug-in.

Note:

The imported employee expense record is fully exposed to SuiteScript.

Step 1 Deploying Plug-in Implementation for Custom Parser

  1. Go to Main Menu > Customization > Plug-ins > Plug-in Implementations > New.

  2. Click the plus sign.

  3. Click Choose file.

  4. Select your script with a custom parser.

  5. Click Save.

  6. Click Create Plug-in Implementation.

  7. Complete the File Name field.

    Tip:

    You can use, for example, Custom FI XML parser.

  8. Click Save.

    This action saves the script record.

The following code contains an example of a parser script:

          /**
 * Copyright © 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * @NScriptType FIParserPlugin
 * @NApiVersion 2.x
 * @NModuleScope TargetAccount
 */
define(['N/xml'], function (nXml) {
    var module = {};
 
    function createTransactionRecord(xmlTrans) {
        // mandatory fields for creating new transaction
        var mandatoryFields = Object.freeze({
            transactionTypeCode: 'CHARGE',
            payee: '',
            sourceId: '',
            transactionStatus: '',
            customerReferenceId: '',
            customerName: '',
            invoiceReferenceIds: [],
        });
        // mapping of XML variables to the plugin ones (XML vars on the left, plugin vars on the right)
        var fieldMap = Object.freeze({
            default: {
                card_holder: 'cardHolder',
                employee_id: 'employeeId',
                date: 'date',
                amount: 'amount',
                foreign_amount: 'localChargeAmount',
                exchange_rate: 'currencyExchangeRate',
                unique_id: 'id',
                currency: 'currency'
            },
            additional: {
                card_currency: 'billedCurrencyISOCode'
            }
        });
        var nodes = xmlTrans.childNodes;
        var record = {
            additionalFields: {}
        };
 
        for (var key in mandatoryFields) {
            record[key] = mandatoryFields[key];
        }
 
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].nodeType === 'ELEMENT_NODE') {
                var elementName = nodes[i].nodeName;
                var elementValue = nodes[i].textContent;
 
                if (fieldMap.default[elementName]) {
                    record[fieldMap.default[elementName]] = elementValue;
                } else {
                    record.additionalFields[fieldMap.additional[elementName] || elementName] = elementValue;
                }
            }
        }
 
        return record;
    }
 
    function getElementValue(transaction, tagName) {
        return transaction.getElementsByTagName({tagName: tagName})[0].textContent;
    }
 
    module.parseData = function (context) {
        var xml = context.inputData.getContents();
        var xmlDoc = nXml.Parser.fromString(xml);
        var xmlTrans = xmlDoc.getElementsByTagName("transaction");
        var record;
        var newAccountData;
        var accountDataMap = {
            getOrCreateAccountData: function (record) {
                var uniqueId = record.employeeId + '' + record.cardHolder;
                if (!this[uniqueId]) {
                    this[uniqueId] = context.createAccountData({
                        employeeId: record.employeeId,
                        cardHolder: record.cardHolder
                    });
                }
                return this[uniqueId];
            }
        };
 
        for (var i = 0; i < xmlTrans.length; i++) {
            record = createTransactionRecord(xmlTrans[i]);
            newAccountData = accountDataMap.getOrCreateAccountData({
                employeeId: getElementValue(xmlTrans[i], 'employee_id'),
                cardHolder: getElementValue(xmlTrans[i], 'card_holder')
            });
            newAccountData.createNewTransaction(record);
        }
    };
 
    return module;
}); 

        

The following code sample contains an example of a parser script that shows the required data format. The createNewTransaction object needs to contain cardCurrency (billedCurrencyISOCode) in the additional fields to run the script correctly:

          /**
 * Copyright © 2020 Oracle and/or its affiliates. All rights reserved.
 *
 * @NScriptType FIParserPlugin
 * @NApiVersion 2.x
 * @NModuleScope TargetAccount
 */
define(['N/xml'], function (nXml) {
    var module = {};

    module.parseData = function (context) {
      var transaction = {
         additionalFields: {}
      };

      transaction['id'] = "471201637";
      transaction['date'] = "2020-05-15";
      transaction['amount'] = "750";
      transaction['billedTaxAmount'] = 0;
      transaction['localChargeAmount'] = "500");
      transaction['localTaxAmount'] = 0;
      transaction['currency'] = 'CAD';
      transaction['currencyExchangeRate'] = "1.5";
      transaction.additionalFields['billedCurrencyISOCode'] = 'USD';
      
        var record = transaction;
        var newAccountData;

      newAccountData = context.createAccountData({
                        employeeId: "17",
                        cardHolder: "Indoors Kibbeh"
                    });
      newAccountData.createNewTransaction(record);

    };

    return module;
}); 

        

The following table contains the fields list:

Field Name (Use in Parser)

Description

Imported Employee Expense Fields

Type

Expected Value

cardHolder

 

cardMemberEmbossedName

string

 

employeeId

 

externalEmployeeId

string

 

CostCenter

 

costCenter

string

 

date

 

chargedate

string

 

id

 

transactionId

string

 

amount

billed amount

amount

number

 

billedTaxAmount

billed tax

taxamount

number

 

billedCurrencyISOCode

billed currency

cardCurrency

string

currency ISO code

currencyExchangeRate

 

fxrate

number

 

localChargeAmount

local amount

fxamount

number

 

localTaxAmount

local tax

fxtaxamount

number

 

currency

local currency

currency

string

currency ISO code

expenseCategoryKey

 

expenseCategory

string

 

memo

 

memo

string

 

Step 2 Creating Financial Institution and Format Profile

  1. Go to Main Menu > Setup > Accounting > Financial Institution > New.

  2. Complete the Financial Institution field.

    Tip:

    You can use, for example, Custom FI.

  3. Click Save.

  4. On your newly created financial institution record, click Add Button on the Format Profile tab.

  5. Complete the following fields:

    1. Profile Name: Custom FP

    2. Profile Type: Corporate Card Expenses

    3. Connectivity method: Manual Import

    4. Transaction parser: Custom FI XML parser

    5. On the Import configuration tab:

      1. Match employee by: Cardholder Name

      2. Expense type: Corporate Card

      3. Employee expense source type: Imported Data

  6. (Optional) In the Expense Code Mapping subtab, map custom expense codes from the parser plug-in file to your own expense categories in NetSuite.

    For more details on mapping custom expense codes from the Financial Institution Parser Plug-in file, see Financial Institution Parser Plug-in and Mapping Custom Expense Codes

  7. (Optional) In the Parser Configuration subtab, configure your transaction parser.

    For more information, see Transaction Parser Configuration.

    Note:

    The Parser Configuration subtab only appears and is populated with configuration fields if your parser plug-in supports parser configuration.

  8. Click Save.

For informatio on creating format profiles for expense reporting, see Creating Format Profiles for Expense Reporting.

Step 3 Importing Transaction data from a file

  1. Go to Main Menu > Transactions > Bank > Banking Import History > Upload File.

  2. Select the input file for parser.

  3. Select Financial Institution: Custom FI.

  4. Select Format Profile: FP.

  5. Click Import.

The following code contains an example of an XML for import:

          <example_card_provider_xml>
      <transaction>
         <card_holder>Indoors Kibbeh</card_holder>
         <employee_id>17</employee_id>
         <date><2020-05-15</date>
         <amount>750</amount>
         <foreign_amount>500</foreign_amount>
         <exchange_rate>1.5</exchange_rate>
         <unique_id>471201637</unique_id>
         <card_currency>USD</card_currency>
         <currency>CAD</currency>
         <custom_value>1776</custom_value>
      </transaction>
</example_card_provider_xml> 

        

Related Topics

General Notices