Needle-Pinpointing Machine

    node-mt940

    0.1.3 • Public • Published

    MT940

    This module parses files with bank account statements in MT940 format.

    Documentation

    Installation

      npm install --save node-mt940
    

    Quick start

    How to use

    The module contains a default parser and writer. Another parser/writer for the bank Sparkasse also exists.

    MT940

    constructor

    singleton - Get single MT940 object

    setConfiguration - Set the mt940 configuration

    setParser - Set the parser

    setWriter - Set the writer

    setWriteAs - Set the format to write transactions.

    parse - Parse transactions in MT940 format

    write - Write transaction in configured format

    getWriteStatus - Get the current status of writing

    Parser

    instance - Get a new parser instance

    setContent - Set the content to parse

    hasContent - Check if parser has content to parse

    setFilePath - Set the path to the file with content to parse

    loadContent - Load the content of configured file path

    execute - Execute parsing file or set content

    Writer

    instance - Get a new writer instance

    setFilePath - Set path write transaction to file

    writePlainText - Write transactions in MT940 plain text format

    writeXML - Write transactions in XML format

    writeCSV - Write transactions in CSV format

    Revenue

    instance - Get a new revenue object

    setReferenceNumber - Set the reference number

    getReferenceNumber - Get the reference number

    setBankCode - Set bank code of account

    getBankCode - Get bank code of account

    setAccountNumber - Set the bank account number

    getAccountNumber - Get the bank account number

    setExtracts - Set collection of extracts (single statement block)

    addExtract - Add single extract to extract collection

    getExtracts - Get collection of extracts

    Extract

    instance - Get a new extract object

    setBankCode - Set bank code of account

    getBankCode - Get bank code of account

    setAccountNumber - Set bank account number

    getAccountNumber - Get bank account number

    setNumber - Set extract number

    getNumber - Get extract number

    setSheetNumber - Set sheet number

    getSheetNumber - Get sheet number

    addTransaction - Add a transaction to the extract

    getTransactionById - Get a specific transaction by its id

    getTransactions - Get collection of added transactions

    setStartSaldo - Set the start saldo

    getStartSaldo - Get the start saldo

    setEndSaldo - Set extract end saldo

    getEndSaldo - Get extract end saldo

    parseLine - Parse a given line of MT940 content

    toCSVString - Get extract information in CSV format

    setPrevious - Set the previous extract object

    previous - Get the previous extract object

    setNext - Set the next extract object

    next - Get the next extract object

    hasPrevious - Check if the current extract object has a previous one.

    hasNext - Check if the current extract object has a next one.

    Transaction

    instance - Get a new transaction object

    setId - Set transaction id

    getId - Get transaction id

    setValuta - Set the transaction valuta

    getValuta - Get the transaction valuta

    getValutaAsTimestamp - Get transaction valuta as timestamp

    getFormattedValuta - Get formatted transaction valuta

    setBookingDate - Set transaction booking date

    getBookingDate - Get transaction booking date

    getFormattedBookingDate - Get the formatted booking date

    setType - Set the transaction type

    getType - Get the transaction type

    getTypeString - Get the transaction type as string

    setLastCharIsoCode - Set the char iso code

    getLastCharIsoCode - Get the char iso code

    setAmount - Set the transaction amount

    getAmount - Get the transaction amount

    setBookingKey - Set the transaction booking key

    getBookingKey - Get the transaction booking key

    setReference - Set transaction reference

    getReference - Get transaction reference

    setPaymentReference - Set the transaction payment reference

    getPaymentReference - Get the transaction payment reference

    parseLine - Parse a given line of MT940 content

    reset - Reset transaction data of the object

    setPrevious - Set the previous extract object

    previous - Get the previous extract object

    setNext - Set the next extract object

    next - Get the next extract object

    hasPrevious - Check if the current extract object has a previous one.

    hasNext - Check if the current extract object has a next one.

    Payment reference

    instance - Get a new payment reference object

    setGVC - Set the GV code

    getGVC - Get the GV code

    setBookingText - Set the booking text

    getBookingText - Get the booking text

    setPrimanotaNumber - Set the primanota number

    getPrimanotaNumber - Get the primanota number

    setText - Set text

    addText - Add text

    getText - Get the whole text

    setPurchaserBIC - Set the BIC

    getPurchaserBIC - Get the BIC

    setPurchaserAccountNumber - Set the bank account number

    getPurchaserAccountNumber - Get the bank account number

    setAccountOwnerName - Set the name of the bank account owner

    getAccountOwnerName - Get the name of the bank account owner

    setTextKeyAddition - Set the text key addition

    getTextKeyAddition - Get the text key addition

    parseLine - Parse a given line of MT940 content

    pad - Pads a string with "0" to given size

    GVCList

    singleton - Get an object of the GV code list

    createCode - Create a new GV code object

    setCodes - Set a collection of GV codes

    addCode - Add a GV code to the collection

    getByCodeNumber - Get a specific GV code by its code number

    GVCode

    instance - Get a new GV code object

    setCode - Set the code

    getCode - Get the code

    setText - Set GV code text

    getText - Get the GV code text

    toJSON - Get GV code information in JSON format

    setPrevious - Set the previous GV code object

    previous - Get the previous GV code object

    setNext - Set the next GV code object

    next - Get the next GV code object

    hasPrevious - Check if the current GV code object has a previous one.

    hasNext - Check if the current GV code object has a next one.

    Saldo

    instance - Get a new saldo object

    setCreditDebit - Set saldo type (credit or debit)

    getCreditDebit - Get saldo type (credit or debit)

    getCreditDebitString - Get saldo type as a string

    setBookingDate - Set saldo booking date

    getBookingDate - Get saldo booking date

    getBookingDateAsTimestamp - Get saldo booking date as timestamp

    getFormattedBookingDate - Get saldo formatted booking date

    setCurrency - Set the saldo currency

    getCurrency - Get saldo currency

    setAmount - Set the saldo amount

    getAmount - Get the saldo amount

    parseLine - Parse a given line of MT940 content

    pad - Pads a string with "0" to given size

    MT940

    constructor(configuration)

    Instantiate a MT940 object.

    Arguments

    • configuration (object) - Basic configuration to parse and write bank account transactions in MT940 format.

    Example

    var mt940 = require("node-mt940")({
        parser: MT940.PARSER_DEFAULT,
        writer: MT940.WRITER_DEFAULT,
        pathToContent: '...',
        writeAs: AWriter.WRITE_DEFAULT,
        pathToWrite: '...',
        gvcData: []
    });

    singleton(configuration)

    Get a single MT940 object.

    Arguments

    • configuration (object) - Basic configuration to parse and write bank account transactions in MT940 format.

    Example

    var mt940 = require("node-mt940").singleton({
        parser: MT940.PARSER_DEFAULT,
        writer: MT940.WRITER_DEFAULT,
        pathToContent: '...',
        writeAs: AWriter.WRITE_DEFAULT,
        pathToWrite: '...',
        gvcData: []
    });

    setConfiguration(configuration)

    Set a configuration.

    Arguments

    • configuration (object) - Set basic configuration to parse and write bank account transactions in MT940 format.

    Example

    var mt940 = require("node-mt940").singleton().setConfiguration({
        parser: MT940.PARSER_DEFAULT,
        writer: MT940.WRITER_DEFAULT,
        pathToContent: '...',
        writeAs: AWriter.WRITE_DEFAULT,
        pathToWrite: '...',
        gvcData: []
    });

    setParser(parser)

    Sets the parser that has to be used on parsing transactions. The content path from configuration will be set to the parser automatically after instantiating.

    Arguments

    • parser (number) - Selected parser number

    Example

    var mt940 = require("node-mt940").singleton({
        writer: MT940.WRITER_DEFAULT,
        pathToContent: '...',
        writeAs: AWriter.WRITE_DEFAULT,
        pathToWrite: '...',
        gvcData: []
    });
     
    mt940.setParser(MT940.PARSER_SPARKASSE);

    setWriter(writer)

    Sets the writer that has to be used on writing back bank account transactions. The target path from configuration will be set to the writer automatically after instantiating.

    Arguments

    • writer (number) - Selected writer number

    Example

    var mt940 = require("node-mt940").singleton({
        parser: MT940.PARSER_DEFAULT,
        pathToContent: '...',
        writeAs: AWriter.WRITE_DEFAULT,
        pathToWrite: '...',
        gvcData: []
    });
     
    mt940.setWriter(MT940.WRITER_SPARKASSE);

    setWriteAs(writeAs)

    Configure the format in which to write bank account transactions.

    Arguments

    • writeAs (number) - Selected write format

    Example

    var mt940 = require("node-mt940").singleton({
        parser: MT940.PARSER_DEFAULT,
        writer: MT940.WRITER_DEFAULT,
        pathToContent: '...',
        pathToWrite: '...',
        gvcData: []
    });
     
    mt940.setWriteAs(AWriter.WRITE_PLAIN_TEXT);

    parse(callback)

    Configure the format in which to write bank account transactions.

    Arguments

    • callback (function) - Function called when parsing finishes.

    Example

    var mt940 = require("node-mt940").singleton({
        pathToContent: '...',
        pathToWrite: '...',
        gvcData: []
    });
    mt940
        .setParser(MT940.PARSER_SPARKASSE)
        .setWriter(MT940.WRITER_SPARKASSE)
        .setWriteAs(AWriter.WRITE_PLAIN_TEXT)
        .parse(function(error, revenues) {
            // Get back error and revenue object.
        });

    write(revenues, callback)

    Configure the format in which to write bank account transactions.

    Arguments

    • revenues (Revenues) - All parsed transactions as revenue object.
    • callback (function) - Function called when parsing finishes.

    Example

    var mt940 = require("node-mt940").singleton({
        pathToContent: '...',
        pathToWrite: '...',
        gvcData: []
    });
    mt940
        .setParser(MT940.PARSER_SPARKASSE)
        .setWriter(MT940.WRITER_SPARKASSE)
        .setWriteAs(AWriter.WRITE_PLAIN_TEXT)
        .write(revenues, function(error, mt940Object) {
            // Do some important stuff.
        });

    getWriteStatus()

    Get the status while writing the transactions into file. Available status are:

    • writing
    • ready
    • error

    Later they will trigger events.

    Arguments

    No arguments.

    Example

    var mt940 = require("node-mt940").singleton({
        pathToContent: '...',
        pathToWrite: '...',
        gvcData: []
    });
    mt940
        .setParser(MT940.PARSER_SPARKASSE)
        .setWriter(MT940.WRITER_SPARKASSE)
        .setWriteAs(AWriter.WRITE_PLAIN_TEXT)
        .write(revenues, function(error, mt940Object) {
            // Do some important stuff.
        });
     
        while(mt940.getWriteStatus() === 'writing') {
            console.log('.');
        }

    Parser

    In the beginning there is a default parser and a parser for the bank "Sparkasse". If there are more parsers in future and more experience with them there should be a global one implemented that covers all interpretations of the MT940 standard then this. All defined lines of the content will be converted into well defined objects like PaymentReference or Transaction.

    setContent(content)

    Set the content in MT940 format.

    Arguments

    • content (string) - Complete content that is in MT940 format and has to be parsed.

    Example

    var parser = require("<node_modules>/node-mt940/src/parser/<name>.js").instance();
     
    parser.setContent('...');
    // ...
    // ...

    hasContent()

    Check if parser has content to parse.

    Arguments

    No arguments.

    Example

    var parser = require("<node_modules>/node-mt940/src/parser/<name>.js").instance();
     
    parser.setContent('...');
    // ...
    // ...
    parser.hasContent();
    // ...
    // ...

    setFilePath(path)

    Set the file path with the MT940 content.

    Arguments

    • path (string) - Path to the file with MT940 content.

    Example

    var parser = require("<node_modules>/node-mt940/src/parser/<name>.js").instance();
     
    parser.setFilePath('...');
    // ...
    // ...

    loadContent(path, callback)

    Load the content of configured file path.

    Arguments

    • path (string) - Path to the file with MT940 content.
    • callback (function) - Callback function that provides two object:
      • error: Will be set when an error occured. Default is null.
      • success: Will be true when loading was successful. Otherwise it is null and an error is set.

    Example

    var parser = require("<node_modules>/node-mt940/src/parser/<name>.js").instance();
    parser.loadContent('...', function(error, success) {
        // do some stuff.
    });
    // ...
    // ...

    execute(path, callback)

    Execute parsing file or set content.

    Arguments

    • path (string) - Path to the file with MT940 content.
    • callback (function) - Callback function that provides two object:
      • error: Will be set when an error occured. Default is null.
      • revenues: A revenue object with converted content information.

    Example

    var parser = require("<node_modules>/node-mt940/src/parser/<name>.js").instance();
    parser.execute('...', function(error, revenues) {
        // do some stuff with the results.
    });
    // ...
    // ...

    Writer

    instance()

    Get a new writer instance.

    Arguments

    No arguments.

    Example

    var writer = require("<node_modules>/node-mt940/src/writer/<name>.js").instance();
    // ...
    // ...

    setFilePath(path)

    Set path to write MT940 statements to file.

    Arguments

    • path (string) - Path to the file.

    Example

    var writer = require("<node_modules>/node-mt940/src/writer/<name>.js").instance();
    writer.setFilePath('...');
    // ...
    // ...

    writePlainText(revenues, callback)

    Write transactions in MT940 plain text format

    Arguments

    • revenues (string) - Path to the file with MT940 content.
    • callback (function) - Callback function that provides two object:
      • error: Will be set when an error occured. Default is null.
      • writerObj: A revenue object with converted content information.

    Example

    var parser = require("<node_modules>/node-mt940/src/writer/<name>.js").instance();
    writer.setFilePath('...');
    writer.writePlainText(revenues, function(error, writerObj) {
        // do some stuff with the results.
    });
    // ...
    // ...

    writeXML(revenues, callback)

    Write transactions in MT940 XML format.

    Arguments

    • revenues (string) - Path to the file with MT940 content.
    • callback (function) - Callback function that provides two object:
      • error: Will be set when an error occured. Default is null.
      • writerObj: A revenue object with converted content information.

    Example

    var parser = require("<node_modules>/node-mt940/src/writer/<name>.js").instance();
    writer.setFilePath('...');
    writer.writeXML(revenues, function(error, writerObj) {
        // do some stuff with the results.
    });
    // ...
    // ...

    writeCSV(revenues, callback)

    Write statements in MT940 in CSV format.

    Arguments

    • revenues (string) - Path to the file with MT940 content.
    • callback (function) - Callback function that provides two object:
      • error: Will be set when an error occured. Default is null.
      • writerObj: A revenue object with converted content information.

    Example

    var parser = require("<node_modules>/node-mt940/src/writer/<name>.js").instance();
    writer.setFilePath('...');
    writer.writeCSV(revenues, function(error, writerObj) {
        // do some stuff with the results.
    });
    // ...
    // ...

    Revenue

    instance()

    Get a new revenue object.

    Arguments

    No arguments.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance();
    // ...
    // ...

    setReferenceNumber(number)

    Set the revenue reference number.

    Arguments

    • number (string) - The reference number.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance();
    revenue.setReferenceNumber('...');
    // ...
    // ...

    getReferenceNumber()

    Get the revenue reference number.

    Arguments

    No arguments.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance().setReferenceNumber('...')
      , referenceNumber = revenue.getReferenceNumber();
    // ...
    // ...

    setBankCode(bankCode)

    Set bank code of account.

    Arguments

    • bankCode (string) - The code to be set.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance();
    revenue.setBankCode('...');
    // ...
    // ...

    getBankCode()

    Get bank code of account.

    Arguments

    No arguments.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance().setBankCode('...')
      , bankCode = revenue.getBankCode();
    // ...
    // ...

    setAccountNumber(accountNumber)

    Set the bank account number.

    Arguments

    • accountNumber (string) - The bank account number.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance();
    revenue.setAccountNumber('...');
    // ...
    // ...

    getAccountNumber()

    Get the bank account number.

    Arguments

    No arguments.

    Example

    var revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance().setAccountNumber('...')
      , bankAccountNumber = revenue.getAccountNumber();
    // ...
    // ...

    setExtracts(extractList)

    Set collection of extracts (single statement block).

    Arguments

    • extractList (LinkedList) - A list with all parsed MT940 statement objects.

    Example

    var LinkedList = require('node-linkedlist')
      , revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance()
      , extract = require("<node_modules>/node-mt940/src/object/Extract.js").instance()
      , statements = LinkedList.Create(extract);
     
    // do some stuff here ...
    // ...
    revenue.setExtracts(statements);
    // ...
    // ...

    addExtract(extract, callback)

    Add single extract to extract collection.

    Arguments

    • extractList (LinkedList) - A list with all parsed MT940 statement objects.
    • callback (function) - Callback function that provides two object:
      • error: Will be set when an error occured. Default is null.
      • extractList: The linked list with all available statements added to it.

    Example

    var LinkedList = require('node-linkedlist')
      , revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance()
      , extract = require("<node_modules>/node-mt940/src/object/Extract.js").instance();
     
    // do some stuff here ...
    // ...
    revenue.addExtract(extract, function(error, statementList) {
        // do some other stuff here with the list.
    });
     
    // ...
    // ...

    getExtracts()

    Get collection of extracts.

    Arguments

    No arguments.

    Example

    var LinkedList = require('node-linkedlist')
      , revenue = require("<node_modules>/node-mt940/src/object/Revenue.js").instance()
      , extract = require("<node_modules>/node-mt940/src/object/Extract.js").instance();
     
    // do some stuff here ...
    // ...
     
    revenue.addExtract(extract, function(error, statementList) {
        // do some other stuff here with the list.
    });
    // Linked list of statements.
    var statementList = revenue.getExtracts();
    // ...
    // ...

    Extract

    instance()

    Get a new extract object.

    Arguments

    No arguments.

    Return

    • Extract - The extract object.

    setBankCode(bankCode)

    Set bank code of account.

    Arguments

    • bankCode (string) - The code of the bank account.

    Return

    • Extract - The extract object.

    getBankCode()

    Get bank code of account.

    Arguments

    No argument.

    Return

    • string - The account code.

    setAccountNumber(accountNumber)

    Set bank account number.

    Arguments

    • accountNumber (string) - The number of the bank account.

    Return

    • Extract - The extract object.

    getAccountNumber()

    Get bank account number.

    Arguments

    No argument.

    Return

    • string - The number of the bank account.

    setNumber(number)

    Set extract number.

    Arguments

    • number (string) - The number of the statement.

    Return

    • Extract - The extract object.

    getNumber()

    Get extract number.

    Arguments

    No argument.

    Return

    • string - The number of the extract.

    setSheetNumber(number)

    Set sheet number.

    Arguments

    • number (string) - The sheet number where the statement is located.

    Return

    • Extract - The extract object.

    getSheetNumber()

    Get sheet number.

    Arguments

    No argument.

    Return

    • string - The sheet number of the extract.

    addTransaction(transaction, callback)

    Add a transaction to the extract.

    Arguments

    • transaction (Transaction) - A transaction object with information about one transaction in the statement.
    • callback (function) - The function get two parameters:
      • error: Will be set if an error occurs. If not the parameter is null.
      • list: A reference to the transaction list where the transaction was added.

    Return

    • Extract - The extract object.

    getTransactionById(id, callback)

    Get a specific transaction by its id.

    Arguments

    • id (number) - The transaction id.
    • callback (function) - The function get two parameters:
      • error: Will be set if an error occurs. If not the parameter is null.
      • transaction: A reference to the transaction with given id.

    Return

    • Transaction - The transaction object.

    getTransactions()

    Get list of all extract transactions.

    Arguments

    No argument.

    Return

    • LinkedList - The transaction list.

    setStartSaldo(saldo)

    Set the start saldo.

    Arguments

    • saldo (Saldo) - The transaction start saldo object.

    Return

    • Extract - The extract object.

    getStartSaldo()

    Get the start saldo.

    Arguments

    No argument.

    Return

    • Saldo - The saldo object with amount before transactions calculated.

    setEndSaldo(saldo)

    Set extract end saldo.

    Arguments

    • saldo (Saldo) - The transaction end saldo object.

    Return

    • Extract - The extract object.

    getEndSaldo()

    Get extract end saldo.

    Arguments

    No argument.

    Return

    • Saldo - The saldo object with amount after transactions calculated.

    parseLine(line)

    Parse a given line of MT940 content.

    Arguments

    • line (string) - The string that has to be padded.

    Return

    • Extract - The extract object itself.

    toCSVString()

    Get extract information in CSV format.

    Arguments

    No arguments.

    Return

    • string - The extract information formatted with CSV format.

    setPrevious(previousNode)

    Set the previous extract object.

    Arguments

    • previousNode (Extract) - A extract object as previous node.

    Return

    • Extract - The previous object reference of the linked list.

    previous()

    Get the previous extract object.

    Arguments

    No arguments.

    Return

    • Extract - The previous object reference of the linked list.

    setNext(nextNode)

    Set the next extract object.

    Arguments

    • nextNode (Extract) - A extract object as next node.

    Return

    • Extract - The previous object reference of the linked list.

    next()

    Get the next extract object.

    Arguments

    No arguments.

    Return

    • Extract - The next object reference of the linked list.

    hasPrevious()

    Check if the current extract object has a previous one.

    Arguments

    No arguments.

    Return

    • boolean

    hasNext()

    Check if the current extract object has a next one.

    Arguments

    No arguments.

    Return

    • boolean

    Transaction

    instance()

    Get a new transaction object.

    Arguments

    No arguments.

    Return

    • Transaction - The transaction object.

    setId(id)

    Set transaction id.

    Arguments

    • id (number) - The transaction id.

    Return

    • Transaction - The transaction object itself.

    getId()

    Get transaction id.

    Arguments

    No arguments.

    Return

    • number - The transaction id.

    setValuta(dateTime)

    Set transaction valuta date.

    Arguments

    • dateTime (number) - The transaction valuta date.

    Return

    • Transaction - The transaction object itself.

    getValuta()

    Get the transaction valuta.

    Arguments

    No arguments.

    Return

    • Date - The transaction valuta date. If assigned date was not valid the method returns null.

    getValutaAsTimestamp()

    Get transaction valuta as timestamp.

    Arguments

    No arguments.

    Return

    • number - The valuta date converted into timestamp.

    getFormattedValuta()

    Get formatted transaction valuta.

    Arguments

    No arguments.

    Return

    • string - The formatted valuta date. The date format is: "mmdd".

    setBookingDate(dateTime)

    Set transaction booking date.

    Arguments

    • dateTime (number) - The transaction booking date.

    Return

    • Transaction - The transaction object itself.

    getBookingDate()

    Get transaction booking date.

    Arguments

    No arguments.

    Return

    • Date - The transaction booking date. If assigned date was not valid the method returns null.

    getFormattedBookingDate()

    Get the formatted booking date.

    Arguments

    No arguments.

    Return

    • string - The formatted date. The format is: "YYmmdd".

    setType(type)

    Set the transaction type.

    Arguments

    • type (string) - The transaction type.

    Return

    • Transaction - The transaction object itself.

    getType()

    Get the transaction type. The possible four types are:

    • 'C' (Transaction.TYPE_CREDIT)
    • 'D' (Transaction.TYPE_DEBIT)
    • 'RC' (Transaction.TYPE_CREDIT_STORNO)
    • 'RD' (Transaction.TYPE_DEBIT_STORNO)

    Arguments

    No arguments.

    Return

    • string - The transaction type.

    getTypeString() (deprecated)

    Get the transaction type as string. The possible four types are:

    • 'C' (Transaction.TYPE_CREDIT)
    • 'D' (Transaction.TYPE_DEBIT)
    • 'RC' (Transaction.TYPE_CREDIT_STORNO)
    • 'RD' (Transaction.TYPE_DEBIT_STORNO)

    Arguments

    No arguments.

    Return

    • string - The transaction type as string.

    setLastCharIsoCode(char)

    Set the last char of the transaction iso code.

    Arguments

    • char (string) - The last iso code char.

    Return

    • Transaction - The transaction object itself.

    getLastCharIsoCode()

    Get the last char of the iso code.

    Arguments

    No arguments.

    Return

    • string - The last char of the transaction iso code.

    setAmount(amount)

    Set the transaction amount.

    Arguments

    • amount (number) - The transaction amount. Mostly it will be a float type.

    Return

    • Transaction - The transaction object itself.

    getAmount()

    Get the transaction amount.

    Arguments

    No arguments.

    Return

    • number - The amount of the transaction.

    setBookingKey(key)

    Set the transaction booking key.

    Arguments

    • key (string) - The transaction booking key.

    Return

    • Transaction - The transaction object itself.

    getBookingKey()

    Get the transaction booking key.

    Arguments

    No arguments.

    Return

    • string - The transaction booking key.

    setReference(reference)

    Set transaction reference.

    Arguments

    • reference (string) - The transaction reference.

    Return

    • Transaction - The transaction object itself.

    getReference()

    Get transaction reference.

    Arguments

    No arguments.

    Return

    • string - The transaction reference.

    setPaymentReference(paymentReference)

    Set the transaction payment reference.

    Arguments

    • paymentReference (PaymentReference) - An object of type PaymentReference.

    Return

    • Transaction - The transaction object itself.

    getPaymentReference()

    Get the transaction payment reference.

    Arguments

    No arguments.

    Return

    • PaymentReference - The transaction payment reference object.

    parseLine(line)

    Parse a given line of MT940 content.

    Arguments

    • line (string) - The string that has to be padded.

    Return

    • Transaction - The transaction object itself.

    reset()

    Reset transaction data of the object.

    Arguments

    No arguments.

    Return

    • Transaction - The transaction object itself.

    setPrevious(previousNode)

    Set the previous transaction object.

    Arguments

    • previousNode (Transaction) - A transaction object as previous node.

    Return

    • Transaction - The previous object reference of the linked list.

    previous()

    Get the previous transaction object.

    Arguments

    No arguments.

    Return

    • Transaction - The previous object reference of the linked list.

    setNext(nextNode)

    Set the next extract object.

    Arguments

    • nextNode (Transaction) - A transaction object as next node.

    Return

    • Transaction - The previous object reference of the linked list.

    next()

    Get the next transaction object.

    Arguments

    No arguments.

    Return

    • Transaction - The next object reference of the linked list.

    hasPrevious()

    Check if the current transaction object has a previous one.

    Arguments

    No arguments.

    Return

    • boolean

    hasNext()

    Check if the current transaction object has a next one.

    Arguments

    No arguments.

    Return

    • boolean

    Payment reference

    instance()

    Get a new payment reference object.

    Arguments

    No arguments.

    Return

    • PaymentReference - The payment reference object.

    setGVC(gvc, check)

    Set the GV code.

    Arguments

    • gvc (string) - The GC code.
    • check (boolean) - If set to true it checks the GV code in internal list of GV codes. If the check fails the GV code is not set. Default is false.

    Return

    • PaymentReference - The payment reference object itself.

    getGVC()

    Get the GV code.

    Arguments

    No arguments.

    Return

    • string - The GVC of the payment reference.

    setBookingText(text)

    Set the booking text.

    Arguments

    • text (string) - The booking text.

    Return

    • PaymentReference - The payment reference object itself.

    getBookingText()

    Get the booking text.

    Arguments

    No arguments.

    Return

    • string - The payment reference booking text.

    setPrimanotaNumber(number)

    Set the primanota number.

    Arguments

    • number (string) - The primanota number.

    Return

    • PaymentReference - The payment reference object itself.

    getPrimanotaNumber()

    Get the primanota number.

    Arguments

    No arguments.

    Return

    • string - The primanota number.

    setText(text)

    Set whole payment reference text.

    Arguments

    • text (string) - The whole text.

    Return

    • PaymentReference - The payment reference object itself.

    addText(text)

    Add text.

    Arguments

    • text (string) - Part of the whole text.

    Return

    • PaymentReference - The payment reference object itself.

    getText()

    Get the whole payment reference text.

    Arguments

    No arguments.

    Return

    • string - The payment reference text.

    setPurchaserBIC(bic)

    Set the BIC information.

    Arguments

    • bic (string) - The BIC information.

    Return

    • PaymentReference - The payment reference object itself.

    getPurchaserBIC()

    Get the BIC information.

    Arguments

    No arguments.

    Return

    • string - The BIC information of the bank account.

    setPurchaserAccountNumber(accountNumber)

    Set the bank account number.

    Arguments

    • accountNumber (string) - The number of the bank account.

    Return

    • PaymentReference - The payment reference object itself.

    getPurchaserAccountNumber()

    Get the bank account number.

    Arguments

    No arguments.

    Return

    • string - The number of the bank account.

    setAccountOwnerName(name)

    Set the name of the bank account owner.

    Arguments

    • name (string) - The name of the bank account owner.

    Return

    • PaymentReference - The payment reference object itself.

    getAccountOwnerName()

    Get the name of the bank account owner.

    Arguments

    No arguments.

    Return

    • string - The name of the bank account owner who get or send the amount.

    setTextKeyAddition(keyAddition)

    Set the text key addition.

    Arguments

    • keyAddition (string) - The key addition.

    Return

    • PaymentReference - The payment reference object itself.

    getTextKeyAddition()

    Get the text key addition.

    Arguments

    No arguments.

    Return

    • string - The key addition.

    parseLine(line)

    Parse a given line of MT940 content.

    Arguments

    • line (string) - The string that has to be padded.

    Return

    • PaymentReference - The payment reference object itself.

    pad(string, size)

    Pads a string with "0" to given size.

    Arguments

    • string (string) - The string that has to be padded.
    • size (number) - Number of characters.

    Example

    var paymentReference = require("<node_modules>/node-mt940/src/object/PaymentReference.js").instance();
     
    // do some stuff here ...
    // ...
    var name = 'Hello';
    name = paymentReference.pad(name, 8);
    // Name should be now '000Hello'
     

    Return

    • string - The padded string.

    GVCList

    singleton()

    Get an object of the GVCList.

    Arguments

    No arguments.

    Return

    • GVCList

    createCode(code, text)

    Create a new GV code object.

    Arguments

    • code (string) - A specific code.
    • text (string) - The code text.

    Return

    • GVCode

    setCodes(codes, callback)

    Set a collection of GV codes.

    Arguments

    • codes (string) - A linked list of GVCodes.
    • callback (function) - The callback function that gets the list of GVCodes or an error.

    Return

    • void

    addCode(code, callback)

    Add a GVCode to the list.

    Arguments

    • code (string) - A specific code.
    • callback (function) - The callback function that gets the list of GVCodes or an error.

    Return

    • void

    getByCodeNumber(number)

    Get a specific GVCode object by its code.

    Arguments

    • number (string) - A specific code.

    Return

    • GVCode

    GVCode

    instance()

    Get a new GV code object.

    Arguments

    No arguments.

    Return

    • GVCode - A new object instance.

    setCode(code)

    Set the code itself.

    Arguments

    • code (string) - The code information of the GVC.

    Return

    • GVCode - The object reference.

    getCode()

    Get the code.

    Arguments

    No arguments.

    Return

    • string - The GVCode information (the code itself).

    setText(text)

    Set GV code text.

    Arguments

    • text (string) - The text of the GVC.

    Return

    • GVCode - The object reference.

    getText()

    Get the GV code text.

    Arguments

    No arguments.

    Return

    • string - The GVCode text information.

    toJSON()

    Get GV code information in JSON format.

    Arguments

    No arguments.

    Return

    • object - The GVCode information converted to a literal object.

    setPrevious(previousNode)

    Set the previous GV code object.

    Arguments

    • previousNode (GVCode) - A GVCode object as previous node.

    Return

    • GVCode - The previous object reference of the linked list.

    previous()

    Get the previous GV code object.

    Arguments

    No arguments.

    Return

    • GVCode - The previous object reference of the linked list.

    setNext(nextNode)

    Set the next GV code object.

    Arguments

    • nextNode (GVCode) - A GVCode object as next node.

    Return

    • GVCode - The previous object reference of the linked list.

    next()

    Get the next GV code object.

    Arguments

    No arguments.

    Return

    • GVCode - The next object reference of the linked list.

    hasPrevious()

    Check if the current GV code object has a previous one.

    Arguments

    No arguments.

    Return

    • boolean

    hasNext()

    Check if the current GV code object has a next one.

    Arguments

    No arguments.

    Return

    • boolean

    Saldo

    instance()

    Get a new saldo object.

    Arguments

    No arguments.

    Return

    • Saldo - The saldo object.

    setCreditDebit(value)

    Set the saldo type (credit or debit). Available types are:

    • Saldo.TYPE_CREDIT
    • Saldo.TYPE_DEBIT

    Arguments

    • value (number) - The saldo type (credit or debit).

    Return

    • Saldo - The saldo object.

    getCreditDebit()

    Get saldo type (credit or debit). The mapping for the types is: 1 => "Credit'", 2 => "Debit"

    Arguments

    No arguments.

    Return

    • number - The internal type number for the saldo type.

    getCreditDebitString()

    Get saldo type as a string. The possible standard types are "C" for credit and "D" for debit.

    Arguments

    No arguments.

    Return

    • string - The saldo type.

    setBookingDate(bookingDate)

    Set saldo booking date. The incoming date format is "YYmmdd". This is parsed and converted into a JavaScript date object.

    Arguments

    • bookingDate (string) - The saldo booking date.

    Return

    • Saldo - The saldo object.

    getBookingDate()

    Get saldo booking date.

    Arguments

    No arguments.

    Return

    • Date - The JavaScript Date object.

    getBookingDateAsTimestamp()

    Get saldo booking date as timestamp

    Arguments

    No arguments.

    Return

    • number - The saldo booking date converted to timestamp.

    getFormattedBookingDate()

    Get saldo formatted booking date

    Arguments

    No arguments.

    Return

    • string - The formatted date of the saldo booking. Format is "YYmmdd". So as value like '130213'.

    setCurrency(currency)

    Set the saldo currency

    Arguments

    • currency (string) - The saldo currency.

    Return

    • Saldo - The saldo object.

    getCurrency()

    Get saldo currency

    Arguments

    No arguments.

    Return

    • string - The currency of the current saldo.

    setAmount(amount)

    Set the saldo amount.

    Arguments

    • amount (number) - The amount of the saldo line.

    Return

    • Saldo - The saldo object.

    getAmount()

    Get the saldo amount.

    Arguments

    No arguments.

    Return

    • number - The saldo amount. This could also be a float number.

    parseLine(line)

    Parse a given line of MT940 content.

    Arguments

    • line (string) - The string that has to be padded.

    Return

    • Saldo - The saldo object itself.

    pad(string, size)

    Pads a string with "0" to given size.

    Arguments

    • string (string) - The string that has to be padded.
    • size (number) - Number of characters.

    Example

    var saldo = require("<node_modules>/node-mt940/src/object/Saldo.js").instance();
     
    // do some stuff here ...
    // ...
    var name = 'Hello';
    name = saldo.pad(name, 8);
    // Name should be now '000Hello'
     

    Return

    • string - The padded string.

    Install

    npm i node-mt940

    DownloadsWeekly Downloads

    14

    Version

    0.1.3

    License

    LGPL-3.0

    Last publish

    Collaborators

    • svenmuellerssen