Budget App transfer method not working not sure why

class Category:
    status= False
    name = ''
    balance = 0
    ledger = []
    
    def __init__(self, name):
        self.name=name
        self.ledger=[]

    def deposit (self,amount, description=''):
        self.ledger.append({'amount': float(amount), 'description': description})
      
    def withdraw (self, amount, description=''):
     
        self.check_funds(float(amount))
        if self.status == True:
            self.ledger.append({'amount': -float(amount), 'description':description})
            self.balance = self.balance - amount
            return True
        else:
            return False
                
    def get_balance (self):
        self.balance=0
        
        for item in self.ledger:
            self.balance = self.balance+item['amount']
        return self.balance
    
    def transfer (self, amount, diff_class):
        self.check_funds(amount)
        if self.status == True:
            self.withdraw(amount, 'Transfer to '+ diff_class)
            diff_class.deposit(amount, 'Transer from '+ self.name) 
            return True
        else:
            return False
    
    def check_funds (self, amount):
        self.get_balance()
        if amount > self.balance:
            self.status=False
            return self.status
        else:
            self.status=True
            return self.status
        
    def __repr__(self):
        return "category()"
    def __str__(self):
        x=int((30-len(self.name))/2)
        i=0
        formatted= list ()
        for item in self.ledger:
            desc_ws= 23-len(item['description'])
            amount_ws= 7 - len(str('%.2f' % item['amount']))
            if desc_ws<=0:
                y=item['description'][:23] + ' '+ ' '*amount_ws + str('%.2f' % item['amount'] + '\n')
                formatted.append(y)     
            else:
                y=item['description']+' '*desc_ws+ ' ' + ' '*amount_ws + str('%.2f' % item['amount'] + '\n')
                formatted.append(y)
                                                              
        combined_formatted= ''.join(formatted)                                                      
        return '*'*x + self.name + '*'*x+ '\n' + combined_formatted + 'Total:  ' + str(self.balance)

Hello there.

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.