Skip to content

Commit

Permalink
change debt2limit ratio warning to 25, add val with Issues data
Browse files Browse the repository at this point in the history
  • Loading branch information
weallwegot committed Aug 15, 2019
1 parent 4d79076 commit 253353a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lambdas/compute-forecast/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
OVERDRAFT = "CHECKING ACCOUNT OVERDRAFT"
OVERCREDIT = "BALANCE HIGHER THAN CREDIT LIMIT"

ISSUE_NOTES = {DEBT_RATIO: "FICO recommends keeping a debt to limit ratio of under 30%",
ISSUE_NOTES = {DEBT_RATIO: "FICO recommends keeping a debt to limit ratio of under 25%",
OVERDRAFT: "Spent more money than you have in this checking account",
OVERCREDIT: "Credit card balance exceeds your limit."}

Expand Down
14 changes: 9 additions & 5 deletions lambdas/compute-forecast/fihnance/account.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from datetime import datetime
import logging

from definitions import Q_, CHECKING, CREDIT, VALID_ACCT_TYPES
from definitions import Q_, CHECKING, CREDIT, VALID_ACCT_TYPES, DEBT_RATIO, OVERCREDIT, OVERDRAFT
from fihnance.transaction import Transaction
# from numpy import float64
from typing import Union, Optional
Expand Down Expand Up @@ -66,16 +66,20 @@ def process_tx(self, amount_extractable_obj: Union[AccountInterface, Transaction
self.balance += amount
if self.acct_type == CREDIT:
bal_credit_ratio = round(abs(self.balance / self.credit_limit) * 100., 1)
if bal_credit_ratio > 20:
if bal_credit_ratio > 25:
logger.info(f"{self.name}\nbe careful, you're debt/limit ratio is {bal_credit_ratio}%\n\
anything over 20% may hurt your credit score.")
issue = {"ISSUE": "DEBT/LIMIT RATIO", "DATE": simulated_day}
anything over 25% may hurt your credit score.")
issue = {"ISSUE": DEBT_RATIO, "DATE": simulated_day, "VALUE": bal_credit_ratio}
self.issues.append(issue)
if abs(self.balance) > self.credit_limit:
logger.info(f"You've spent more than your credit limit for {self.name}")
issue = {"ISSUE": OVERCREDIT, "DATE": simulated_day, "VALUE": self.balance}
self.issues.append(issue)

elif self.acct_type == CHECKING:
if self.balance < Q_(0, 'usd'):
logger.info(f"{self} has just overdrafted.")
issue = {"ISSUE": "OVERDRAFT": "DATE": simulated_day}
issue = {"ISSUE": OVERDRAFT: "DATE": simulated_day, "VALUE": self.balance}
self.issues.append(issue)

# check if balance is an attribute, and update it
Expand Down
8 changes: 5 additions & 3 deletions lambdas/compute-forecast/lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from collections import OrderedDict
from typing import List, Tuple

from definitions import ROOT_DIR, Q_, CHECKING, CREDIT, FOREVER_RECURRING
from definitions import ROOT_DIR, Q_, CHECKING, CREDIT, FOREVER_RECURRING, ISSUE_NOTES

from fihnance.account import Account
from fihnance.transaction import Transaction
Expand Down Expand Up @@ -63,8 +63,10 @@ def place_money_warning_data(userid: str, account_objects: List[Account]) -> Non
dict2write = {}
dict2write["date"] = issue["DATE"].strftime()
dict2write["account"] = account.name
dict2write["issue"] = issue["ISSUE"]
dict2write["notes"] = ""

issue_key = issue["ISSUE"]
dict2write["issue"] = issue_key
dict2write["notes"] = ISSUE_NOTES[issue_key]

writer.writerow(entry)

Expand Down

0 comments on commit 253353a

Please sign in to comment.