@@ -200,9 +200,23 @@ func (suite *TestSuiteEnv) TestBudgetCalculations() {
200200 suite .Assert ().Fail ("Resource could not be saved" , err )
201201 }
202202
203+ overspendTransaction := models.Transaction {
204+ TransactionCreate : models.TransactionCreate {
205+ Date : marchFifteenthTwentyTwentyTwo ,
206+ BudgetID : budget .ID ,
207+ SourceAccountID : cashAccount .ID ,
208+ DestinationAccountID : groceryAccount .ID ,
209+ Amount : decimal .NewFromFloat (20 ),
210+ },
211+ }
212+ err = database .DB .Save (& overspendTransaction ).Error
213+ if err != nil {
214+ suite .Assert ().Fail ("Resource could not be saved" , err )
215+ }
216+
203217 budget = budget .WithCalculations ()
204218
205- shouldBalance := decimal .NewFromFloat (5489 .38 )
219+ shouldBalance := decimal .NewFromFloat (5469 .38 )
206220 assert .True (suite .T (), budget .Balance .Equal (shouldBalance ), "Balance for budget is not correct. Should be %s, is %s" , shouldBalance , budget .Balance )
207221
208222 // Verify income for used budget in March
@@ -238,14 +252,14 @@ func (suite *TestSuiteEnv) TestBudgetCalculations() {
238252 assert .True (suite .T (), budgeted .IsZero (), "Budgeted is %s, should be 0" , budgeted )
239253
240254 // Verify overspent calculation for month without spend
241- overpent , err := budget .Overspent (time .Date (2022 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ))
255+ overspent , err := budget .Overspent (time .Date (2022 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ))
242256 assert .Nil (suite .T (), err )
243- assert .True (suite .T (), overpent .IsZero (), "Overspent is %s, should be 0" , overpent )
257+ assert .True (suite .T (), overspent .IsZero (), "Overspent is %s, should be 0" , overspent )
244258
245259 // Verify overspent calculation for month with spend
246- overpent , err = budget .Overspent (marchFifteenthTwentyTwentyTwo )
260+ overspent , err = budget .Overspent (marchFifteenthTwentyTwentyTwo )
247261 assert .Nil (suite .T (), err )
248- assert .True (suite .T (), overpent .Equal (decimal .NewFromFloat (110 .62 )), "Overspent is %s, should be 110 .62" , overpent )
262+ assert .True (suite .T (), overspent .Equal (decimal .NewFromFloat (130 .62 )), "Overspent is %s, should be 130 .62" , overspent )
249263}
250264
251265func (suite * TestSuiteEnv ) TestMonthIncomeNoTransactions () {
0 commit comments