• Hey there! Welcome to TFC! View fewer ads on the website just by signing up on TF Community.

[Axis] Automatic credit card transaction and rewards tracker

ChurningNoob

TF Ace
RML Group
VIP Lounge
TLDR –
  • Every hour all credit card transactions are automatically fetched from your email
  • Transactions are added to google sheet
  • Expected default rewards generated and milestones achievement calculated
  • The emails processed are labeled so that there no duplicate transactions
  • Project moved here : https://github.com/TheSidd/EmailExpenseTracker
Drawbacks –
  • Refunds cannot be calculated as no email
  • If email template is changed by the bank, need to modify script
Security & Privacy –
  • Main reason to create this and not rely on third-party apps
  • Everything remains private in your account
Before you begin –
Steps –
  1. Visit script.google.com in browser where only one google account is logged in
  2. Click on Create app scripts
  3. Replace Code.gs content with https://gist.github.com/TheSidd/d439779aa048ebcbe9a51ff0514c5751#file-code-gs
  4. Paste your copied excel URL in line 62
  5. Click Save
  6. Left panel Files – Click on Add a file (+ icon) – then HTML – Rename with messages and replace contents from https://gist.github.com/TheSidd/d439779aa048ebcbe9a51ff0514c5751#file-messages-html
  7. Left panel Files – Click on Add a file (+ icon) – then HTML – Rename with parsed and replace contents with https://gist.github.com/TheSidd/d439779aa048ebcbe9a51ff0514c5751#file-parsed-html
  8. Click Save icon
Now your script should look like this

1671014914488.png

  1. Click on Deploy – New Deployment
  2. Now on the pop up click on Setting – select Web App – Provide description and click Deploy
  3. Now Authorize access to script, you will receive warning
  4. Click on Advance – then Click Go to Project-name (unsafe)
  5. Click on allow
  6. A URL should be generated, open and you should see your transactions.
  7. Click on Save data to Sheet
  8. Verify the data in excel
Should look like this, but with data filled

1671015028176.png

If everything is good so far, we can trigger this every hour.
  1. Back to the script page
  2. On left panel click on Triggers (Clock icon)
  3. Add trigger
  4. Select and save the trigger with these options
EDIT : Choose which deployment should run - click dropdown and select your latest deployment.
1671015078847.png

This will trigger the script and fetch details every hour.

So how will it look finally?

image.png

image.png


1671019779982.png
 

Attachments

  • 1671014816654.png
    1671014816654.png
    14 KB · Views: 96
  • 1671014983955.png
    1671014983955.png
    20.7 KB · Views: 108
Last edited:
not working for me after 10 march, any idea why
I had a similar problem, on checking I found out that my axis transaction mails were not in the inbox anymore (I am not sure why, maybe gmail is classifying them to be out of inbox). So made a small change on line number 3 i.e. first line of code in function getRelevantMessages() ; as below to remove the check for in:inbox, post which it has been working fine.

var threads = GmailApp.search("newer_than:1d AND from:axisbank.com AND subject:Transaction alert AND -label:axis_processed",0,100)
 
I had a similar problem, on checking I found out that my axis transaction mails were not in the inbox anymore (I am not sure why, maybe gmail is classifying them to be out of inbox). So made a small change on line number 3 i.e. first line of code in function getRelevantMessages() ; as below to remove the check for in:inbox, post which it has been working fine.
It goes to under updates labels
 
Set it to run once a day(preferably at early morning).
Apart from that, google sheets has an option to remove duplicates.

Data>Data clean-up>Remove duplicates

Will do that as well.
For now, I added Google's "Remove Duplicate" functionality in the script itself. So whenever the processing beings the first step it does is to clear any duplicate values in the "Axis" Sheet.
 
Can you share the code for the same
Add this function to your script:

Code:
/**
 * Removes duplicate rows from the current sheet.
 */
function removeDuplicates() {
  var spreadsheet = SpreadsheetApp.openByUrl("Enter your spreadsheet URL");
  const sheet = spreadsheet.getSheetByName("Axis");
  const data = sheet.getRange(1,1,5000,4).getValues();
  const uniqueData = {};
  for (let row of data) {
    const key = row.join();
    uniqueData[key] = uniqueData[key] || row;
  }
  sheet.clearContents();
  const newData = Object.values(uniqueData);
  sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}

And then just call this removeDuplicates() function in the processTransactionEmails() as the first thing to be done.
 
Back
Top