Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Fix incorrect cash balance when the user has instant deposit cash ava…
Browse files Browse the repository at this point in the history
…ilable (#45)

## Bug Fixes

- Fixed an incorrect cash balance when the user had instant deposit cash available. (Closes #44)
- Fixed an issue where Firefox would incorrectly calculate the last sync date/time, requiring a manual sync every time.

## Maintenance

- Adds a pull request template.
  • Loading branch information
pkmnct committed Jan 28, 2021
1 parent 4ea984a commit abc5cac
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 21 deletions.
26 changes: 26 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!--
Thank you for contributing to this project! In order to build the changelog, any changes must be
documented in one of the following sections.
If this pull request does not include one of the sections, you may omit it.
If any of the items close an open issue, reference the issue with the "closes" keyword. For example:
- Introduce Pull Request Template (closes #123)
-->

## New Features

-

## Bug Fixes

-

## Maintenance

-

<!--
Make sure that you have run `npm version` with the correct versioning on this branch.
This project strives to follow Semantic Versioning (https://semver.org/)
-->
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "robinhood-mint-sync-chrome",
"version": "3.4.0",
"version": "3.4.1",
"repository": {
"type": "git",
"url": "git+https://github.com/pkmnct/robinhood-mint-sync-chrome.git"
Expand Down
26 changes: 20 additions & 6 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Robinhood Mint Sync",
"description": "Automatically add your Robinhood portfolio to Mint",
"version": "3.4.0",
"version": "3.4.1",
"author": "George Walker",
"browser_specific_settings": {
"gecko": {
Expand All @@ -17,7 +17,11 @@
"512": "images/icon512.png"
},
"background": {
"scripts": ["js/background/main.js", "js/background/update_install_listener.js", "js/background/browser_action.js"]
"scripts": [
"js/background/main.js",
"js/background/update_install_listener.js",
"js/background/browser_action.js"
]
},
"browser_action": {
"default_icon": {
Expand All @@ -38,21 +42,31 @@
"js": ["js/content/robinhood/login.js"]
},
{
"matches": ["https://mint.intuit.com/settings.event?filter=property&addRobinhood=true"],
"matches": [
"https://mint.intuit.com/settings.event?filter=property&addRobinhood=true"
],
"js": ["js/content/mint/properties/update.js"]
},
{
"matches": ["https://mint.intuit.com/settings.event?filter=property&setupRobinhood=true"],
"matches": [
"https://mint.intuit.com/settings.event?filter=property&setupRobinhood=true"
],
"js": ["js/content/mint/properties/check.js"]
},
{
"matches": ["https://mint.intuit.com/settings.event?filter=property&createProperty=true&property=*"],
"matches": [
"https://mint.intuit.com/settings.event?filter=property&createProperty=true&property=*"
],
"js": ["js/content/mint/properties/create.js"]
},
{
"matches": ["https://mint.intuit.com/overview.event*"],
"js": ["js/external/noty/noty.min.js", "js/content/mint/main.js"],
"css": ["css/notification.css", "js/external/noty/noty.css", "js/external/noty/themes/relax.css"]
"css": [
"css/notification.css",
"js/external/noty/noty.css",
"js/external/noty/themes/relax.css"
]
},
{
"matches": ["https://mint.intuit.com/*"],
Expand Down
3 changes: 2 additions & 1 deletion src/background/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ const eventHandlers = {
// This event is emitted by the Mint property update content script.
"mint-sync-complete": ({ sender }: eventHandler) => {
debug.log("mint-sync-complete event");
chrome.storage.sync.set({ syncTime: new Date().toString() });
chrome.storage.sync.set({ syncTime: new Date().toISOString() });
chrome.tabs.sendMessage(mintTab, {
status: "Sync Complete! Reload to see the change.",
link: "/overview.event",
Expand Down Expand Up @@ -195,6 +195,7 @@ const eventHandlers = {
const currentTime = new Date();
const differenceMilliseconds = currentTime.valueOf() - syncTimeParsed.valueOf();
const differenceHours = Math.floor((differenceMilliseconds % 86400000) / 3600000);
debug.log(syncTime, syncTimeParsed, currentTime, differenceHours);
if (differenceHours >= 1) {
eventHandlers["trigger-sync"]();
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/content/mint/properties/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ chrome.runtime.onMessage.addListener((request) => {
};

if (request.uninvested_cash) {
cash = parseFloat(request.uninvested_cash);
cash = parseFloat(request.uninvested_cash) - parseFloat(request.cash_available_from_instant_deposits);
}
setRobinhoodAmount("Cash", cash);

Expand Down
29 changes: 18 additions & 11 deletions src/content/robinhood/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface Message {
error?: Error;
newProperties?: string;
property?: string;
cash_available_from_instant_deposits?: string;
}

/**
Expand All @@ -67,20 +68,26 @@ const scrapeData = async () => {

returnValue.debug = json;

if (json && json.uninvested_cash && json.uninvested_cash.amount) {
returnValue.uninvested_cash = json.uninvested_cash.amount;
}
if (json) {
if (json.uninvested_cash && json.uninvested_cash.amount) {
returnValue.uninvested_cash = json.uninvested_cash.amount;
}

if (json && json.crypto && json.crypto.equity && json.crypto.equity.amount) {
returnValue.crypto = json.crypto.equity.amount;
}
if (json.crypto && json.crypto.equity && json.crypto.equity.amount) {
returnValue.crypto = json.crypto.equity.amount;
}

if (json && json.equities && json.equities.equity && json.equities.equity.amount) {
returnValue.equities = json.equities.equity.amount;
}
if (json.equities && json.equities.equity && json.equities.equity.amount) {
returnValue.equities = json.equities.equity.amount;
}

if (json.total_equity && json.total_equity.amount) {
returnValue.total_equity = json.total_equity.amount;
}

if (json && json.total_equity && json.total_equity.amount) {
returnValue.total_equity = json.total_equity.amount;
if (json.cash_available_from_instant_deposits && json.cash_available_from_instant_deposits.amount) {
returnValue.cash_available_from_instant_deposits = json.cash_available_from_instant_deposits.amount;
}
}

return returnValue;
Expand Down

0 comments on commit abc5cac

Please sign in to comment.