Description
Add a simple tax calculation system that automatically computes taxes on invoices based on a single configurable tax rate.
Why This Matters
Users currently must manually calculate taxes, which is error-prone and time-consuming. Basic automated tax calculation ensures accuracy and saves time.
Features
Tax Configuration
- Tax Rate Setting: Single tax rate per user (e.g., 20%)
- Tax Name: Customizable name (e.g., "VAT", "GST", "Sales Tax")
- Enable/Disable: Option to turn tax calculation on/off
- Default Application: Tax applies to all new invoices automatically
Tax Calculation
- Tax Exclusive (default): Subtotal + Tax = Total
- Automatic Calculation: Updates in real-time as items are added
- Clear Display:
Subtotal: $1,000.00
VAT (20%): $ 200.00
─────────────────────────
Total: $1,200.00
Tax Settings
- Location: Settings page → Tax Configuration
- Simple form: Tax Name, Tax Rate (%), Enable Tax
- Save and apply to all future invoices
Database Schema
-- Add tax fields to invoices table
ALTER TABLE invoices
ADD COLUMN tax_rate DECIMAL(5,2) DEFAULT 0, -- e.g., 20.00 for 20%
ADD COLUMN tax_amount DECIMAL(10,2) DEFAULT 0;
-- Optional: Store user's default tax setting
ALTER TABLE user_settings
ADD COLUMN default_tax_rate DECIMAL(5,2) DEFAULT 0,
ADD COLUMN default_tax_name VARCHAR(50) DEFAULT 'Tax',
ADD COLUMN tax_enabled BOOLEAN DEFAULT false;
User Flow
Setup
- Go to Settings → Tax
- Enable tax calculation (toggle)
- Enter tax name (e.g., "VAT")
- Enter tax rate (e.g., 20)
- Save settings
Creating Invoice
- Create new invoice
- Add line items
- System automatically calculates tax based on user's default rate
- View subtotal, tax amount, and total
- Tax appears on saved invoice and PDF
Tax Calculation Logic
function calculateInvoiceTax(subtotal: number, taxRate: number) {
const tax = subtotal * (taxRate / 100);
const total = subtotal + tax;
return {
subtotal: subtotal,
tax: parseFloat(tax.toFixed(2)), // Round to 2 decimals
total: parseFloat(total.toFixed(2))
};
}
Technical Implementation
Auto-calculation: Update tax when:
- Items are added/removed
- Item quantities/rates change
- Invoice is created
Settings Service:
interface TaxSettings {
taxEnabled: boolean;
taxRate: number;
taxName: string;
}
Invoice Display:
- Show tax row only if tax is enabled
- Display tax name and percentage
- Round all amounts to 2 decimal places
Design Considerations
- Clear indication when tax is enabled
- Display tax percentage in invoice (e.g., "VAT (20%)")
- Tax appears in invoice list, detail view, and PDF
- Simple on/off toggle for tax
- Validation: tax rate between 0-100%
Acceptance Criteria
Edge Cases
- Zero tax rate (0%)
- Tax disabled (don't show tax row)
- Rounding issues (always 2 decimals)
- Negative amounts (validation)
- Very large amounts (handle precision)
Testing Checklist
Priority
High - Core feature for many businesses
Estimated Complexity
Low-Medium - Simple calculation, basic settings UI
Next Steps
After this is complete, see Part 2 for advanced features like per-item tax, tax-exempt items, and multiple tax rates.
Description
Add a simple tax calculation system that automatically computes taxes on invoices based on a single configurable tax rate.
Why This Matters
Users currently must manually calculate taxes, which is error-prone and time-consuming. Basic automated tax calculation ensures accuracy and saves time.
Features
Tax Configuration
Tax Calculation
Tax Settings
Database Schema
User Flow
Setup
Creating Invoice
Tax Calculation Logic
Technical Implementation
Auto-calculation: Update tax when:
Settings Service:
Invoice Display:
Design Considerations
Acceptance Criteria
Edge Cases
Testing Checklist
Priority
High - Core feature for many businesses
Estimated Complexity
Low-Medium - Simple calculation, basic settings UI
Next Steps
After this is complete, see Part 2 for advanced features like per-item tax, tax-exempt items, and multiple tax rates.