fixed ittt

main
Bel LaPointe 2023-10-24 12:43:04 -06:00
parent aed990fa2c
commit 26b8174fb3
1 changed files with 18 additions and 1 deletions

View File

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