Answer:
Since Amarillo paid the invoice within the discount period, the amount paid was $3,960 but both the merchandise inventory and the accounts payable had a $4,000 balance. So the discount should affect directly both accounts (assets and liabilities) by decreasing both of them by $40.
That way accounts payable's balance = $4,000 - $3,960 (cash payment) - $40 (purchase discount) = $0
Merchandise inventory = $4,000 - $40 = $3,960
Purchases discount is a contra-purchase account, so it lowers expenses, it doesn't increase revenue.