implement transaction.go:Transaction:isRefund

This commit is contained in:
bel
2023-10-15 12:01:18 -06:00
parent 98b1ddcbaf
commit 8a469d4735

View File

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