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

Added a button to normalize the date. #37

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from

Conversation

shaperilio
Copy link

This will force the parsed date to be output as "YYYY-MM-DD", a format that YNAB is guaranteed to accept.

This was tested with real Venmo transactions, which were otherwise unimportable.

This will force the parsed date to be output as "YYYY-MM-DD", a format that
YNAB is guaranteed to accept.
@@ -101,6 +102,22 @@ window.DataObject = class DataObject {
tmp_row[col] = cell;
}
break;
case "Date":
if (normalize_date) {
var d = new Date(cell),
Copy link

@denkristoffer denkristoffer Dec 28, 2020

Choose a reason for hiding this comment

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

Some date format detection and shaping is necessary before this will work, cell can be in a lot of formats that wont work with new Date(). I believe this is why date formatting has not been added so far: #10

@aniav
Copy link
Owner

aniav commented Dec 29, 2020

Hey @shaperilio what's the date format you get from Venmo? Would you mind sharing a few anonymised statement lines?

The code was previously always using moment(cell_value) to produce a Date object and I removed it long ago when YNAB introduced a date format selector in their settings. Also because parsing the date this way was producing varied results, as 2012-07-06 can either mean 6th of July or 7th of June, depending on part of the world you're in.

Date will parse only ISO formatted dates as @denkristoffer mentioned, so I'm thinking maybe we could make the code use some formatting library to try and properly guess the date format and produce the outcome in the YNAB valid format?

Also sorry you had to wait for a response for so long 🙏

@shaperilio
Copy link
Author

Hello @aniav; no worries on the wait.

This is what I got from Venmo this morning:

Username,ID,Datetime,Type,Status,Note,From,To,Amount (total),Amount (fee),Funding Source,Destination,Beginning Balance,Ending Balance,Statement Period Venmo Fees,Terminal Location,Year to Date Venmo Fees,Disclaimer
my_user,,,,,,,,,,,,$520.81,,,,,
,3154016250804306394,2020-11-30T17:07:16,Charge,Complete,My Note,My Name,Payee,+ $45.00,,,Venmo balance,,,,Venmo,,
,3155147014426067350,2020-12-02T06:33:54,Standard Transfer,Issued,,,,"- $2,000.00",,,My Bank *9999,,,,Venmo,,
,3157241580838977867,2020-12-05T03:55:25,Payment,Complete,My Note,My Name,Payee,- $40.00,,Venmo balance,,,,,Venmo,,

It is unrecognizable by YNAB, as we know.

After running through your tool, YNAB does not recognize the date (which is taken directly from the CSV, e.g. the first one above is 2020-11-30T17:07:16):
image

Forgive my crude code for the Javscript universe is a world of confusion to me. To @denkristoffer's point, if you don't select the "Datetime" column and choose to normalize the date, you'll get "NaN-NaN-NaN", which I certainly find sufficient to indicate the user made a mistake (in part because I don't have the capacity to do anything more elegant).

Date parsing is always a nightmare, but something must have changed in the way Venmo outputs things (or the way YNAB imports things) and this works today (and has since I made the modification). We will likely have to do something again next time something changes. I don't think we need to worry about nnnn-nn-nn being confused as month-day or day-month, nor do we need to check the format of the date in Venmo's output. Perhaps a better way to do this is to simply throw away the string beyond the "T"; that way we are not interpreting the date in any way, and if Venmo changes the format, it may be more robust against mangling the date.

When I import what my version outputs with "normalized date" turned on, YNAB does not let me choose the date format. Examining the screenshot carefully, you can see that if you use hyphen as a separator, the only possibility is YYYY-MM-DD (however, YYYY/DD/MM and YYYY/MM/DD both exist). This lucky coincidence means we don't really need to communicate the format to the user.

Curiously, YNAB has a checkbox to "Adjust to local time", despite presumably not accepting any formats with the time included. Checking this box sets all my dates back a day. I think Venmo is outputting UTC.

Of note is that the thousands separator is a comma, and that transaction amount appears in quotes. Venmo is only available in the United States; do we have to worry about any internationalization?

If we know the Venmo output format is universally the same for all customers, there shouldn't be a "normalize" toggle at all.

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.

3 participants