ledger.Delta.Payee = true
parent
1d18cb50c5
commit
59205fba4c
|
|
@ -16,9 +16,10 @@ type Delta struct {
|
||||||
Description string
|
Description string
|
||||||
isSet bool
|
isSet bool
|
||||||
Transaction string
|
Transaction string
|
||||||
|
Payee bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDelta(transaction string, d, desc, name string, v float64, c string, isSet bool) Delta {
|
func newDelta(transaction string, payee bool, d, desc, name string, v float64, c string, isSet bool) Delta {
|
||||||
return Delta{
|
return Delta{
|
||||||
Date: d,
|
Date: d,
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
@ -27,11 +28,12 @@ func newDelta(transaction string, d, desc, name string, v float64, c string, isS
|
||||||
Description: desc,
|
Description: desc,
|
||||||
isSet: isSet,
|
isSet: isSet,
|
||||||
Transaction: transaction,
|
Transaction: transaction,
|
||||||
|
Payee: payee,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (delta Delta) Debug() string {
|
func (delta Delta) Debug() string {
|
||||||
return fmt.Sprintf("{@%s %s:\"%s\" %s%.2f %s}", delta.Date, delta.Name, delta.Description, func() string {
|
return fmt.Sprintf("{@%s %s(payee=%v):\"%s\" %s%.2f %s}", delta.Date, delta.Name, delta.Payee, delta.Description, func() string {
|
||||||
if !delta.isSet {
|
if !delta.isSet {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,14 @@ import (
|
||||||
|
|
||||||
func TestDelta(t *testing.T) {
|
func TestDelta(t *testing.T) {
|
||||||
d := "2099-08-07"
|
d := "2099-08-07"
|
||||||
delta := newDelta("x", d, "", "name", 34.56, "$", false)
|
delta := newDelta("x", true, d, "", "name", 34.56, "$", false)
|
||||||
|
|
||||||
if delta.Transaction != "x" {
|
if delta.Transaction != "x" {
|
||||||
t.Error(delta.Transaction)
|
t.Error(delta.Transaction)
|
||||||
}
|
}
|
||||||
|
if !delta.Payee {
|
||||||
|
t.Error(delta.Payee)
|
||||||
|
}
|
||||||
if delta.Date != d {
|
if delta.Date != d {
|
||||||
t.Error(delta.Date)
|
t.Error(delta.Date)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,9 +144,10 @@ func TestFileAmend(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else if filtered := deltas.Like(func(d Delta) bool {
|
} else if filtered := deltas.Like(func(d Delta) bool {
|
||||||
c.old.Transaction = d.Transaction
|
c.old.Transaction = d.Transaction
|
||||||
|
c.old.Payee = d.Payee
|
||||||
return d == c.old
|
return d == c.old
|
||||||
}); len(filtered) != 1 {
|
}); len(filtered) != 1 {
|
||||||
t.Fatalf("input %s didnt include old %+v in %+v", c.from, c.old, deltas)
|
t.Fatalf("input \n\t%s \ndidnt include old \n\t%+v \nin \n\t%+v: \n\t%+v", c.from, c.old, deltas, filtered)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := files.Amend(c.old, c.now); err != nil {
|
if err := files.Amend(c.old, c.now); err != nil {
|
||||||
|
|
@ -371,6 +372,7 @@ func TestFileDeltas(t *testing.T) {
|
||||||
Value: -97.92,
|
Value: -97.92,
|
||||||
Currency: USD,
|
Currency: USD,
|
||||||
Description: "Electricity / Power Bill TG2PJ-2PLP5",
|
Description: "Electricity / Power Bill TG2PJ-2PLP5",
|
||||||
|
Payee: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Date: "2022-12-12",
|
Date: "2022-12-12",
|
||||||
|
|
@ -385,6 +387,7 @@ func TestFileDeltas(t *testing.T) {
|
||||||
Value: -1.00,
|
Value: -1.00,
|
||||||
Currency: USD,
|
Currency: USD,
|
||||||
Description: "Test pay chase TG32S-BT2FF",
|
Description: "Test pay chase TG32S-BT2FF",
|
||||||
|
Payee: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Date: "2022-12-12",
|
Date: "2022-12-12",
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,7 @@ func (t transaction) deltas() Deltas {
|
||||||
sums[recipient.currency] += recipient.value
|
sums[recipient.currency] += recipient.value
|
||||||
result = append(result, newDelta(
|
result = append(result, newDelta(
|
||||||
t.name,
|
t.name,
|
||||||
|
true,
|
||||||
t.date,
|
t.date,
|
||||||
t.description,
|
t.description,
|
||||||
recipient.name,
|
recipient.name,
|
||||||
|
|
@ -111,6 +112,7 @@ func (t transaction) deltas() Deltas {
|
||||||
} else {
|
} else {
|
||||||
result = append(result, newDelta(
|
result = append(result, newDelta(
|
||||||
t.name,
|
t.name,
|
||||||
|
false,
|
||||||
t.date,
|
t.date,
|
||||||
t.description,
|
t.description,
|
||||||
t.payee,
|
t.payee,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue