parseBankStatement
Function Declaration |
|
Type |
Interface function |
Description |
Parse a streamed bank statement. This function can stream bank statement file content and obtain default settings for the file. This function adds the parsed transactions and account statements to NetSuite. When NetSuite requests the bank statement content, the plug-in implements this function, which parses and sends the translated transaction data to NetSuite. |
Returns |
void |
Input Parameters |
bankStatementParserContext |
Example
parseBankStatement: function (context) {
var accountStatement = context.output.createNewAccountStatement();
accountStatement.accountMappingKey = defaultAccountMappingKey;
log.debug({
title: 'Adding a new account statement',
details: accountStatement
});
var accountStatementId = context.output.addAccountStatement({"parsedAccountStatement":accountStatement});
log.debug({
title: 'New account statement ID',
details: accountStatementId
});
var statementFile = context.input.file;
var statementLineIterator = statementFile.lines.iterator();
statementLineIterator.next();
statementLineIterator.each(function (line) {
log.debug({
title: 'Read a line from the statement',
details: line.value
});
var partsOfCSVLine = line.value.split(',');
var transaction = context.output.createNewTransaction();
transaction.accountStatementId = accountStatementId;
var rawDate = partsOfCSVLine[0];
transaction.date = rawDate.substring(6, 10) + '-' + rawDate.substring(0, 2) + '-' + rawDate.substring(3, 5);
transaction.amount = partsOfCSVLine[4];
transaction.transactionMappingKey = partsOfCSVLine[3];
transaction.transactionNumber = partsOfCSVLine[2];
transaction.payee = partsOfCSVLine[1];
transaction.currency = "USD";
transaction.memo = partsOfCSVLine[5];
transaction.customerRawId = partsOfCSVLine[6];
transaction.customerName = partsOfCSVLine[7];
transaction.invoices = partsOfCSVLine[8].split(',');
log.debug({
title: 'Adding a new transaction',
details: transaction
});
context.output.addTransaction({"parsedTransaction":transaction});
return true;
});
},