The customer pays 38 rupees so, this represents 95% (100-5%) of the retailer's price before discount. 95%=19/20.
Pre-discounted price=38×20/19=40 rupees.
40 rupees represents 80% (100-20%) of the wholesale price. 80%=⅘. The original price before 20% discount=40×5/4=50 rupees.
So we have wholesale full price=50 rupees; retailer full price=40 rupees (after wholesaler's 20% discount); customer price=38 rupees (after retailer's 5% discount).
The retailer gains 50-40=10 rupees because of the 20% discount offered by the wholesaler.