Here is a working example, using $100.00 as the original bill to make the math show up easily.
100.00 - Original Amount
20.00 - Discount
80.00 - Subtotal
18.00 - Gratuity Added based on $100
5.20 - Sales Tax on $80
103.20 - Final amount charged, takes into consideration discount, gratuity and tax.