Sample financial Institution Plugin

/**

 * @NApiVersion 2.x

 * @NScriptType fiParserPlugin

 */

define([‘N/query’, ‘N/url’],

    function (query, url) {

       

        function parseData(context) {

            log.debug(“data parser”);

            var configuration = context.pluginConfiguration.getConfigurationFieldValue({ fieldName: “configuration_id” });

            var data = JSON.parse(context.inputData.getContents());

         for (var accountIndex = 0; accountIndex < data.accounts.length; accountIndex++) {

                var account = data.accounts[accountIndex];

                var accountData = context.createAccountData({

                    accountId: account.accountId,

                    dataAsOfDate: account.dataAsOfDate,

                    closingBalance: account.closingBalance

                });

                for (var transactionIndex = 0; transactionIndex < account.transactions.length; transactionIndex++) {

                    var transaction = account.transactions[transactionIndex];

                    accountData.createNewTransaction({

                        date: transaction.date,

                        amount: transaction.amount,

                        transactionTypeCode: transaction.transactionTypeCode,

                        uniqueId: transaction.uniqueId,

                        id: transaction.id,

                        payee: transaction.payee,

                        currency: transaction.currency,

                        memo: transaction.memo,

                        transactionStatus: transaction.transactionStatus,

                        customerReferenceId: transaction.customerReferenceId,

                        invoiceReferenceIds: transaction.invoiceReferenceIds,

                        billedTaxAmount: transaction.billedTaxAmount,

                        localChargeAmount: transaction.localChargeAmount,

                        currencyExchangeRate: transaction.currencyExchangeRate,

                        expenseCode: transaction.expenseCode

                    });

                }

            }

        }

        return {

            parseData: parseData

        };

    });

Leave a comment

Your email address will not be published. Required fields are marked *