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

Support of multi accounts files #10 #64

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

gustawdaniel
Copy link
Contributor

@gustawdaniel gustawdaniel commented May 1, 2020

In this pull request packages are updated:

 fecha                       ^3.0.3  →   ^4.2.0 
 iconv-lite                  ^0.5.0  →   ^0.5.1 
 jschardet                   ^2.1.0  →   ^2.1.1 
 eslint                      ^6.0.1  →   ^6.8.0 
 eslint-config-airbnb-base  ^14.0.0  →  ^14.1.0 
 eslint-plugin-import       ^2.16.0  →  ^2.20.2 
 mocha                       ^6.0.1  →   ^7.1.2 

Support for multi accounts files was added.
Support for single account files was not changed.

Structure of single account json:

{
  type: 'Bank',
  transactions: [
    {
      date: '2010-03-03T00:00:00',
      amount: -379,
      payee: 'SOME £$™€ CHARACTERS'
    }
  ]
}

Structure of multi account json:

{
  "accounts": [
    {
      "name": "Alior GBP",
      "type": "Bank"
    },
    {
      "name": "Revolut USD",
      "type": "Bank"
    }
  ],
  "transactions": [
    {
      "date": "2010-03-03T00:00:00",
      "amount": -379,
      "payee": "CITY OF SPRINGFIELD",
      "account": "Alior GBP"
    },
    {
      "date": "2010-04-03T00:00:00",
      "amount": -20.28,
      "payee": "YOUR LOCAL SUPERMARKET",
      "account": "Alior GBP"
    },
    {
      "date": "2010-03-03T00:00:00",
      "amount": -421.35,
      "payee": "SPRINGFIELD WATER UTILITY",
      "account": "Alior GBP"
    },
    {
      "date": "2016-05-31T00:00:00",
      "payee": "Authorization sms",
      "amount": -0.2,
      "category": "Services",
      "subcategory": "Financial",
      "account": "Revolut USD"
    }
  ]
}

Copy link
Owner

@spmason spmason left a comment

Choose a reason for hiding this comment

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

The changes look mostly fine, thanks for contributing. There's just some cleanup to do and I think the date-format-guessing needs to be removed

lib/qif2json.js Outdated Show resolved Hide resolved

const US_DATE_FORMATS = ['MM-DD-YYYYHH:mm:ss', 'MM-DD-YYYY', 'MM-DD-YY'];
const UK_DATE_FORMATS = ['DD-MM-YYYYHH:mm:ss', 'DD-MM-YYYY', 'DD-MM-YY'];

function parseDate(dateStr, formats) {
if (formats === 'us') {
if (formats === 'us' || dateStr.includes("'")) {
Copy link
Owner

Choose a reason for hiding this comment

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

It seems a bit risky to say that any dateStr that includes a ' is a US date format

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there any better proposition? This code do not breaks compatibility but is open also for other date format, that I am using.

Copy link
Owner

Choose a reason for hiding this comment

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

Per #26 you can pass in a dateFormat option to control how the dates are parsed. us is only supported for backward compatibility

lib/qif2json.js Outdated Show resolved Hide resolved
lib/qif2json.js Outdated Show resolved Hide resolved
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