Handle $ and , in amount
This commit is contained in:
12
main.go
12
main.go
@@ -84,7 +84,7 @@ type Transaction struct {
|
||||
|
||||
type TransactionYaml struct {
|
||||
Name string `yaml:"name"`
|
||||
Amount float64 `yaml:"amount"`
|
||||
Amount string `yaml:"amount"`
|
||||
Date string `yaml:"date"`
|
||||
Delayable string `yaml:"delayable"`
|
||||
Frequency string `yaml:"frequency,omitempty"`
|
||||
@@ -204,8 +204,16 @@ func parseTransaction(transactionYaml TransactionYaml) (*Transaction, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
amountStr := strings.ReplaceAll(transactionYaml.Amount, "$", "")
|
||||
amountStr = strings.ReplaceAll(amountStr, ",", "")
|
||||
|
||||
amount, err := strconv.ParseFloat(amountStr, 32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
transaction := &Transaction{
|
||||
Amount: transactionYaml.Amount,
|
||||
Amount: amount,
|
||||
Date: stripTime(date),
|
||||
Delayable: delayable,
|
||||
Frequency: transactionYaml.Frequency,
|
||||
|
||||
Reference in New Issue
Block a user