i.e you are talking about BTST sales of shares Buy Today Sale Tomorrow.
BTST® is a facility whereby the customers are being allowed to sell their shares against their receivable position in the same shares from the same Exchange. However, in case there is a short delivery from the Exchange for the earlier buy transaction, then the BTST® customers will also be giving short delivery for their sell transaction. The Exchange would either give delivery of shares bought earlier through market auction or shall closeout the buy transactions as per the Exchange Regulations. However, this would not help the customer in meeting his sale delivery obligations already committed by him as even if he receives the shares bought earlier through auction settlement, by that time the securities pay-in date for his sell transaction would be over. In such case, the customer will have to face auction proceedings against his sale transaction and will have to bear the auction losses, auction penalties and any other incidental charges etc.
Exchange does not net off subsequent sell transaction against the previous buy transaction across the settlements and all the settlement obligations are settled settlement wise.
agreed with Aditya Ji.
In this case capital gain is arise becasue short delivery in your pool account.