Profit loss calculations

i have one question regarding profit amount be taken in actual consideration

10 shares of zomato bought at 50 rs each
20 shares of zomato bought at 60 rs each
50 shares of zomato bought at 40 rs each

in console average price is somethings lets say 45

all this buy orders were in different months

while selling

sold 10 shares at 47 rs
now on console average price increases or decrease (no matter)

if we take profit loss statement from backoffice we will see FIFO
where the sold shares will be taken as loss of 3 rs per share

but what will be actual profit
i want to calculate it based on average price as i bought more quantity to average out price
now while selling price was higher than average price so I sold some quantity but p&L statement will take fifo i want to calculate it by average rate

anyone has any excel or something

i have teared this example in 2 digit actual value i traded was in 4 digits
so this matters