@@ -138,7 +138,23 @@ func (suite *TestSuiteEnv) TestBudgetCalculations() {
138138 suite .Assert ().Fail ("Resource could not be saved" , err )
139139 }
140140
141- salaryTransaction := models.Transaction {
141+ salaryTransactionFebruary := models.Transaction {
142+ TransactionCreate : models.TransactionCreate {
143+ Date : marchFifteenthTwentyTwentyTwo ,
144+ BudgetID : budget .ID ,
145+ EnvelopeID : nil ,
146+ SourceAccountID : employerAccount .ID ,
147+ DestinationAccountID : bankAccount .ID ,
148+ Reconciled : true ,
149+ Amount : decimal .NewFromFloat (1800 ),
150+ },
151+ }
152+ err = database .DB .Save (& salaryTransactionFebruary ).Error
153+ if err != nil {
154+ suite .Assert ().Fail ("Resource could not be saved" , err )
155+ }
156+
157+ salaryTransactionMarch := models.Transaction {
142158 TransactionCreate : models.TransactionCreate {
143159 Date : marchFifteenthTwentyTwentyTwo ,
144160 BudgetID : budget .ID ,
@@ -149,7 +165,7 @@ func (suite *TestSuiteEnv) TestBudgetCalculations() {
149165 Amount : decimal .NewFromFloat (2800 ),
150166 },
151167 }
152- err = database .DB .Save (& salaryTransaction ).Error
168+ err = database .DB .Save (& salaryTransactionMarch ).Error
153169 if err != nil {
154170 suite .Assert ().Fail ("Resource could not be saved" , err )
155171 }
@@ -216,18 +232,18 @@ func (suite *TestSuiteEnv) TestBudgetCalculations() {
216232
217233 budget = budget .WithCalculations ()
218234
219- shouldBalance := decimal .NewFromFloat (5469 .38 )
235+ shouldBalance := decimal .NewFromFloat (7269 .38 )
220236 assert .True (suite .T (), budget .Balance .Equal (shouldBalance ), "Balance for budget is not correct. Should be %s, is %s" , shouldBalance , budget .Balance )
221237
222238 // Verify income for used budget in March
223- shouldIncome := decimal .NewFromFloat (2800 )
239+ shouldIncome := decimal .NewFromFloat (4600 )
224240 income , err := budget .Income (marchFifteenthTwentyTwentyTwo )
225241 assert .Nil (suite .T (), err )
226242 assert .True (suite .T (), income .Equal (shouldIncome ), "Income is %s, should be %s" , income , shouldIncome )
227243
228244 // Verify total income for used budget
229- shouldIncomeTotal := decimal .NewFromFloat (5600 )
230- income , err = budget .TotalIncome ()
245+ shouldIncomeTotal := decimal .NewFromFloat (4600 )
246+ income , err = budget .TotalIncome (marchFifteenthTwentyTwentyTwo )
231247 assert .Nil (suite .T (), err )
232248 assert .True (suite .T (), income .Equal (shouldIncomeTotal ), "Income is %s, should be %s" , income , shouldIncomeTotal )
233249
@@ -237,7 +253,7 @@ func (suite *TestSuiteEnv) TestBudgetCalculations() {
237253 assert .True (suite .T (), income .IsZero (), "Income is %s, should be 0" , income )
238254
239255 // Verify total income for empty budget
240- income , err = emptyBudget .TotalIncome ()
256+ income , err = emptyBudget .TotalIncome (marchFifteenthTwentyTwentyTwo )
241257 assert .Nil (suite .T (), err )
242258 assert .True (suite .T (), income .IsZero (), "Income is %s, should be 0" , income )
243259
@@ -281,7 +297,7 @@ func (suite *TestSuiteEnv) TestTotalIncomeNoTransactions() {
281297 suite .Assert ().Fail ("Resource could not be saved" , err )
282298 }
283299
284- income , err := budget .TotalIncome ()
300+ income , err := budget .TotalIncome (time . Date ( 2031 , 3 , 17 , 0 , 0 , 0 , 0 , time . UTC ) )
285301 assert .Nil (suite .T (), err )
286302 assert .True (suite .T (), income .IsZero (), "Income is %s, should be 0" , income )
287303}
0 commit comments