ledger.Delta.Payee = true
parent
1d18cb50c5
commit
59205fba4c
|
|
@ -16,9 +16,10 @@ type Delta struct {
|
|||
Description string
|
||||
isSet bool
|
||||
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{
|
||||
Date: d,
|
||||
Name: name,
|
||||
|
|
@ -27,11 +28,12 @@ func newDelta(transaction string, d, desc, name string, v float64, c string, isS
|
|||
Description: desc,
|
||||
isSet: isSet,
|
||||
Transaction: transaction,
|
||||
Payee: payee,
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
return ""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@ import (
|
|||
|
||||
func TestDelta(t *testing.T) {
|
||||
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" {
|
||||
t.Error(delta.Transaction)
|
||||
}
|
||||
if !delta.Payee {
|
||||
t.Error(delta.Payee)
|
||||
}
|
||||
if delta.Date != d {
|
||||
t.Error(delta.Date)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,9 +144,10 @@ func TestFileAmend(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
} else if filtered := deltas.Like(func(d Delta) bool {
|
||||
c.old.Transaction = d.Transaction
|
||||
c.old.Payee = d.Payee
|
||||
return d == c.old
|
||||
}); 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 {
|
||||
|
|
@ -371,6 +372,7 @@ func TestFileDeltas(t *testing.T) {
|
|||
Value: -97.92,
|
||||
Currency: USD,
|
||||
Description: "Electricity / Power Bill TG2PJ-2PLP5",
|
||||
Payee: true,
|
||||
},
|
||||
{
|
||||
Date: "2022-12-12",
|
||||
|
|
@ -385,6 +387,7 @@ func TestFileDeltas(t *testing.T) {
|
|||
Value: -1.00,
|
||||
Currency: USD,
|
||||
Description: "Test pay chase TG32S-BT2FF",
|
||||
Payee: true,
|
||||
},
|
||||
{
|
||||
Date: "2022-12-12",
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ func (t transaction) deltas() Deltas {
|
|||
sums[recipient.currency] += recipient.value
|
||||
result = append(result, newDelta(
|
||||
t.name,
|
||||
true,
|
||||
t.date,
|
||||
t.description,
|
||||
recipient.name,
|
||||
|
|
@ -111,6 +112,7 @@ func (t transaction) deltas() Deltas {
|
|||
} else {
|
||||
result = append(result, newDelta(
|
||||
t.name,
|
||||
false,
|
||||
t.date,
|
||||
t.description,
|
||||
t.payee,
|
||||
|
|
|
|||
Loading…
Reference in New Issue