Skip to content

Commit

Permalink
Add support to the new fields for month requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno M V Souza committed Jul 31, 2018
1 parent 507bc29 commit 2f11bb4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
18 changes: 18 additions & 0 deletions api/month/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ type Month struct {
Note *string `json:"note"`
ToBeBudgeted *int64 `json:"to_be_budgeted"`
AgeOfMoney *int64 `json:"age_of_money"`

// Income the total amount in transactions categorized to "Inflow: To be Budgeted"
// in the month (milliunits format)
Income *int64 `json:"income"`
// Budgeted the total amount budgeted in the month (milliunits format)
Budgeted *int64 `json:"budgeted"`
// Activity the total amount in transactions in the month, excluding those
// categorized to "Inflow: To be Budgeted" (milliunits format)
Activity *int64 `json:"activity"`
}

// Summary represents the summary of a month for a budget
Expand All @@ -28,4 +37,13 @@ type Summary struct {
Note *string `json:"note"`
ToBeBudgeted *int64 `json:"to_be_budgeted"`
AgeOfMoney *int64 `json:"age_of_money"`

// Income the total amount in transactions categorized to "Inflow: To be Budgeted"
// in the month (milliunits format)
Income *int64 `json:"income"`
// Budgeted the total amount budgeted in the month (milliunits format)
Budgeted *int64 `json:"budgeted"`
// Activity the total amount in transactions in the month, excluding those
// categorized to "Inflow: To be Budgeted" (milliunits format)
Activity *int64 `json:"activity"`
}
22 changes: 20 additions & 2 deletions api/month/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ func TestService_GetMonths(t *testing.T) {
"month": "2017-10-01",
"note": null,
"to_be_budgeted": 0,
"age_of_money": 14
"age_of_money": 14,
"income": 3077330,
"budgeted": 3271990,
"activity": -3128590
}
]
}
Expand All @@ -45,10 +48,16 @@ func TestService_GetMonths(t *testing.T) {
var (
expectedAgeOfMoney int64 = 14
expectedToBeBudgeted int64
expectedIncome int64 = 3077330
expectedBudgeted int64 = 3271990
expectedActivity int64 = -3128590
)
assert.Equal(t, "2017-10-01 00:00:00 +0000 UTC", m.Month.String())
assert.Equal(t, &expectedToBeBudgeted, m.ToBeBudgeted)
assert.Equal(t, &expectedAgeOfMoney, m.AgeOfMoney)
assert.Equal(t, &expectedIncome, m.Income)
assert.Equal(t, &expectedBudgeted, m.Budgeted)
assert.Equal(t, &expectedActivity, m.Activity)
assert.Nil(t, m.Note)
}

Expand All @@ -65,7 +74,10 @@ func TestService_GetMonth(t *testing.T) {
"month": "2017-10-01",
"note": null,
"to_be_budgeted": 0,
"age_of_money": 14
"age_of_money": 14,
"income": 3077330,
"budgeted": 3271990,
"activity": -3128590
}
}
}
Expand All @@ -85,9 +97,15 @@ func TestService_GetMonth(t *testing.T) {
var (
expectedAgeOfMoney int64 = 14
expectedToBeBudgeted int64
expectedIncome int64 = 3077330
expectedBudgeted int64 = 3271990
expectedActivity int64 = -3128590
)
assert.Equal(t, "2017-10-01 00:00:00 +0000 UTC", m.Month.String())
assert.Equal(t, &expectedToBeBudgeted, m.ToBeBudgeted)
assert.Equal(t, &expectedAgeOfMoney, m.AgeOfMoney)
assert.Equal(t, &expectedIncome, m.Income)
assert.Equal(t, &expectedBudgeted, m.Budgeted)
assert.Equal(t, &expectedActivity, m.Activity)
assert.Nil(t, m.Note)
}

0 comments on commit 2f11bb4

Please sign in to comment.