diff --git a/ofx.go b/ofx.go index e06e657..59f1ee6 100644 --- a/ofx.go +++ b/ofx.go @@ -44,8 +44,7 @@ func (i *OFXImport) AddTransaction(tran *ofxgo.Transaction, account *Account) er var t Transaction t.Date = tran.DtPosted.UTC() - t.RemoteId = tran.FiTID.String() - // TODO CorrectFiTID/CorrectAction? + // Construct the description from whichever of the descriptive OFX fields are present if len(tran.Name) > 0 { t.Description = string(tran.Name) @@ -80,6 +79,10 @@ func (i *OFXImport) AddTransaction(tran *ofxgo.Transaction, account *Account) er if account.SecurityId < 1 || account.SecurityId > int64(len(i.Securities)) { return errors.New("Internal error: security index not found in OFX import\n") } + + s1.RemoteId = tran.FiTID.String() + // TODO CorrectFiTID/CorrectAction? + security := i.Securities[account.SecurityId-1] s1.Amount = amt.FloatString(security.Precision) s2.Amount = amt.Neg(amt).FloatString(security.Precision) diff --git a/transactions.go b/transactions.go index c7e68f8..af4a19b 100644 --- a/transactions.go +++ b/transactions.go @@ -34,9 +34,10 @@ type Split struct { AccountId int64 SecurityId int64 - Number string // Check or reference number - Memo string - Amount string // String representation of decimal, suitable for passing to big.Rat.SetString() + RemoteId string // unique ID from server, for detecting duplicates + Number string // Check or reference number + Memo string + Amount string // String representation of decimal, suitable for passing to big.Rat.SetString() } func GetBigAmount(amt string) (*big.Rat, error) { @@ -63,7 +64,6 @@ func (s *Split) Valid() bool { type Transaction struct { TransactionId int64 UserId int64 - RemoteId string // unique ID from server, for detecting duplicates Description string Date time.Time Splits []*Split `db:"-"`