Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@centrapay/swift-parser

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@centrapay/swift-parser

Swift financial message parser (MT940, MT942)

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Centrapay SWIFT Parser

SWIFT bank statement parser for JavaScript (ES2015). Supports MT 940 Customer Statement Message and MT 942 Interim Transaction Report.

Installation

npm install @centrapay/swift-parser

Usage

const parser = require('@centrapay/swift-parser');
const statements = parser.parse({
  type: 'mt940',
  data: fs.readFileSync(path, 'utf8'),
});

statements.forEach(stmt => {
  console.log(stmt.statementDate, stmt.accountIdentification, stmt.number.statement);
  stmt.transactions.forEach(txn => {
    console.log(txn.amount, txn.currency);
  };
};

CLI

This package also includes a CLI which parses a SWIFT file and outputs the result as JSON:

swift-parse -t mt942 my-statement.txt

API

parser.parse()

Parse a SWIFT statement document.

If parser.parse() is invoked with { validate: true } then MT940 statements are additionally validated for:

  • all strictly required tags
  • opening/closing balance currency is the same
  • opening balance + turnover = closing balance

Returns: Array<Statement>

Params:

ParamTypeDescription
datastringraw SWIFT message text
typestringmessage format (mt940 or mt942)
validatebooleanOptional perform additional semantic error checking

Statement

FieldTypeDescription
transactionReferencestringtag 20 reference
relatedReferencestringtag 21 reference
accountIdentificationstringtag 25 own bank account identification
number.statementstringtag 28 main statement number
number.sequencestringtag 28 statement sub number (sequence)
number.sectionstringtag 28 statement sub sub number (present on some banks)
statementDateDatetag 62 (MT940, day precision) or tag 13D (MT942, minute precision)
openingBalanceDateDatetag 60 statement opening date
closingBalanceDateDatetag 62 statement closing date
closingAvailableBalanceDateDatetag 64 closing available balance date, default = closing date
forwardAvailableBalanceDateDatetag 65 forward available balance date, default = closing available date
currencystringstatement currency (USD, EUR ...)
openingBalanceBigNumberbeginning balance of the statement (with sign, based on debit/credit mark)
closingBalanceBigNumberending balance of the statement (with sign, based on debit/credit mark)
closingAvailableBalanceBigNumbertag 64 closing available balance, default = closing balance
forwardAvailableBalanceBigNumbertag 65 forward available balance, default = closing available
informationToAccountOwnerstringadditional statement level information
transactionsarraycollection of transactions
messageBlocksobjectstatement message blocks, if present (EXPERIMENTAL)

Transaction

FieldTypeDescription
dateDatetransaction date
amountBigNumbertransaction amount (with sign, Credit+, Debit-)
reversalBooleantransaction is a reversal
currencystringtransaction currency (copy of statement currency)
detailsstringcontent of relevant 86 tag(s), may be multiline (\n separated)
transactionTypestringMT940 transaction type code (e.g. NTRF ...)
referencestringpayment reference field
entryDateDateentry date field
fundsCodestringfunds code field
bankReferencestringbank reference
extraDetailsstringextra details (supplementary details)
structuredDetailsObjectstructured details if detected
nonSwiftstringcontent of NS tags associated with a transaction (after tags 61 or 86)

Structured Transaction Details

The transaction.structuredDetails attribute can be used to access structured data from statement transaction details (SWIFT "86" tag). The following structured detail formats are supported:

  • '<sep>DD', where <sep> can be '>' or '?' and DD is two digits
  • '/TAG/value', where TAG is 2 to 4 uppercase chars.

Example

>20some details >30more data
{
  "20": "some details",
  "30": "more data"
}

Example

/ORDP/Smith Corp
{
  "ORDP": "Smith Corp"
}

History

See Changelog

Copyright © 2015 Alexander Tsybulsky and other contributors. Copyright © 2020 Centrapay.

This software is licensed under Apache-2.0 License. Please see LICENSE for details.

Credits

Forked from a-fas/mt940. Originally inspired by WoLpH/mt940.

Keywords

FAQs

Package last updated on 30 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc