twang2218 / node-cba-netbank

Unofficial The Commonwealth Bank of Australia NetBank API wrap for Node.js
Apache License 2.0
74 stars 25 forks source link

Most recent transactions not appearing #4

Open dwdickens opened 7 years ago

dwdickens commented 7 years ago

Hi, thanks so much for making this available - it's great!

I've noticed the most recent transactions aren't being pulled. As I try this at around 11pm AEST, only transactions up to the previous day are being returned, not today's transactions.

Perhaps this line is the issue? Should it be a reference to local time rather than UTC?

var to = toDateString(moment.utc().valueOf());

mcat-ee commented 7 years ago

hey @dwdickens, I see you've forked this project and modified date handling - did you fix this issue?

dwdickens commented 7 years ago

No it wasn't the date handling. It looks like it's some sort of server side caching, but I have no idea. Here are the steps to reproduce:

  1. Run script to obtain list of transaction
  2. Have additional transactions occur in account
  3. Run script again - it will obtain the same list as from 1 and won't be updated.

The workaround I have found is to manually log in to Netbank, open the account and scroll down. If I then run the script, it picks up the most recent transactions. It doesn't matter if I manually log in to Netbank on a different machine to the one that runs the script.

Based on this, I think there must be some sort of server side caching that goes on. Any ideas? It's quite annoying!

twang2218 commented 7 years ago

Yes, you are right, the date should be AEST timezone, not utc:

function toDateString(timestamp) {
  return moment(timestamp).utc().format('DD/MM/YYYY');
}

I will fix this later.

However, it shouldn't cause your problem, as you tried it around 11pm AEST, which is the same day as UTC.

Are you talking about the Pending transactions? Most recent transactions might not be cleared, and are pending. Currently, this program will only return the processed transactions, as some data in the pending transactions are not accurate, might be changed later, (such as time). To avoid the duplication, I didn't return the pending ones. However, I can add support for returning pending transactions as a special group, if it's necessary.

twang2218 commented 7 years ago

I fixed the timezone issue, and added the pending transactions in the resp.pendings object, as well as the new ui command.

After reinstall node-cba-netbank in global, you can try cba-netbank ui to login, choose a account, and after the transactions be downloaded, the pending transactions will be on the top.

Please have a look, and let me know if you still have any issue.

dwdickens commented 7 years ago

Thanks Tao, that's great! I haven't had a play with the update, but the issue of needing to log in to netbank manually to allow the script to pick up recent transactions is unrelated to pending transactions.

Here are the steps to reproduce: 1.Run script to obtain list of transactions

  1. Generate a transaction (gg, transfer $5 from one account to another. This happens immediately and isn't described as pending). 3.Run script again - it will obtain the same list as from 1 (the new transaction is missing).
  2. Log in to netbank, click on the account and scroll down.
  3. Run the script again - this time it will pick up the most recent transaction

The only explanation I can think of is that on the server side, it is caching the transaction list and the script does not cause the server to refresh but manually logging in does.

twang2218 commented 7 years ago

Hi, I just test the procedure via cba-netbank ui command, even without exit the program, it retrieved the transaction just happened:

$ cba-netbank ui
Logon as account XXXXXXX ...
? Which account? Smart Access   (0620XX XXXXXXXX)    Balance: $1047.44   Available Funds: $1047.44
Downloading history [03/05/2017 => 03/07/2017] ...
Time              Description                                               Amount     Balance
----------------  --------------------------------------------------------  ---------  --------
2017-07-03 11:20  Transfer to xx0642 NetBank; test                          $-5.00     $1047.44
...

Total 38 transactions and 0 pending transactions.
? Which account? Smart Access   (0620XX XXXXXXXX)    Balance: $1047.44   Available Funds: $1047.44
Downloading history [03/05/2017 => 03/07/2017] ...
Time              Description                                               Amount     Balance
----------------  --------------------------------------------------------  ---------  --------
2017-07-03 11:23  Transfer to xx0642 CommBank app; Test                     $-5.00     $1042.44
2017-07-03 11:20  Transfer to xx0642 NetBank; test                          $-5.00     $1047.44
...

Total 39 transactions and 0 pending transactions.

I tried both online banking over desktop browser and mobile netbank app, they seems appeared on the transaction history immediately. Is it possible that the ISP/router cached the request? I can add a explicit no-cache to the http header if the new version is still not working.

twang2218 commented 7 years ago

no-cache has been added in v0.7.1 as it seems no harm to add anyway.

dwdickens commented 7 years ago

Great, I'll give it a try. Thanks so much for this, it's a fantastic project

rikdepeuter commented 6 years ago

Thank you for this project, it works fabulously! But could you please add the option so that you can download the pending transactions as well? You mentioned above that you could do that, it would be a great help to me if I can download those through the command-line. Edit: for now to be able to continue I edited the cli.js to give me an extra command which is a copy of the "download" command but returns the history.pendings instead. Without a date filter.

mcat-ee commented 6 years ago

@rikdepeuter that sounds ace! Maybe submit your edits as a pull request and we can all pick over it?