How are same year contributions and deductions from/to IRA dealt with?

Could not find a similar discussion beyond excess contributions.

 

Here is a case. This is an IRA owned by over 60 year old, so distributions are not penalized. In 2022 the max allowed contribution is $7K.

 

In May $15K were taken out  as a distribution (not a rollover or conversion). If $20K is put back in Sept in this IRA how is this handled from a taxable view point at year end?

My logic tells me that there would be 20-15 = $5K contribution. 

 

In short, I am asking if an IRA account when withdrawal are fully allowed, can be transacted like a saving account.