Skip to content

Commit

Permalink
transactions,db: improve field names for some types
Browse files Browse the repository at this point in the history
Signed-off-by: Gunwant Jain <[email protected]>
  • Loading branch information
wantguns committed Oct 15, 2023
1 parent e634265 commit c8b92fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions api/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ type FilteredTransactions struct {
CurrentBalance float64 `json:"current_balance"`
TxnTimestamp time.Time `json:"txn_timestamp"`
Type string `json:"type"`
Receiver string `json:"reciever"`
Sender string `json:"sender"`
Account string `json:"account"`
Merchant string `json:"merchant"`
}

type TransactionsReturn struct {
Expand All @@ -105,15 +105,15 @@ func filterTransactions(raw TransactionsResponse, since time.Time) []FilteredTra
UUID: t[i].UUID,
Amount: t[i].Amount,
Type: t[i].Type,
Sender: t[i].FinancialInformationProvider.Name,
Receiver: t[i].Narration,
Merchant: t[i].FinancialInformationProvider.Name,
Account: t[i].Narration,
TxnTimestamp: t[i].TxnTimestamp,
CurrentBalance: t[i].CurrentBalance,
}

// Use Fold's F1 classifier if this transaction was classified
if t[i].Merchant != nil {
transaction.Receiver = t[i].Merchant.(string)
transaction.Account = t[i].Merchant.(string)
}

transactions = append(transactions, transaction)
Expand Down
8 changes: 4 additions & 4 deletions cmd/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ func printTransactions(t api.FilteredTransactions) {
t.TxnTimestamp,
t.Amount,
t.Type,
t.Sender,
t.Merchant,
t.CurrentBalance,
t.Receiver,
t.Account,
)
}

Expand All @@ -50,9 +50,9 @@ func writeToDb(t api.FilteredTransactions) {
Timestamp: t.TxnTimestamp,
Amount: t.Amount,
Type: t.Type,
Sender: t.Sender,
Merchant: t.Merchant,
CurrentBalance: t.CurrentBalance,
Receiver: t.Receiver,
Account: t.Account,
})
}

Expand Down
4 changes: 2 additions & 2 deletions db/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ type Transactions struct {
CurrentBalance float64
Timestamp time.Time `gorm:"index:sortTimestamp,sort:desc"`
Type string
Receiver string
Sender string
Account string
Merchant string
}

0 comments on commit c8b92fd

Please sign in to comment.