Ejemplo n.º 1
0
		mockAgg    *mockAggregator

		start time.Time
		end   time.Time

		t1 *transaction.Transaction
		t2 *transaction.Transaction

		acc1 []*transaction.Account
		acc2 []*transaction.Account

		grouping *database.Grouping
	)

	BeforeEach(func() {
		start = transaction.NewDate(2015, 10, 10)
		end = transaction.NewDate(2015, 10, 12)

		acc1 = []*transaction.Account{
			{
				Name:  "some-acc-name-1",
				Value: 1,
			},
			{
				Name:  "some-acc-name-2",
				Value: 2,
			},
		}

		acc2 = []*transaction.Account{
			{
Ejemplo n.º 2
0
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("TransactionList", func() {
	Describe("Sort Interface", func() {
		var (
			t1   *transaction.Transaction
			t2   *transaction.Transaction
			t3   *transaction.Transaction
			list transaction.TransactionList
		)

		BeforeEach(func() {
			t1 = &transaction.Transaction{
				Date: transaction.NewDate(2012, 1, 1),
			}
			t2 = &transaction.Transaction{
				Date: transaction.NewDate(2013, 1, 1),
			}
			t3 = &transaction.Transaction{
				Date: transaction.NewDate(2011, 1, 1),
			}
			list = transaction.TransactionList([]*transaction.Transaction{
				t1,
				t2,
				t3,
			})
		})

		It("is sortable", func() {
Ejemplo n.º 3
0
2015/10/12 Qdoba
		Expenses:Food:FastFood $21.50
		Liabilities:AmericanExpress $-21.50
`)
		reader = transaction.NewReader(strReader)
	})

	It("reads all the transactions", func() {
		t1, err := reader.Next()
		Expect(err).ToNot(HaveOccurred())
		t2, err := reader.Next()
		Expect(err).ToNot(HaveOccurred())

		Expect(t1).To(Equal(
			&transaction.Transaction{
				Date: transaction.NewDate(2015, 10, 12),
				Title: &transaction.Title{
					Value: "Exxon",
				},
				Accounts: &transaction.AccountList{
					Accounts: []*transaction.Account{
						{
							Name:  "Expenses:Auto:Gas",
							Value: 1000,
						},
						{
							Name:  "Liabilities:MasterCard",
							Value: -1000,
						},
					},
				},
Ejemplo n.º 4
0
var _ = Describe("Transaction", func() {
	var t *transaction.Transaction

	Describe("Parse", func() {
		BeforeEach(func() {
			t = new(transaction.Transaction)
		})

		It("parses a transaction", func() {
			line := "2015/10/12 Exxon\n\tExpenses:Auto:Gas         $10.00\n\tLiabilities:MasterCard   $-10.00"
			remaining, err := t.Parse(line)

			Expect(err).ToNot(HaveOccurred())
			Expect(remaining).To(BeZero())
			Expect(t.Date).To(Equal(transaction.NewDate(2015, 10, 12)))
			Expect(t.Title).To(Equal(&transaction.Title{
				Value: "Exxon",
			}))
			Expect(t.Accounts).To(Equal(&transaction.AccountList{
				Accounts: []*transaction.Account{
					{
						Name:  "Expenses:Auto:Gas",
						Value: 1000,
					},
					{
						Name:  "Liabilities:MasterCard",
						Value: -1000,
					},
				},
			}))