1
0
mirror of https://github.com/aclindsa/moneygo.git synced 2025-07-01 12:08:37 -04:00

Move 'status' from transactions to splits

This allows for a transaction to clear one account before the other (and
mirrors how Gnucash, and I suspect most other pieces of software, do it)
This commit is contained in:
2017-05-31 08:23:19 -04:00
parent 11c7f199c4
commit b37a20536f
6 changed files with 86 additions and 69 deletions

View File

@ -92,6 +92,7 @@ type GnucashTransaction struct {
type GnucashSplit struct {
SplitId string `xml:"http://www.gnucash.org/XML/split id"`
Status string `xml:"http://www.gnucash.org/XML/split reconciled-state"`
AccountId string `xml:"http://www.gnucash.org/XML/split account"`
Memo string `xml:"http://www.gnucash.org/XML/split memo"`
Amount string `xml:"http://www.gnucash.org/XML/split quantity"`
@ -211,11 +212,20 @@ func ImportGnucash(r io.Reader) (*GnucashImport, error) {
t := new(Transaction)
t.Description = gt.Description
t.Date = gt.DatePosted.Date.Time
t.Status = Imported
for j := range gt.Splits {
gs := gt.Splits[j]
s := new(Split)
s.Memo = gs.Memo
switch gs.Status {
default: // 'n', or not present
s.Status = Imported
case "c":
s.Status = Cleared
case "y":
s.Status = Reconciled
}
account, ok := accountMap[gs.AccountId]
if !ok {
return nil, fmt.Errorf("Unable to find account: %s", gs.AccountId)