Git Product home page Git Product logo

ofx's Introduction

OFX

<img src=“https://badge.fury.io/rb/ofx.svg” alt=“Gem Version” /> <img src=“https://github.com/annacruz/ofx/actions/workflows/config.yml/badge.svg” alt=“Build Status” />

A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports both OFX 1.0.2 and 2.1.1.

Works on both ruby 1.9 and 2.0.

Usage

require "ofx"

OFX("file.ofx") do
  p account
  p account.balance
  p account.transactions
end

Invalid files will raise an OFX::UnsupportedFileError.

Creator

Maintainer

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ofx's People

Contributors

annacruz avatar arthurgeek avatar chopmo avatar chrisroos avatar danielfone avatar danielvlopes avatar deltadd avatar dependabot-preview[bot] avatar dependabot[bot] avatar douglaslise avatar dx7 avatar eltonlk avatar esdras avatar felipediesel avatar fnando avatar idanci avatar jaischeema avatar jtadeulopes avatar marcosdemelo avatar mrbongiolo avatar nhgrave avatar ouranos avatar paulstuartparker avatar ysbaddaden avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ofx's Issues

Version

Hi Anna, how do you update the project version?

If is like bellow, can I put this in the README?

Deploy

  1. Create and send the new version to Rubygems
$ bundle exec rake release
  1. Create a new release on Github
  • Choose the new tag (Ex.: v0.10.1)
  • Fill the Release title (Ex.: 0.10.1)
  • Click at Generate release notes
  • Click at Publish release
  1. Done!

An example of how it will look

https://github.com/asseinfo/br_danfe/releases/tag/v0.17.6

image

Travis migrated to travis-ci.com

Here’s the TL;DR version:

  • Travis-ci.org shut down will occur on May 31, 2021
  • This change is to ensure product updates and fixes can be implemented for all users, at the same time
  • All your repositories on travis-ci.org should be migrated to travis-ci.com before May 31, 2021 to avoid builds not running
  • All repositories – private, and public – will continue to build as expected on travis-ci.com once migrated
  • Your historic build data on travis-ci.org will remain available in a read-only state for an indefinite period

https://blog.travis-ci.com/2021-05-07-orgshutdown

@annacruz , if you want to ditch travis or just add support for github actions, let me know and I'll submit a PR configuring github actions in the project.

0.3.5 is broken on rubygems

I am hitting this issue too : #96
It looks like the 0.3.5 hosted on rubygems differs from the repo.
I diffed the gem against this repo and ignoring the difference caused by rubocop/standard, this line is causing the issue
The content attr_reader is missing a t.

attr_reader :headers, :body, :conten, :parser

should be

attr_reader :headers, :body, :content, :parser

I think we need to create a new re-lease to fix.

Error in computing @amount_to_pennies in balance and avail_balance

Just found this when I decided to add bank transactions to a project.

The project is a patterned after GnuCash which used 'Pennies' for their amounts. After I figured out how to use the gem and got our bank OFX file to load, I found a small problem.

All you transactions use BigDecimal for amounts and then convert that into pennies, all except for the balance amounts. The balance portion of our statement

       <LEDGERBAL>
           <BALAMT>34553.52
           <DTASOF>20180831000000.000[-5:CDT]
        </LEDGERBAL>
        <AVAILBAL>
           <BALAMT>34553.52
           <DTASOF>20180831000000.000[-5:CDT]
        </AVAILBAL>

in your code 'build_balance' the amount returns 34553.52 (float) but amount_to_pennies is 3455351. because from an irb session

irb(main):005:0> "34553.52".to_f * 100
=> 3455351.9999999995
# I changed the code to test
 :amount_in_pennies => (amount * 100).round(2).to_i,

I then got the right amount of pennies, but you probably to should call build_amount which returns a BigDecimal. I tried but not great at XML parsing.

Multiple statements/accounts per file

Fantastic library! Found a curveball you might be interested in, however.

American Express lets customers export a single .ofx file containing multiple statements from multiple credit cards.

Each statement has a repetition of the account number, balance, etc.

While it's easy to have a separate .ofx per CC account, it may be an invalid assumption that there is a 1-1 relationship between .ofx and account.

In my use case, I need to access the balance for each month, but only the first balance is available through the current API.

I can send you a sample file if you like.

Is this project still active?

