implement transaction.go:Transaction:isRefund

main
bel 2023-10-15 12:01:18 -06:00
parent 98b1ddcbaf
commit 8a469d4735
1 changed files with 5 additions and 1 deletions

View File

@ -24,7 +24,7 @@ type Transaction struct {
} }
func (trn Transaction) String() string { func (trn Transaction) String() string {
if trn.Amount < 0 { if trn.isRefund() {
return trn.stringifyRefund() return trn.stringifyRefund()
} }
return trn.stringifyExpense() return trn.stringifyExpense()
@ -43,6 +43,10 @@ func (trn Transaction) stringifyCardholder() string {
return fmt.Sprintf("%s. %s", trn.CardholderFirstInitial, trn.CardholderLastName) return fmt.Sprintf("%s. %s", trn.CardholderFirstInitial, trn.CardholderLastName)
} }
func (trn Transaction) isRefund() bool {
return trn.Amount < 0
}
// Transactions represents a list of Transaction // Transactions represents a list of Transaction
type Transactions []Transaction type Transactions []Transaction