mirror of
https://github.com/aclindsa/ofxgo.git
synced 2024-11-21 19:20:05 -05:00
Bank transactions: Allow transaction currencies to be empty
The XML marahaller will attempt to marshal the top-level elements, not knowing that the lower-level elements are empty. Making them pointers solves this.
This commit is contained in:
parent
3e8a9c5a53
commit
423d460747
13
bank.go
13
bank.go
@ -126,8 +126,8 @@ type Transaction struct {
|
|||||||
ImageData []ImageData `xml:"IMAGEDATA,omitempty"`
|
ImageData []ImageData `xml:"IMAGEDATA,omitempty"`
|
||||||
|
|
||||||
// Only one of Currency and OrigCurrency can ever be Valid() for the same transaction
|
// Only one of Currency and OrigCurrency can ever be Valid() for the same transaction
|
||||||
Currency Currency `xml:"CURRENCY,omitempty"` // Represents the currency of TrnAmt (instead of CURDEF in STMTRS) if Valid
|
Currency *Currency `xml:"CURRENCY,omitempty"` // Represents the currency of TrnAmt (instead of CURDEF in STMTRS) if Valid
|
||||||
OrigCurrency Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency TrnAmt was converted to STMTRS' CURDEF from if Valid
|
OrigCurrency *Currency `xml:"ORIGCURRENCY,omitempty"` // Represents the currency TrnAmt was converted to STMTRS' CURDEF from if Valid
|
||||||
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST (Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST.)
|
Inv401kSource inv401kSource `xml:"INV401KSOURCE,omitempty"` // One of PRETAX, AFTERTAX, MATCH, PROFITSHARING, ROLLOVER, OTHERVEST, OTHERNONVEST (Default if not present is OTHERNONVEST. The following cash source types are subject to vesting: MATCH, PROFITSHARING, and OTHERVEST.)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +166,13 @@ func (t Transaction) Valid(version ofxVersion) (bool, error) {
|
|||||||
} else if len(t.ImageData) > 2 {
|
} else if len(t.ImageData) > 2 {
|
||||||
return false, errors.New("Only 2 of ImageData allowed in Transaction")
|
return false, errors.New("Only 2 of ImageData allowed in Transaction")
|
||||||
}
|
}
|
||||||
ok1, _ := t.Currency.Valid()
|
var ok1, ok2 bool
|
||||||
ok2, _ := t.OrigCurrency.Valid()
|
if t.Currency != nil {
|
||||||
|
ok1, _ = t.Currency.Valid()
|
||||||
|
}
|
||||||
|
if t.OrigCurrency != nil {
|
||||||
|
ok2, _ = t.OrigCurrency.Valid()
|
||||||
|
}
|
||||||
if ok1 && ok2 {
|
if ok1 && ok2 {
|
||||||
return false, errors.New("Currency and OrigCurrency both supplied for Pending Transaction, only one allowed")
|
return false, errors.New("Currency and OrigCurrency both supplied for Pending Transaction, only one allowed")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user