Hi!

We'd like to use this gem in your project but we noticed that the last commit was in 2019.

Does anyone know if this project is still being maintained?

Thanks.

Argument error when DTASOF = 00000000

Hello @annacruz

I have tried to parse an .ofx generated directly from a famous brazilian bank (the big red one) that has the folowing content:

...
<LEDGERBAL>
<BALAMT>0,00
<DTASOF>00000000
</LEDGERBAL>
...

I can't upload the whole file because it is not mine, but the problem is that DTASOF can't be parsed:

ArgumentError: argument out of range
    from /.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/time.rb:202:in `local'
    from /.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/time.rb:202:in `make_time'
    from /.rvm/rubies/ruby-1.9.3-p545/lib/ruby/1.9.1/time.rb:271:in `parse'
    from /.rvm/gems/ruby-1.9.3-p545@ror/gems/ofx-0.3.2/lib/ofx/parser/ofx102.rb:109:in `build_date'
    from /.rvm/gems/ruby-1.9.3-p545@ror/gems/ofx-0.3.2/lib/ofx/parser/ofx102.rb:118:in `build_balance'
    from /.rvm/gems/ruby-1.9.3-p545@ror/gems/ofx-0.3.2/lib/ofx/parser/ofx102.rb:58:in `build_account'
    from /.rvm/gems/ruby-1.9.3-p545@ror/gems/ofx-0.3.2/lib/ofx/parser/ofx102.rb:26:in `account'
    from (irb):2:in `block in irb_binding'
    from /.rvm/gems/ruby-1.9.3-p545@ror/gems/ofx-0.3.2/lib/ofx.rb:25:in `instance_eval'
    from /.rvm/gems/ruby-1.9.3-p545@ror/gems/ofx-0.3.2/lib/ofx.rb:25:in `OFX'
    from (irb):2
    from /.rvm/rubies/ruby-1.9.3-p545/bin/irb:12:in `<main>'

1.0 release?

Hey, this is an awesome library and thanks for still working on it (e.g. issues and PRs).

It would be awesome if you could make a 1.0 release. The API seems stable enough and it's working well for our requirements. It's just sad when a library sits in "0.x" development for an eternity. Even if you are not fully happy, even just releasing the current 0.3.0 as 1.0 would be fine.

0.3.5 parser gives me OFX::UnsupportedFileError - works in 0.3.3

I've been using OFX for about 5 or 6 years. Same bank, same format.

I initially had some problem, think a BigDecimal error that I patched.

I'm using it in a Rails application that I'm trying to update. My new approach is I download a QBO file from the bank and stuff it in a BankStatement model as a text field.

I was working with 0.3.3 using

gem 'ofx' , '~> 0.3.3' , github: 'annacruz/ofx', branch: 'main'

In my gem file. I saw that the version was updates and then just did gem 'ofx' in the gem file and it bundled 0.3.5. I swear it worked a few weeks ago but now I'm getting the OFX::UnsupportedFileError. I dropped back to 0.3.3 and it still works. A short example of a downloaded text file:

"OFXHEADER:100\r\nDATA:OFXSGML\r\nVERSION:102\r\nSECURITY:NONE\r\nENCODING:USASCII\r\nCHARSET:1252\r\nCOMPRESSION:NONE\r\nOLDFILEUID:NONE\r\nNEWFILEUID:NONE\r\n\r\n<OFX>\r\n   <SIGNONMSGSRSV1>\r\n      <SONRS>\r\n         <STATUS>\r\n            <CODE>0\r\n            <SEVERITY>INFO\r\n         </STATUS>\r\n         <DTSERVER>20220910081143.727[-5:CDT]\r\n         <LANGUAGE>ENG\r\n         <FI>\r\n            <ORG>River Bank & Trust\r\n            <FID>52161\r\n         </FI>\r\n         <INTU.BID>52161\r\n         <INTU.USERID>xxxx@cccc\r\n      </SONRS>\r\n   </SIGNONMSGSRSV1>\r\n   <BANKMSGSRSV1>\r\n      <STMTTRNRS>\r\n         <TRNUID>0\r\n         <STATUS>\r\n            <CODE>0\r\n            <SEVERITY>INFO\r\n         </STATUS>\r\n         <STMTRS>\r\n            <CURDEF>USD\r\n            <BANKACCTFROM>\r\n               <BANKID>xxxxxx\r\n               <ACCTID>yyyyyyy\r\n               <ACCTTYPE>CHECKING\r\n            </BANKACCTFROM>\r\n            <BANKTRANLIST>\r\n               <DTSTART>20220901000000.000[-5:CDT]\r\n               <DTEND>20220910235959.000[-5:CDT]\r\n               <STMTTRN>\r\n                  <TRNTYPE>CREDIT\r\n                  <DTPOSTED>20220909000000.000\r\n                  <TRNAMT>603\r\n                  <FITID>63671357\r\n                  <NAME>VETERANS OF WARS PAYMENT\r\n                  <MEMO>Deposit VETERANS OF WARS PAYMENT\r\n               </STMTTRN>\r\n               <STMTTRN>\r\n                  <TRNTYPE>DEBIT\r\n                  <DTPOSTED>20220902000000.000\r\n                  <TRNAMT>-800\r\n                  <FITID>63406872\r\n                  <CHECKNUM>3706\r\n                  <NAME>CK # 3706\r\n                  <MEMO>On-Us Check CK # 3706\r\n               </STMTTRN>\r\n               <STMTTRN>\r\n                  <TRNTYPE>DEBIT\r\n                  <DTPOSTED>20220901000000.000\r\n                  <TRNAMT>-78\r\n                  <FITID>63356623\r\n                  <NAME>BP-AUTO OWNERS I BILL PAY\r\n                  <MEMO>On-Us Check BP-AUTO OWNERS I BILL PAY\r\n               </STMTTRN>\r\n            </BANKTRANLIST>\r\n            <LEDGERBAL>\r\n               <BALAMT>16819.07\r\n               <DTASOF>20220910081143.000[-5:CDT]\r\n            </LEDGERBAL>\r\n            <AVAILBAL>\r\n               <BALAMT>16819.07\r\n               <DTASOF>20220910081143.000[-5:CDT]\r\n            </AVAILBAL>\r\n         </STMTRS>\r\n      </STMTTRNRS>\r\n   </BANKMSGSRSV1>\r\n</OFX>\r\n"

If I try to parse it in a Rails console

bs = BankStatement.find(52)
acct =  OFX(bs.ofx_data).account

I get an error:

/Users/salex/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ofx-0.3.5/lib/ofx/parser.rb:15:in `rescue in initialize': OFX::UnsupportedFileError (OFX::UnsupportedFileError)                                        
/Users/salex/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/ofx-0.3.5/lib/ofx/parser.rb:13:in `initialize': undefined local variable or method `content' for #<OFX::Parser::Base:0x000000013d80ca30 @content="OFXHEADER:100\r\nDATA:OFXSGML\r\nVERSION:102\r\nSECURITY:NONE\r\nENCODING:USASCII\r\nCHARSET:1252\r\nCOMPRESSION:NONE\r\nOLDFILEUID:NONE\r\nNEWFILEUID:NONE\r\n\r\n<OFX>\r\n   <SIGNONMSGSRSV1>\r\n      <SONRS>\r\n         <STATUS>\r\n            <CODE>0\r\n            <SEVERITY>INFO\r\n         </STATUS>\r\n         <DTSERVER>20220910081143.727[-5:CDT]\r\n         <LANGUAGE>ENG\r\n         <FI>\r\n            <ORG>River Bank & Trust\r\n            <FID>52161\r\n         </FI>\r\n         <INTU.BID>52161\r\n         <INTU.USERID>wpp8600@qm14\r\n      </SONRS>\r\n   </SIGNONMSGSRSV1>\r\n   <BANKMSGSRSV1>\r\n      <STMTTRNRS>\r\n         <TRNUID>0\r\n         <STATUS>\r\n            <CODE>0\r\n            <SEVERITY>INFO\r\n         </STATUS>\r\n         <STMTRS>\r\n            <CURDEF>USD\r\n            <BANKACCTFROM>\r\n               <BANKID>062206567\r\n               <ACCTID>20011288\r\n               <ACCTTYPE>CHECKING\r\n            </BANKACCTFROM>\r\n            <BANKTRANLIST>\r\n               <DTSTART>20220901000000.000[-5:CDT]\r\n               <DTEND>20220910235959.000[-5:CDT]\r\n               <STMTTRN>\r\n                  <TRNTYPE>CREDIT\r\n                  <DTPOSTED>20220909000000.000\r\n                  <TRNAMT>603\r\n                  <FITID>63671357\r\n                  <NAME>VETERANS OF WARS PAYMENT\r\n                  <MEMO>Deposit VETERANS OF WARS PAYMENT\r\n               </STMTTRN>\r\n               <STMTTRN>\r\n                  <TRNTYPE>DEBIT\r\n                  <DTPOSTED>20220902000000.000\r\n                  <TRNAMT>-800\r\n                  <FITID>63406872\r\n                  <CHECKNUM>3706\r\n                  <NAME>CK # 3706\r\n                  <MEMO>On-Us Check CK # 3706\r\n               </STMTTRN>\r\n               <STMTTRN>\r\n                  <TRNTYPE>DEBIT\r\n                  <DTPOSTED>20220901000000.000\r\n                  <TRNAMT>-78\r\n                  <FITID>63356623\r\n                  <NAME>BP-AUTO OWNERS I BILL PAY\r\n                  <MEMO>On-Us Check BP-AUTO OWNERS I BILL PAY\r\n               </STMTTRN>\r\n            </BANKTRANLIST>\r\n            <LEDGERBAL>\r\n               <BALAMT>16819.07\r\n               <DTASOF>20220910081143.000[-5:CDT]\r\n            </LEDGERBAL>\r\n            <AVAILBAL>\r\n               <BALAMT>16819.07\r\n               <DTASOF>20220910081143.000[-5:CDT]\r\n            </AVAILBAL>\r\n         </STMTRS>\r\n      </STMTTRNRS>\r\n   </BANKMSGSRSV1>\r\n</OFX>\r\n"> (NameError)
Did you mean?  conten
               @content

