Skip to content

Commit

Permalink
Handle unspecified start date
Browse files Browse the repository at this point in the history
  • Loading branch information
stonish authored and --global committed Jun 8, 2022
1 parent 6467221 commit 4a0e91f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ Formatted data output includes these supplied classifications by default.
Any transactions which cannot be automatically classified based on the classifications.json file will be classified as "UNKNOWN"
Foratted data can be used elsewhere to understand spending types and remaining budget per classification.`,
Run: func(cmd *cobra.Command, args []string) {
startDate, err := time.Parse("20060102", start)
if err != nil {
log.Fatal("Could not parse start date: ", err)
}
startDate = startDate.Add(time.Hour * -24)
startDate := getStartDate(start)
transactions.Process(revolutFile, aibFile, startDate)
},
}
Expand All @@ -56,3 +52,15 @@ func init() {
processCmd.Flags().StringVarP(&aibFile, "aibFile", "a", "", "The path to the exported AIB statement file")
processCmd.Flags().StringVarP(&start, "startDate", "s", "", "The earliest date to be processed (format yyyymmdd)")
}

func getStartDate(start string) time.Time {
if start != "" {
startDate, err := time.Parse("20060102", start)
if err != nil {
log.Fatal("Could not parse start date: ", err)
}
return startDate.Add(time.Hour * -24)
}

return time.Unix(0, 0)
}

0 comments on commit 4a0e91f

Please sign in to comment.