Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Fix #42: Work with suntrust double column csv files #48

Merged
merged 11 commits into from
Jul 7, 2015

Conversation

BlackEdder
Copy link
Collaborator

  • Add test for suntrust
  • Improve Money.from_s method
  • csvparser merge columns should use moneycolumn.merge

The problem:

Suntrust csv has two money columns, one for debit and one for credit. Reckon used to deal with this by appending two columns (space separated) with each other and then testing them for a money column. This works fine if one column is always empty -> ["2.00", ""], ["", "1.00"] merged is ["2.00" + " " + "", "" + " " + "1.00"]
but the suntrust one had 0.00 instead of "" -> ["2.00", "0"], ["0", "1.00"] merged is ["2.00" + " " + "0", "0" + " " + "1.00"], which clearly leads to problems.

The solution

First convert the columns to money columns and then merge them like that. The only downside of this solution is that when converting to money we lose some information (prefixes and suffixes). This initially led to some problems when converting two columns that had numbers in them, but clearly where not money columns (account numbers etc). I solved this by making the Money.from_s function stricter.

@BlackEdder BlackEdder changed the title [WIP] Fix #42: Work with suntrust double column csv files [RFC] Fix #42: Work with suntrust double column csv files Apr 23, 2015
@BlackEdder
Copy link
Collaborator Author

The commit history on this is a bit of a mess, because I tried multiple approaches. Therefore some of the later commits undo much of the earlier commits. I can rebase and clean that up if requested.

Reckon::MoneyColumn.new( ["", "AB-2.00C"] ) ).should == [
Reckon::Money.new( 1.00 ), Reckon::Money.new( -2.00 ) ]
Reckon::MoneyColumn.new( ["AB1.00C", "AB0C"] ).merge!(
Reckon::MoneyColumn.new( ["AB0C", "AB-2.00C"] ) ).should == [
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example CSV that has numbers in this format? It might be worth adding above... or is this the Suntrust one? I just don't see why that one was having issues.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no real example, but thought it was nice to allow arbitrary postfix/prefix with numbers in them. In many ways this is more for the columns that are likely to not be money, but something like account numbers. It will still parse them as money and give them the benefit of the doubt.

I've updated the description of this PR to explain why the suntrust csv didn't work.

@cantino
Copy link
Owner

cantino commented Apr 25, 2015

I don't have a strong opinion about rebasing the history. Up to you if you want to.

@BlackEdder
Copy link
Collaborator Author

Added explanations and named regexes to the from_s method. Hope that is a lot clearer now.

If don't really have a strong opinion about rebasing, so let's keep it like this.

@cantino
Copy link
Owner

cantino commented Jul 3, 2015

Sorry for the delay here. What's the status on this?

@BlackEdder
Copy link
Collaborator Author

I'm happy with this. In general this change results in a more robust system and adds support for an additional csv format.

@cantino
Copy link
Owner

cantino commented Jul 6, 2015

LGTM! Go ahead and merge :)

BlackEdder added a commit that referenced this pull request Jul 7, 2015
[RFC] Fix #42: Work with suntrust double column csv files
@BlackEdder BlackEdder merged commit 3d2b1e5 into cantino:master Jul 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants