deltas try to remember filename, lineno
This commit is contained in:
@@ -110,6 +110,9 @@ type transaction struct {
|
||||
payee string
|
||||
recipients []transactionRecipient
|
||||
name string
|
||||
|
||||
fileName string
|
||||
lineNo int
|
||||
}
|
||||
|
||||
func (t transaction) empty() bool {
|
||||
@@ -126,7 +129,7 @@ type transactionRecipient struct {
|
||||
func (t transaction) deltas() Deltas {
|
||||
result := []Delta{}
|
||||
sums := map[string]float64{}
|
||||
for _, recipient := range t.recipients {
|
||||
for i, recipient := range t.recipients {
|
||||
sums[recipient.currency] += recipient.value
|
||||
result = append(result, newDelta(
|
||||
t.name,
|
||||
@@ -137,6 +140,8 @@ func (t transaction) deltas() Deltas {
|
||||
recipient.value,
|
||||
recipient.currency,
|
||||
recipient.isSet,
|
||||
t.fileName,
|
||||
t.lineNo+i,
|
||||
))
|
||||
}
|
||||
for currency, value := range sums {
|
||||
@@ -155,6 +160,8 @@ func (t transaction) deltas() Deltas {
|
||||
-1.0*value,
|
||||
currency,
|
||||
false,
|
||||
t.fileName,
|
||||
t.lineNo,
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -194,6 +201,8 @@ func (files Files) _transactions(file string) ([]transaction, error) {
|
||||
name := fmt.Sprintf("%s/%d", file, len(result))
|
||||
one, err := readTransaction(name, r)
|
||||
if !one.empty() {
|
||||
one.fileName = file
|
||||
one.lineNo = len(result)
|
||||
result = append(result, one)
|
||||
}
|
||||
if err == io.EOF {
|
||||
|
||||
Reference in New Issue
Block a user