Skip to content

Swf 17 credit health #17

Merged
merged 26 commits into from May 1, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38a78cf
radial progress indicators and page-based nav
ahm11003 Feb 13, 2019
5d7cb80
Added Balance, Utilization, and AccountNumber Controllers. Added PLis…
Mar 6, 2019
10e6442
PList Functions
ahm11003 Mar 6, 2019
c212e13
Merge pull request #5 from rrk12005/demo-radial-style-progress-indica…
jod13004 Mar 6, 2019
83e5766
Added Utilization score calculation
Mar 28, 2019
3be3eef
Renamed files to more accurately represent them. Changed wellness rad…
Mar 29, 2019
5a821f7
no message
Mar 29, 2019
a2f3c9d
Merge branch 'master' into SWF-17-credit-health
ahm11003 Apr 9, 2019
9303329
- Functions for utilization and account (temporary) metrics.
Apr 11, 2019
3599c77
SWF-17 remove storyboard segue
ahm11003 Apr 11, 2019
2c07f8e
SWF-17 pass our metrics to page hierarchy
ahm11003 Apr 11, 2019
416c2ea
SWF-17 credit utilization improvements
ahm11003 Apr 17, 2019
3e7ddcd
SWE-17 remove unused classes and files
ahm11003 Apr 17, 2019
8e8dec7
SWF-17 fix logical error leading to bad utilization score
ahm11003 Apr 17, 2019
a5c4ac1
SWF-17 remove unused class
ahm11003 Apr 17, 2019
85fd3e2
SWF-17 new class to display trends in credit utilization
ahm11003 Apr 17, 2019
4f67b56
SWF-17 new image assets, implementation for utilization trend
ahm11003 Apr 17, 2019
23fb930
SWF-17 Added basic details for utilization trends
ahm11003 Apr 17, 2019
80acdbf
Merge branch 'master' into SWF-17-credit-health
ahm11003 Apr 17, 2019
ddbc228
SWF-17 More wellness implementation
ahm11003 Apr 23, 2019
4a55d89
SWF-17 more wellness configuration
ahm11003 Apr 23, 2019
d170909
SWF-17 remove unused code
ahm11003 Apr 23, 2019
433ebac
SWF-17 More wellness implementation and improvements
ahm11003 Apr 23, 2019
17dd1df
SWF-17 metric calculations
ahm11003 Apr 23, 2019
a949599
SWF-17 clean up how we receive data for utilization
ahm11003 Apr 23, 2019
f84701b
SWF-17 new image assets, wellness calculation
ahm11003 Apr 24, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+137 −19
Diff settings

Always

Just for now

- Functions for utilization and account (temporary) metrics.

- Added identifiers for wellness score controllers
- Added "transaction_code" values to respective API call and transaction class
  • Loading branch information...
