implement transaction.go:Transaction:String with Amount:FormatUSD
parent
56b7ed0fc8
commit
58405fcdd8
|
|
@ -3,6 +3,7 @@ package analyzer
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -23,8 +24,23 @@ type Transaction struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (trn Transaction) String() string {
|
func (trn Transaction) String() string {
|
||||||
// TODO: Not implemented.
|
if trn.Amount < 0 {
|
||||||
return ""
|
return trn.stringifyRefund()
|
||||||
|
}
|
||||||
|
return trn.stringifyExpense()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (trn Transaction) stringifyRefund() string {
|
||||||
|
amount := trn.Amount * -1.0
|
||||||
|
return fmt.Sprintf("%s refunded %s %s", trn.Vendor, trn.stringifyCardholder(), amount.FormatUSD())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (trn Transaction) stringifyExpense() string {
|
||||||
|
return fmt.Sprintf("%s spent %s at %s", trn.stringifyCardholder(), trn.Amount.FormatUSD(), trn.Vendor)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (trn Transaction) stringifyCardholder() string {
|
||||||
|
return fmt.Sprintf("%s. %s", trn.CardholderFirstInitial, trn.CardholderLastName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transactions represents a list of Transaction
|
// Transactions represents a list of Transaction
|
||||||
|
|
|
||||||
60
todo.yaml
60
todo.yaml
|
|
@ -2,12 +2,6 @@ todo:
|
||||||
- review readme tail to finish // answer 3 questions, gofmt
|
- review readme tail to finish // answer 3 questions, gofmt
|
||||||
- todo: go test
|
- todo: go test
|
||||||
subtasks:
|
subtasks:
|
||||||
- my `go mod tidy` actually cleared `go.mod` file, probably weird localhost backwards
|
|
||||||
compatilble stuff
|
|
||||||
- TestTransaction_String
|
|
||||||
- TestTransaction_String/MCCOLLOMS_INC
|
|
||||||
- TestTransaction_String/QUANTUM_ELECTRIC_INC
|
|
||||||
- TestTransaction_String/MARRIOTT_33716_NEW_ORLEAN
|
|
||||||
- TestAnalyzer_TransctionsSum
|
- TestAnalyzer_TransctionsSum
|
||||||
- TestAnalyzer_LargestTransaction
|
- TestAnalyzer_LargestTransaction
|
||||||
- TestAnalyzer_DuplicatesExcluded
|
- TestAnalyzer_DuplicatesExcluded
|
||||||
|
|
@ -17,6 +11,10 @@ todo:
|
||||||
- TestAnalyzer_TransactionsFromURLsConcurrent
|
- TestAnalyzer_TransactionsFromURLsConcurrent
|
||||||
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
||||||
tho...
|
tho...
|
||||||
|
- my `go mod tidy` actually cleared `go.mod` file, probably weird localhost backwards
|
||||||
|
compatilble stuff
|
||||||
|
- transaction.go:Transaction:String not clear if FormatUSD or amount currency should
|
||||||
|
not be changed, or even what currency Amount is
|
||||||
scheduled: []
|
scheduled: []
|
||||||
done:
|
done:
|
||||||
- todo: hello world
|
- todo: hello world
|
||||||
|
|
@ -368,3 +366,53 @@ done:
|
||||||
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
||||||
tho...
|
tho...
|
||||||
ts: Sun Oct 15 11:19:11 MDT 2023
|
ts: Sun Oct 15 11:19:11 MDT 2023
|
||||||
|
- todo: go test
|
||||||
|
subtasks:
|
||||||
|
- my `go mod tidy` actually cleared `go.mod` file, probably weird localhost backwards
|
||||||
|
compatilble stuff
|
||||||
|
- TestTransaction_String
|
||||||
|
- TestTransaction_String/MCCOLLOMS_INC
|
||||||
|
- TestTransaction_String/QUANTUM_ELECTRIC_INC
|
||||||
|
- TestTransaction_String/MARRIOTT_33716_NEW_ORLEAN
|
||||||
|
- TestAnalyzer_TransctionsSum
|
||||||
|
- TestAnalyzer_LargestTransaction
|
||||||
|
- TestAnalyzer_DuplicatesExcluded
|
||||||
|
- TestAnalyzer_GroupByCategory
|
||||||
|
- TestAnalyzer_BigSpendersReport
|
||||||
|
- TestAnalyzer_TransactionsFromURLs
|
||||||
|
- TestAnalyzer_TransactionsFromURLsConcurrent
|
||||||
|
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
||||||
|
tho...
|
||||||
|
ts: Sun Oct 15 11:19:20 MDT 2023
|
||||||
|
- todo: go test
|
||||||
|
subtasks:
|
||||||
|
- TestTransaction_String
|
||||||
|
- TestTransaction_String/MCCOLLOMS_INC
|
||||||
|
- TestTransaction_String/QUANTUM_ELECTRIC_INC
|
||||||
|
- TestTransaction_String/MARRIOTT_33716_NEW_ORLEAN
|
||||||
|
- TestAnalyzer_TransctionsSum
|
||||||
|
- TestAnalyzer_LargestTransaction
|
||||||
|
- TestAnalyzer_DuplicatesExcluded
|
||||||
|
- TestAnalyzer_GroupByCategory
|
||||||
|
- TestAnalyzer_BigSpendersReport
|
||||||
|
- TestAnalyzer_TransactionsFromURLs
|
||||||
|
- TestAnalyzer_TransactionsFromURLsConcurrent
|
||||||
|
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
||||||
|
tho...
|
||||||
|
- my `go mod tidy` actually cleared `go.mod` file, probably weird localhost backwards
|
||||||
|
compatilble stuff
|
||||||
|
ts: Sun Oct 15 11:24:28 MDT 2023
|
||||||
|
- todo: go test
|
||||||
|
subtasks:
|
||||||
|
- TestAnalyzer_TransctionsSum
|
||||||
|
- TestAnalyzer_LargestTransaction
|
||||||
|
- TestAnalyzer_DuplicatesExcluded
|
||||||
|
- TestAnalyzer_GroupByCategory
|
||||||
|
- TestAnalyzer_BigSpendersReport
|
||||||
|
- TestAnalyzer_TransactionsFromURLs
|
||||||
|
- TestAnalyzer_TransactionsFromURLsConcurrent
|
||||||
|
- amount.go:Rounded probably does NOT handle float precision well... it is float64
|
||||||
|
tho...
|
||||||
|
- my `go mod tidy` actually cleared `go.mod` file, probably weird localhost backwards
|
||||||
|
compatilble stuff
|
||||||
|
ts: Sun Oct 15 11:24:56 MDT 2023
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue