Prompt
How do I calculate tax for subscriptions, one-time purchases, refunds, and invoices?
Latest observation
Here’s a practical way to calculate tax for each case. I’ll keep it general, since exact rules depend on your country/state and whether you’re charging sales tax, VAT, GST, or similar.
1) Subscriptions
For subscriptions, tax is usually calculated on each recurring charge.
Formula
Tax = Subscription price × tax rate
Example
- Monthly subscription: $20
- Tax rate: 10%
Tax = 20 × 0.10 = $2
Total charged = $22
Important notes
- Tax may be applied:
- on every billing cycle
- based on the customer’s location
- based on the product type
- If the tax rate changes, future subscription invoices may use the new rate.
2) One-time purchases
Tax is calculated once at the time of sale.
Formula
Tax = Item price × tax rate
Example
- Product price: $100
- Tax rate: 8%
Tax = 100 × 0.08 = $8
Total charged = $108
If multiple items
Calculate tax per item or on the subtotal, depending on local rules and your tax system.
Tax = (sum of taxable items) × tax rate
3) Refunds
Refund tax by reversing the original tax amount for the refunded portion.
Full refund
If the customer gets the full amount back:
- Refund amount: $108
- Original tax: $8
- Tax refund: $8
Partial refund
If only part of the purchase is refunded:
Refund tax = Original tax × (Refunded amount / Original amount)
Example
- Original purchase: $100
- Tax: $8
- Total: $108
- Partial refund: $50 of the $100 item price
Refund tax = 8 × (50 / 100) = $4
So refund:
- Item: $50
- Tax: $4
- Total refund: $54
Important notes
- Refund tax should usually match the tax originally collected for that portion.
- Some systems require separate credit notes or refund invoices.
4) Invoices
An invoice usually shows:
- subtotal
- tax
- total due
Formula
Subtotal = sum of line items
Tax = taxable subtotal × tax rate
Total = subtotal + tax
Example
- Service A: $70
- Service B: $30
- Subtotal: $100
- Tax rate: 5%
Tax = 100 × 0.05 = $5
Invoice total = $105
If invoice has taxable and non-taxable items
Only apply tax to taxable items.
Tax = sum of taxable items × tax rate
General calculation pattern
For most situations:
- Determine the taxable amount
- Apply the correct tax rate
- Round according to local rules
- Add tax to get the total
Core formula
Tax = Taxable amount × Tax rate
Total = Taxable amount + Tax
Things to watch out for
- Tax-inclusive pricing: tax is already included in the listed price, so you must extract it.
- Multiple tax rates: some items may have different rates.
- Jurisdiction rules: tax can depend on customer location, seller location, and product type.
- Rounding: tax may be rounded per line item or at the invoice total level.
- Exempt items/customers: some sales may not be taxable.
If you want a simple implementation rule
Use this:
- Subscriptions: calculate tax on each recurring invoice
- One-time purchases: calculate tax once on the purchase
- Refunds: reverse tax proportionally to the refund
- Invoices: tax the taxable subtotal and add it to the total
If you want, I can also give you:
- a worked example table,
- formula code in Python/JavaScript, or
- guidance for tax-inclusive vs tax-exclusive pricing.