Burn and mint function not working

Hello

I want to add the burn and mint function into my contract like this:

constructor () public {
  rOwned[_msgSender()] = _rTotal;
}
  function _mint(address account, uint256 amount) public onlyOwner {
        require(account != address(0), "ERC20: mint to the zero address");
         _rOwned[owner()] += amount;
        emit Transfer(address(0), account, amount);
    }
    
function _burn(address account, uint256 amount) public onlyOwner {
     require(account != address(0), "ERC20: burn from the zero address");
    
     uint256 accountBalance = _rOwned[account];
     require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
 
      _rOwned[owner()] = accountBalance - amount;
      
      emit Transfer(account, address(0), amount);
    }

The owner has 1000000000000000 token and I want to burn for example 50% (500000000000000).

Screenshot 2021-06-08 at 17.57.28

After I checked the balance of the owner it does not burn the amount.

Screenshot 2021-06-08 at 17.58.26

What I am doing wrong?

You are trying to burn from owner balance instead of account passed as parameter. Also I think it is a safemoon fork so check how the balance are mapped. rOwned and tOwned based on the account if it excluded or not.

You need to use the “reflected” amount for _rOwned … i.e.

uint256 rAmount = amount * _getRate();

Check out our discord (see the link in my profile) if you need further help