Budget App output issue

My budget app has passed all the test cases but I noticed that for my Clothing object, the transaction for withdrawals don’t appear on the output. I see the transfer of 50 from food but nothing else. Food and Auto categories appear okay. Any ideas?

*************Food*************
initial deposit        1000.00
groceries               -10.15
restaurant and more foo -15.89
Transfer to Clothing    -50.00
Total: 923.96
***********Clothing***********
Transfer from Food       50.00
Total: 0.00
*************Auto*************
initial deposit        1000.00
                        -15.00

Notice that Total amount for Clothing also seems to be incorrect. This could be related to the lack of withdrawals from it.

Interesting. I added a print balance for the clothing category after the food transfer to it and it is 0. So I’m guessing it wouldn’t be able to withdraw anything if it’s not accepting the $50.

print(food.get_balance())
clothing = budget.Category("Clothing")
food.transfer(50, clothing)
print(clothing.get_balance())

973.96
0

But the transfer method passed the test case. Hmm

That seems to be the reason. Have you considered using the existing deposit and withdraw methods when making the transfer?

Regarding the passing test, would you be willing to create an issue on the freeCodeCamp repository, that test might need some augmenting to check if withdrawals are working after the transfer? Issues · freeCodeCamp/freeCodeCamp · GitHub

1 Like

Thanks. I applied deposit and withdraw to accomplish the transfer method. Seems to be behaving correctly now.

I have opened an issue about the test case not being robust.