1
0
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:
2017-04-18 20:17:44 -04:00
parent a3e42fc903
commit 8712be5a9d
4 changed files with 18 additions and 8 deletions

View File

@ -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
}