A salon receipt is a useful test for a tip calculator. One receipt can contain a service, a discount, a retail purchase, and tax. If the UI takes a single number called “total,” two calculations can produce different answers while both look plausible.
Consider this sample receipt. These amounts are an example, not a salon's policy.
| Receipt line | Amount |
|---|---|
| Hair service | $100.00 |
| Service discount | −$10.00 |
| Take-home product | $25.00 |
| Tax shown on receipt | $7.50 |
If the customer chooses to tip 20% on the discounted service alone, the base is $90.00 and the tip is $18.00. The amount due, including the other lines, is $140.50. Applying 20% to the entire $122.50 before gratuity instead gives $24.50. Show the selected base so users can tell which choice they made.
Keep the tip base visible
Here's a small JavaScript fixture. The amounts are integer cents. Basis points let the same example represent 18.5% as 1850 as well as 20% as 2000.
const receipt = {
serviceCents: 10_000,
discountCents: 1_000,
retailCents: 2_500,
taxCents: 750,
};
const serviceAfterDiscount = receipt.serviceCents - receipt.discountCents;
const subtotal = serviceAfterDiscount + receipt.retailCents + receipt.taxCents;
const tipRateBps = 2_000;
const tipCents = Math.round((serviceAfterDiscount * tipRateBps) / 10_000);
console.assert(serviceAfterDiscount === 9_000);
console.assert(subtotal === 12_250);
console.assert(tipCents === 1_800);
console.assert(subtotal + tipCents === 14_050);
This fixture accepts an already itemized receipt. In the UI, parse and validate each input at the boundary. Check that a discount does not take the service amount below zero. Display the tip base and the before-tip total separately. If there is an option to include tax, show exactly which taxable lines contribute to that base.
Test two different kinds of split
If the salon tells you to allocate a single $18.00 gratuity across staff, it might be $15.00 for the stylist and $3.00 for the assistant in this example. That split still totals $18.00. If two people are paying the bill equally, their payment amounts are $70.25 each. Those operations use different totals, so they should have distinct labels and assertions.
Try changing the discount to $9.99, or using an odd-cent total and splitting it among three payers. Check that the pieces add back to the exact amount you are dividing. The same receipt makes a useful regression case for percentage rounding, excluded products, and split totals.
For more examples involving discounts, products and assistants, see the hairdresser tipping guide with sample salon receipts.
Disclosure: This article links to a guide from my Calculator Toolkit project. An AI agent drafted this article from the project’s published guide and verified the arithmetic in the example.
Top comments (0)