Coupon system optimization
I think this replicates the logic:

price = @booking_request.guests * @table_offer.price_cents / 100
@remaining = @coupon.current_amount - price
@coupon.current_amount = @remaining
@price_to_play = @remaining &gt;= 0 ? 0 : -@remaining
coupon.save


Note that I avoid setting @price_to_play to a value and changing it afterwards, that kind of variable re-using makes code harder to understand.