Again, I have a working version, but something changed.

EDIT
I saw that account has been deprecated and I tried accounts but still gets error.

The Did you mean? conten @content
error look like a type?

Just added content!

Tests Failling

I am trying to update my projects, but I realize now that a lot of tests are breaking.

This is happening to you also? I can check that and make it work again.

ArgumentError at TRNAMT

Some brazilian banks are generating an invalid value for TRNAMT tag.

It breaks the line below:

https://github.com/annacruz/ofx/blob/main/lib/ofx/parser/ofx102.rb#L200

ArgumentError: invalid value for BigDecimal(): "."

Today we're catching the argument error and returning to the user that the file is not valid. But it is a good solution because it invalidates all the file.

We wouldn't like to create a parallel source to treat it.

One solution we found is to treat this argument error inside the gem returning zero.

Is there any chance to be approved a PR resolving this problem?

We'd love to work on it but we don't want to waist our time if it is not a good idea.

Thanks.

Pull requests

Hi @annacruz, did you see that in my last pull requests that you integrated, all the commits I made in the working branches appeared in the main branch?

It didn't have any really bad messages, but I'd like to know what you think of doing a squash when you integrate PR into the main branch?

It would even be possible to configure Github to show this option by default:

To configure: https://github.com/annacruz/ofx/settings

image

Regression in master (compared to 0.3.2)

Today I upgraded my code from the latest gem version (0.3.2) to master (at 3c084de), and the parser started choking on the files:

ArgumentError: wrong number of arguments (given 1, expected 0)
  /Users/thbar/.rvm/gems/ruby-2.4.0/bundler/gems/ofx-3c084de7ff94/lib/ofx/parser/ofx102.rb:116:in `build_balance'
  /Users/thbar/.rvm/gems/ruby-2.4.0/bundler/gems/ofx-3c084de7ff94/lib/ofx/parser/ofx102.rb:63:in `build_account'
  /Users/thbar/.rvm/gems/ruby-2.4.0/bundler/gems/ofx-3c084de7ff94/lib/ofx/parser/ofx102.rb:31:in `account'

I cannot at this point provide data (yet), but I still wanted to open the issue to avoid seeing a 1.0 release with that regression included.

Nokogiri version restriction prevents use with rails 7.1

Rails 7.1 will be releasing this year. Rails 7.1 will require nokogiri 1.14 or higher, but ofx restrict to lower than 1.14, making it incompatible with rails 7.1.

The upper bound should be remove, that way we could control it in our own gemfile or you could merge this PR from dependabot : #108

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.