fixed ittt
parent
aed990fa2c
commit
26b8174fb3
|
|
@ -57,6 +57,23 @@ func (file File) transactions() ([]transaction, error) {
|
|||
}
|
||||
|
||||
func readTransaction(r *bufio.Reader) (transaction, error) {
|
||||
result, err := _readTransaction(r)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
if result.empty() {
|
||||
return result, nil
|
||||
}
|
||||
if result.payee == "" && len(result.recipients) < 2 {
|
||||
return result, fmt.Errorf("found a transaction with no payee and less than 2 recipeints: %+v", result)
|
||||
}
|
||||
if result.payee != "" && len(result.recipients) < 1 {
|
||||
return result, fmt.Errorf("found a transaction with payee but no recipeints: %+v", result)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func _readTransaction(r *bufio.Reader) (transaction, error) {
|
||||
readTransactionLeadingWhitespace(r)
|
||||
|
||||
firstLine, err := readTransactionLine(r)
|
||||
|
|
@ -155,7 +172,7 @@ func readTransactionAccount(r *bufio.Reader) (string, float64, string, error) {
|
|||
|
||||
if len(line) > 0 && !unicode.IsSpace(rune(line[0])) {
|
||||
r2 := *r
|
||||
*r = *bufio.NewReader(io.MultiReader(bytes.NewReader(line), &r2))
|
||||
*r = *bufio.NewReader(io.MultiReader(bytes.NewReader(append(line, '\n')), &r2))
|
||||
return "", 0, "", nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue