ledger.Delta.OtherDates
This commit is contained in:
@@ -106,6 +106,7 @@ func (transaction Transaction) Payee() string {
|
||||
|
||||
type transaction struct {
|
||||
date string
|
||||
otherDates []string
|
||||
description string
|
||||
payee string
|
||||
recipients []transactionRecipient
|
||||
@@ -142,6 +143,7 @@ func (t transaction) deltas() Deltas {
|
||||
recipient.isSet,
|
||||
t.fileName,
|
||||
t.lineNo+i,
|
||||
t.otherDates,
|
||||
))
|
||||
}
|
||||
for currency, value := range sums {
|
||||
@@ -162,6 +164,7 @@ func (t transaction) deltas() Deltas {
|
||||
false,
|
||||
t.fileName,
|
||||
t.lineNo,
|
||||
t.otherDates,
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -287,16 +290,17 @@ func _readTransaction(name string, r *bufio.Reader) (transaction, error) {
|
||||
return transaction{}, err
|
||||
}
|
||||
|
||||
dateDescriptionPattern := regexp.MustCompile(`^([0-9]+-[0-9]+-[0-9]+)\s+(.*)$`)
|
||||
dateDescriptionMatches := dateDescriptionPattern.FindAllSubmatch(firstLine, 4)
|
||||
dateDescriptionPattern := regexp.MustCompile(`^([0-9]+-[0-9]+-[0-9]+)((=[0-9]+-[0-9]+-[0-9]+)*)\s+(.*)$`)
|
||||
dateDescriptionMatches := dateDescriptionPattern.FindAllStringSubmatch(string(firstLine), 4)
|
||||
if len(dateDescriptionMatches) != 1 {
|
||||
return transaction{}, fmt.Errorf("bad first line: %v matches: %q", len(dateDescriptionMatches), firstLine)
|
||||
} else if len(dateDescriptionMatches[0]) != 3 {
|
||||
} else if len(dateDescriptionMatches[0]) != 5 {
|
||||
return transaction{}, fmt.Errorf("bad first line: %v submatches: %q", len(dateDescriptionMatches[0]), firstLine)
|
||||
}
|
||||
result := transaction{
|
||||
date: string(dateDescriptionMatches[0][1]),
|
||||
description: string(dateDescriptionMatches[0][2]),
|
||||
date: dateDescriptionMatches[0][1],
|
||||
otherDates: strings.Split(strings.Trim(dateDescriptionMatches[0][2], "="), "="),
|
||||
description: dateDescriptionMatches[0][4],
|
||||
name: name,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user