Skip to content

Commit

Permalink
Update report to receive flag for source type
Browse files Browse the repository at this point in the history
Report previously tried to determine the type of input data from the data itself. However, before the report is generated, we already know the source type from the command line arguments. Report now gets passed a flag to specify the type of source data
  • Loading branch information
stonish committed Oct 13, 2021
1 parent 7b9942e commit 816f9cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions transactions/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func Process(revolutFile string, aibFile string, startDate time.Time) {
revolutLines := utils.ReadInputFile(revolutFile)
aibLines := utils.ReadInputFile(aibFile)

report = report.AddTransactions(revolutLines)
report = report.AddTransactions(aibLines)
report = report.AddTransactions(revolutLines, true)
report = report.AddTransactions(aibLines, false)

report.Sort()
report.Output()
Expand Down
4 changes: 1 addition & 3 deletions transactions/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package transactions
import (
"fmt"
"time"
"strings"
"sort"
)

Expand All @@ -20,8 +19,7 @@ func NewReport(startDate time.Time) *report {
return r
}

func (r report) AddTransactions(rawData[]string) *report {
isRevolut := strings.HasPrefix(rawData[0], "Completed Date")
func (r report) AddTransactions(rawData[]string, isRevolut bool) *report {
if isRevolut {
for i := len(rawData) - 1; i > 0; i-- {
transaction := NewRevolutTransaction(rawData[i])
Expand Down

0 comments on commit 816f9cd

Please sign in to comment.