@hublaw/ofx-parser
Version:
A tool that converts financial data from OFX to JS Object.
84 lines (58 loc) • 3.18 kB
Markdown
<p align="center"><h1 align="center">/ofx-parser</h1></p>
<h3 align="center">A light-weight Typescript Ofx Parser</h3>
<br>
<div align="center">

<space><space>

<space><space>

<space><space>

<space><space>

</div>
A light weight Typescript tool that converts financial data from OFX into JS Object, applied only to Bank Account Statement developed and mantained by [HubLaw](https://github.com/hublawbr) and [@gusflopes](https://github.com/hublawbr), and originally written by [@bakesaled](https://github.com/bakesaled).
---
## 🖋 Credits
This tools depends on the [`xml2js`](https://www.npmjs.com/package/xml2js) package and started by a fork from `@bakesaled/carbonate` that did an awesome work mapping all the Ofx Structure to interfaces.
---
## 🚧 Current Status
This tool is still under development and missing tests, but it works as intendend.
This package is currently being used on project under development.
---
## 📝 Instructions
There are two ways to use this use this package. You could use it as a **dependency on your project** to handle parsing OFX files. Or you can run it using the **command line tool**.
### Using this package on your project
It's pretty straightforward, you just need to install this package and use the `parseStatement()` or `parseStatementFile()` functions from the **OfxParser** module.
#### Create a Class to handle Ofx Files
Basically you need to need to install the package:
```bash
yarn add /ofx-parser
```
After that you can create a class to Handle Ofx files:
```ts
import OfxParser from '/ofx-parser'
export default class OfxHandler() {
private ofxParser = new OfxParser()
// Call this handler using a filePath from local file system
// You could use this together with an upload route from Controller
public async handler(filePath: string) {
const result: StatementModel = await ofxParser.parseStatementFile(filePath)
return result
}
}
```
You don't really need a class just for that. Specially if using the `parseStatementFile()` instead of the `parseStatement()`.
The reason I personally prefer using it is because I do more stuff with the Ofx File, like: upload to GCloud Storage, persisting the transactions to bank, formatting specific fields like dates, download Ofx from GCloud, create signedUrl to share file, create readable stream from Gcloud instead of file system, and a few other stuff.
#### Other use cases
*Suggestions would be appreciated, but you can see the examples folder*
### Using as command line tool
You can run this project as originally designed using a command tool. For that you want to **clone the repository**, and run the following commands:
```bash
$ yarn install
$ yarn start
```
___
## License
MIT © [HubLAW](https://github.com/hublawbr)