Square off and premium consideration

Hi,
Suppose I sold PE for 15600 Aug expiry and got premium of say 165… so 165*50 comes as premium… as I see this gets credited in funds balance…

Now if market goes up and also due to time decay premium value for this strike price gets lower in next few days… let’s after a week premium gets to 100 rupees and I then square of this position…

So how does the calculation works in that case :
My profit will be (165-100)*50?

Will the premium which was credited earlier be debited as well from balance?

Can you please clarify?

Your calculation is correct. ,

And what will happen to premium of 8250 which was credited earlier? Will that be debited as well ?

I got my query clarified from below link. Thank you

Your profits will be = (165-100)*50 = 3250
So, 5000 will be debited from your account because you need to buy back contracts at 100