Skip to content
This repository has been archived by the owner on Sep 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #9 from webschik/webschik.8
Browse files Browse the repository at this point in the history
#8: add a customizable transaction id generator
  • Loading branch information
webschik authored Nov 6, 2017
2 parents 9cc9242 + 5676f72 commit f0b2ccd
Show file tree
Hide file tree
Showing 13 changed files with 2,766 additions and 40 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.6.0
* **Breaking change**: [new transaction id generator](README.md#readoptions)

## 0.5.2
* fix parsing of customer and bank references

Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,40 @@

> An isomorphic Javascript library for working with [MT940](#related-links) format
> # [Changelog](CHANGELOG.md)
## Reading
### API
#### read(buffer)
#### read(buffer, options)
* `buffer` {Buffer|ArrayBuffer} - income buffer that contains data of mt940 file.
* `options` {ReadOptions}
* returns `Promise` with list of [Statement](src/typings.ts#L40).

##### ReadOptions
* `getTransactionId(transaction, index)` - a custom generator for transaction id. By default it's:
```js
/**
* @description version 0.5.x
* @param {Transaction} transaction
* @param {number} index
* @returns {string}
*/
function getTransactionId (transaction, index) {
return md5(`${ date }${ transaction.description }${ amount }${ transaction.currency }`);
}


/**
* @description version 0.6.x+
* @param {Transaction} transaction
* @param {number} index
* @returns {string}
*/
function getTransactionId (transaction, index) {
return md5(JSON.strinfigy(transaction));
}
```

### Node.js environment
````js
import * as mt940 from 'mt940-js';
Expand Down
Loading

0 comments on commit f0b2ccd

Please sign in to comment.