You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This adds more fields to the /v1/month endpoint:
* `data` now has an additional `allocation` field that contains the
sum of all allocations for the month
* All categories (in `data.categories`) now have the following
additional fields:
* `balance`: Sum of all allocations for envelopes in that category
* `allocation`: Sum of all allocations for that category
* `spent`: Sum of spend for all envelopes
This deprecates the `data.budgeted` field on the /v1/month endpoint
in favor of the `data.allocation` field.
suite.Assert().True(month.Data.Balance.Equal(tt.response.Data.Balance), "Month balance calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, tt.response.Data.Balance, month.Data.Balance, month.Data)
194
206
207
+
// Verify allocation calculation
208
+
suite.Assert().True(month.Data.Allocation.Equal(tt.response.Data.Allocation), "Month allocation sum for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, tt.response.Data.Allocation, month.Data.Allocation, month.Data)
209
+
210
+
// Verify month spent calculation
211
+
suite.Assert().True(month.Data.Spent.Equal(tt.response.Data.Spent), "Month spent is wrong. Should be %v, but is %v: %#v", tt.response.Data.Spent, month.Data.Spent, month.Data)
212
+
195
213
if!suite.Assert().Len(month.Data.Categories, 1) {
196
214
suite.Assert().FailNow("Response category length does not match!", "Category list does not have exactly 1 item, it has %d, Request ID: %s", len(month.Data.Categories), r.Header().Get("x-request-id"))
suite.Assert().FailNow("Response envelope length does not match!", "Envelope list does not have exactly 1 item, it has %d, Request ID: %s", len(month.Data.Categories[0].Envelopes), r.Header().Get("x-request-id"))
201
219
}
202
220
203
-
suite.Assert().True(month.Data.Spent.Equal(tt.response.Data.Spent), "Month spent is wrong. Should be %v, but is %v: %#v", tt.response.Data.Spent, month.Data.Spent, month.Data)
221
+
// Category calculations
222
+
expectedCategory:=tt.response.Data.Categories[0]
223
+
category:=month.Data.Categories[0]
224
+
225
+
suite.Assert().True(category.Spent.Equal(expectedCategory.Spent), "Monthly category spent calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expectedCategory.Spent, category.Spent, month.Data)
226
+
suite.Assert().True(category.Balance.Equal(expectedCategory.Balance), "Monthly category balance calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expectedCategory.Balance, category.Balance, month.Data)
227
+
suite.Assert().True(category.Allocation.Equal(expectedCategory.Allocation), "Monthly category allocation fetch for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expectedCategory.Allocation, category.Allocation, month.Data)
suite.Assert().True(envelope.Spent.Equal(expected.Spent), "Monthly spent calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expected.Spent, envelope.Spent, month.Data)
208
-
suite.Assert().True(envelope.Balance.Equal(expected.Balance), "Monthly balance calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expected.Balance, envelope.Balance, month.Data)
209
-
suite.Assert().True(envelope.Allocation.Equal(expected.Allocation), "Monthly allocation fetch for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expected.Allocation, envelope.Allocation, month.Data)
suite.Assert().True(envelope.Spent.Equal(expectedEnvelope.Spent), "Monthly envelope spent calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expectedEnvelope.Spent, envelope.Spent, month.Data)
234
+
suite.Assert().True(envelope.Balance.Equal(expectedEnvelope.Balance), "Monthly envelope balance calculation for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expectedEnvelope.Balance, envelope.Balance, month.Data)
235
+
suite.Assert().True(envelope.Allocation.Equal(expectedEnvelope.Allocation), "Monthly envelope allocation fetch for %v is wrong: should be %v, but is %v: %#v", month.Data.Month, expectedEnvelope.Allocation, envelope.Allocation, month.Data)
0 commit comments