Jonathan Duarte
Jonathan Duarte committed Apr 11, 2019
commit 9303329f977423f234896e4ae5e10ef93720b823
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14490.70" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14460.31" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14490.21"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14460.16"/>
</dependencies>
<scenes>
<!--root-->
@@ -70,10 +70,10 @@
</objects>
<point key="canvasLocation" x="23" y="602"/>
</scene>
<!--Account Num Interface Controller-->
<!--AccountScore-->
<scene sceneID="jxS-9m-lB7">
<objects>
<controller id="Mki-ad-UCC" customClass="AccountNumInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="AccountScore" id="Mki-ad-UCC" customClass="AccountNumInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="left" text="Account Score" textAlignment="center" id="0ed-0W-LKq"/>
<imageView width="1" height="120" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" id="RlX-Hj-mTY"/>
@@ -309,10 +309,10 @@
</objects>
<point key="canvasLocation" x="1420" y="-229"/>
</scene>
<!--Utilization Interface Controller-->
<!--UtilizationScore-->
<scene sceneID="nMW-YM-Pwh">
<objects>
<controller id="RNe-Ul-1jm" customClass="UtilizationInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="UtilizationScore" id="RNe-Ul-1jm" customClass="UtilizationInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="left" text="Utilization Score" textAlignment="center" id="Rzj-RR-iat"/>
<imageView width="1" height="120" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" id="MkL-48-J8l"/>
@@ -325,10 +325,10 @@
</objects>
<point key="canvasLocation" x="613" y="602"/>
</scene>
<!--Consistency Interface Controller-->
<!--PaymentScore-->
<scene sceneID="do4-GS-cad">
<objects>
<controller id="k4M-kn-ZzM" customClass="ConsistencyInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="PaymentScore" id="k4M-kn-ZzM" customClass="ConsistencyInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" height="20" alignment="left" text="Payment Score" textAlignment="center" id="5cf-d7-ssN"/>
<imageView width="1" height="120" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" id="XsN-KK-JY4"/>
@@ -20,8 +20,14 @@ class AccountNumInterfaceController: WKInterfaceController {
override func awake(withContext context: Any?) {
super.awake(withContext: context)

if let val: Int = context as? Int {
score = val
}else {
score = 0
}

//Assigns score based on # of accounts
switch accNum {
/*switch accNum {
case 2...3:
score = 50
case 3...4:
@@ -30,7 +36,7 @@ class AccountNumInterfaceController: WKInterfaceController {
score = 100
default:
score = 25
}
}*/
}

override func didAppear() {
@@ -20,7 +20,7 @@ class ConsistencyInterfaceController: WKInterfaceController {
super.awake(withContext: context)

//Assigns a score based on # of late payments
switch latePayments {
/*switch latePayments {
case 1:
score = 80
case 2:
@@ -29,7 +29,7 @@ class ConsistencyInterfaceController: WKInterfaceController {
score = 25
default:
score = 100
}
}*/
}

override func didAppear() {
@@ -92,13 +92,14 @@ class FetchData {
let amountString = $0["transaction_amount"].string,
let amount = Double(amountString),
let confirmationNum = $0["payment_confirmation_number"].string,
let transactionCode = $0["transaction_code"].string,
let paymentIdString = $0["payment_id"].string,
let paymentId = Int(paymentIdString),
let modifiable = $0["is_payment_modifiable"].string {
let type: TransactionType = $0["payment_amount_type"].stringValue == "" ? .purchase : .reimbursement
let isModifiable: Bool = modifiable == "Y" ? true : false

transactions.append(Transaction(type: type, amount: amount, merchantID: desc, date: date, confirmationNum: confirmationNum, paymentId: paymentId, isPending: true, isModifiable: isModifiable))
transactions.append(Transaction(type: type, amount: amount, merchantID: desc, date: date, confirmationNum: confirmationNum, paymentId: paymentId, isPending: true, isModifiable: isModifiable, transactionCode: transactionCode))
}
}

@@ -107,9 +108,10 @@ class FetchData {
if let desc = $0["description"].string,
let date = Defaults.careCreditDateFormatter.date(from: $0["transaction_date"].stringValue),
let amountString = $0["transaction_amount"].string,
let transactionCode = $0["transaction_code"].string,
let amount = Double(amountString) {
let type: TransactionType = $0["payment_amount_type"].stringValue == "" ? .purchase : .reimbursement
transactions.append(Transaction(type: type, amount: amount, merchantID: desc, date: date, isPending: false))
transactions.append(Transaction(type: type, amount: amount, merchantID: desc, date: date, isPending: false, transactionCode: transactionCode))
}
}
completion(transactions, nil)
@@ -52,6 +52,7 @@ class MainMenuInterfaceController: WKInterfaceController {
return acctDict
} else if segueIdentifier == "toWellness" {
// we will probably want to do some setup prior to presenting Wellness
return acctDict
}

return nil
@@ -17,9 +17,11 @@ class UtilizationInterfaceController: WKInterfaceController {
@IBOutlet weak var image3: WKInterfaceImage!
override func awake(withContext context: Any?) {
super.awake(withContext: context)

score = context as? Int

// get plist data to generate utilization metric
var plistValues = PlistUtil.readPlist(for: .balance)
/*var plistValues = PlistUtil.readPlist(for: .balance)
let balance = plistValues[0][0]
let credit = plistValues[0][1] > 0 ? plistValues[0][1] : 1
util = round((Double(balance)/Double(credit)) * 100)
@@ -37,7 +39,7 @@ class UtilizationInterfaceController: WKInterfaceController {
score = Int(round((100 - util) * 0.6))
default:
score = 1
}
}*/
}

override func didAppear() {
@@ -11,13 +11,40 @@ import Foundation


class WellnessInterfaceController: WKInterfaceController {
var accounts: [Account] = []
var transactions: [Transaction] = []
var transactionDict: [String: [Transaction]] = [:]
var wellnessScore: Int?
var accountScore: Int = 0
var utilizationScore: Int = 0
var paymentScore: Int = 0

@IBOutlet weak var image: WKInterfaceImage!

override func awake(withContext context: Any?) {
super.awake(withContext: context)

if let context = context as? [String: [Account]], let accts = context["accts"] {
accounts = accts
}
/*for index in 0..<accounts.count{
FetchData.fetchTransactionsFor(accountAlias: accounts[index].accountAlias) { transactions, error in
guard error == nil else {
NSLog("Error retrieving transactions for account.")
return
}
self.transactionDict.updateValue(self.transactions, forKey: "transactions")
}
}*/

calculateUtilization()
countAccounts()
calculateWellness()

image.setImageNamed("scores")
image.startAnimatingWithImages(in: NSRange(location: 1, length: 65), duration: 1.5, repeatCount: 1)
image.startAnimatingWithImages(in: NSRange(location: 1, length: wellnessScore ?? 0), duration: 1.5, repeatCount: 1)

self.pushController(withName: "UtilizationScore", context: utilizationScore)
}

override func willActivate() {
@@ -29,4 +56,82 @@ class WellnessInterfaceController: WKInterfaceController {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}

private func calculateUtilization() {
var totalBalance: Double = 0
var totalCredit: Double = 0

for index in 0..<accounts.count {
totalBalance += accounts[index].curBalance
totalCredit += accounts[index].creditLimit
}

let util = round(((totalBalance)/(totalCredit)) * 100)

switch util {
case 0...10:
utilizationScore = 100
case 11...20:
utilizationScore = Int(round((100 - util) * 0.9))
case 21...30:
utilizationScore = Int(round((100 - util) * 0.85))
case 31...60:
utilizationScore = Int(round((100 - util) * 0.725))
case 61...90:
utilizationScore = Int(round((100 - util) * 0.6))
default:
utilizationScore = 1
}
}

private func countAccounts() {
var count: Int = 0

for _ in 0..<accounts.count {
count += 1
}

switch count {
case 2...3:
accountScore = 50
case 3...4:
accountScore = 75
case 5...10:
accountScore = 100
default:
accountScore = 25
}
}

private func calculateWellness() {
let m1 = Double(utilizationScore) * 0.50
let m2 = Double(accountScore) * 0.20
let m3 = Double(paymentScore) * 0.30
wellnessScore = Int(round(m1 + m2 + m3))
}

/*private func calculatePaymentsMissed() {
var lateCount: Int = 0
for index in 0..<accounts.count {
if let alias = selectedAccount?.accountAlias {
FetchData.fetchTransactionsFor(accountAlias: alias) { transactions, error in
guard error == nil else {
NSLog("Error retrieving transactions for account.")
return
}
self.transactionDict.updateValue(transactions, forKey: "transactions")
self.pushController(withName: "Transactions", context: self.transactionDict)
}
}
}
}*/

override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
if segueIdentifier == "UtilizationScore" {
return utilizationScore
}
return nil
}

}
@@ -26,9 +26,10 @@ class Transaction: NSObject {
var paymentId: Int
var isPending: Bool
var isModifiable: Bool
var transactionCode: String

init(type: TransactionType, amount: Double, merchantID: String, date: Date,
confirmationNum: String? = nil, paymentId: Int? = nil, isPending: Bool? = nil, isModifiable: Bool? = nil) {
confirmationNum: String? = nil, paymentId: Int? = nil, isPending: Bool? = nil, isModifiable: Bool? = nil, transactionCode: String) {
self.type = type
self.amount = amount
self.merchantID = merchantID
@@ -37,5 +38,6 @@ class Transaction: NSObject {
self.paymentId = paymentId ?? 0
self.isPending = isPending ?? false
self.isModifiable = isModifiable ?? false
self.transactionCode = transactionCode
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.