mirror of
https://github.com/aclindsa/ofxgo.git
synced 2025-07-01 11:48:38 -04:00
Bank Transactions: Use Currency structs, not CurrSymbol directly
This commit is contained in:
10
common.go
10
common.go
@ -316,3 +316,13 @@ type Currency struct {
|
||||
CurRate Amount `xml:"CURRATE"` // Ratio of <CURDEF> currency to <CURSYM> currency
|
||||
CurSym CurrSymbol `xml:"CURSYM"` // ISO-4217 3-character currency identifier
|
||||
}
|
||||
|
||||
// Valid returns whether the Currency is valid according to the OFX spec
|
||||
func (c Currency) Valid() (bool, error) {
|
||||
if c.CurRate.IsInt() && c.CurRate.Num().Int64() == 0 {
|
||||
return false, errors.New("CurRate may not be zero")
|
||||
} else if ok, err := c.CurSym.Valid(); !ok {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user