|
| 1 | +--- |
| 2 | +name: invoice-creator |
| 3 | +description: Generate professional invoices from itemized lists. When a user or AI needs to create an invoice document, this skill guides the process of collecting invoice details (items, quantities, prices, customer info), calculating totals and taxes, and generating a formatted invoice file using a professional template. The skill supports customization of invoice metadata, tax rates, and output formats (HTML/PDF). |
| 4 | +license: MIT |
| 5 | +compatibility: Python 3.8+ |
| 6 | +allowed-tools: write, shell |
| 7 | +--- |
| 8 | + |
| 9 | +# Invoice Creator |
| 10 | + |
| 11 | +This skill enables the creation of professional invoices from itemized lists. It guides the AI through collecting invoice data, calculating totals, and generating formatted invoice documents. |
| 12 | + |
| 13 | +## When to Use This Skill |
| 14 | + |
| 15 | +**Trigger conditions:** |
| 16 | +- User wants to create an invoice |
| 17 | +- User provides a list of items/services with prices |
| 18 | +- User needs to generate a billing document |
| 19 | +- User mentions "invoice", "bill", "receipt", or "billing" |
| 20 | + |
| 21 | +**Initial offer:** |
| 22 | +Offer to help create a professional invoice. Explain that you'll need: |
| 23 | +1. Invoice details (number, date, due date) |
| 24 | +2. Sender/company information |
| 25 | +3. Customer/client information |
| 26 | +4. List of items with descriptions, quantities, and unit prices |
| 27 | +5. Tax rate (if applicable) |
| 28 | +6. Payment terms/notes (optional) |
| 29 | + |
| 30 | +## Workflow |
| 31 | + |
| 32 | +### Step 1: Collect Invoice Metadata |
| 33 | + |
| 34 | +Ask for or confirm: |
| 35 | +- **Invoice Number**: Unique identifier (e.g., "INV-2026-001") |
| 36 | +- **Invoice Date**: Date of issue |
| 37 | +- **Due Date**: Payment deadline (optional) |
| 38 | +- **Currency**: Default to USD if not specified |
| 39 | + |
| 40 | +### Step 2: Collect Sender Information |
| 41 | + |
| 42 | +Ask for or use default: |
| 43 | +- Company/Business name |
| 44 | +- Address |
| 45 | +- Contact information (phone, email) |
| 46 | +- Tax ID/VAT number (if applicable) |
| 47 | + |
| 48 | +If user doesn't provide, use placeholder values and ask if they want to customize. |
| 49 | + |
| 50 | +### Step 3: Collect Customer Information |
| 51 | + |
| 52 | +Ask for: |
| 53 | +- Customer name |
| 54 | +- Address |
| 55 | +- Contact information (optional) |
| 56 | + |
| 57 | +### Step 4: Collect Line Items |
| 58 | + |
| 59 | +For each item, collect: |
| 60 | +- **Item name/description** |
| 61 | +- **Quantity** |
| 62 | +- **Unit price** |
| 63 | +- **Total** (calculated automatically: quantity × unit price) |
| 64 | + |
| 65 | +Support multiple input formats: |
| 66 | +- Structured: "Item: Widget, Qty: 5, Price: $10" |
| 67 | +- List format: "5x Widget @ $10 each" |
| 68 | +- Table format: User provides table data |
| 69 | + |
| 70 | +Continue asking for items until user indicates they're done. |
| 71 | + |
| 72 | +### Step 5: Calculate Totals |
| 73 | + |
| 74 | +Automatically calculate: |
| 75 | +- **Subtotal**: Sum of all line item totals |
| 76 | +- **Tax**: Subtotal × tax rate (if tax rate provided) |
| 77 | +- **Grand Total**: Subtotal + Tax |
| 78 | + |
| 79 | +Display calculations for user confirmation. |
| 80 | + |
| 81 | +### Step 6: Additional Information |
| 82 | + |
| 83 | +Ask for optional details: |
| 84 | +- Payment terms (e.g., "Net 30", "Due on receipt") |
| 85 | +- Notes/memo |
| 86 | +- Tax rate (if not already provided) |
| 87 | + |
| 88 | +### Step 7: Generate Invoice |
| 89 | + |
| 90 | +1. **Load Template**: Use the HTML template from `templates/invoice-template.html` |
| 91 | +2. **Render Data**: Fill template with collected information |
| 92 | +3. **Create File**: Generate `invoice-{invoice-number}.html` in the current directory |
| 93 | +4. **Optional PDF**: If user requests PDF, use the Python script to convert HTML to PDF |
| 94 | + |
| 95 | +**File Output:** |
| 96 | +- Filename: `invoice-{invoice-number}.html` (e.g., `invoice-INV-2026-001.html`) |
| 97 | +- Format: Professional HTML with embedded CSS |
| 98 | +- Print-friendly: Optimized for printing/PDF conversion |
| 99 | + |
| 100 | +## Using the Python Script |
| 101 | + |
| 102 | +The skill includes a Python script (`scripts/generate_invoice.py`) for programmatic invoice generation: |
| 103 | + |
| 104 | +```bash |
| 105 | +python scripts/generate_invoice.py invoice_data.json output.html |
| 106 | +``` |
| 107 | + |
| 108 | +**Input JSON format:** |
| 109 | +```json |
| 110 | +{ |
| 111 | + "invoice_number": "INV-2026-001", |
| 112 | + "invoice_date": "2026-01-28", |
| 113 | + "due_date": "2026-02-27", |
| 114 | + "currency": "USD", |
| 115 | + "sender": { |
| 116 | + "name": "Company Name", |
| 117 | + "address": "123 Main St", |
| 118 | + "city": "City", |
| 119 | + "state": "State", |
| 120 | + "zip": "12345", |
| 121 | + "phone": "+1 (555) 123-4567", |
| 122 | + "email": "billing@company.com", |
| 123 | + "tax_id": "12-3456789" |
| 124 | + }, |
| 125 | + "customer": { |
| 126 | + "name": "Customer Name", |
| 127 | + "address": "456 Oak Ave", |
| 128 | + "city": "City", |
| 129 | + "state": "State", |
| 130 | + "zip": "67890" |
| 131 | + }, |
| 132 | + "items": [ |
| 133 | + { |
| 134 | + "name": "Widget", |
| 135 | + "description": "Premium widget", |
| 136 | + "quantity": 5, |
| 137 | + "unit_price": 10.00, |
| 138 | + "total": 50.00 |
| 139 | + } |
| 140 | + ], |
| 141 | + "subtotal": 50.00, |
| 142 | + "tax_rate": 0.08, |
| 143 | + "tax_amount": 4.00, |
| 144 | + "total": 54.00, |
| 145 | + "payment_terms": "Net 30", |
| 146 | + "notes": "Thank you for your business!" |
| 147 | +} |
| 148 | +``` |
| 149 | + |
| 150 | +## Template Features |
| 151 | + |
| 152 | +The invoice template includes: |
| 153 | +- Professional header with company logo space |
| 154 | +- Clear invoice metadata display |
| 155 | +- Organized customer information section |
| 156 | +- Itemized table with proper alignment |
| 157 | +- Automatic calculations display |
| 158 | +- Footer with payment terms and notes |
| 159 | +- Print-optimized CSS (removes colors, ensures proper page breaks) |
| 160 | +- Responsive design for screen viewing |
| 161 | + |
| 162 | +## Customization |
| 163 | + |
| 164 | +Users can customize: |
| 165 | +- Invoice styling (colors, fonts) by modifying the template |
| 166 | +- Tax calculations (flat rate, multiple tax types) |
| 167 | +- Currency formatting |
| 168 | +- Date formats |
| 169 | +- Additional fields (PO number, terms, etc.) |
| 170 | + |
| 171 | +## Tips for Effective Invoice Creation |
| 172 | + |
| 173 | +1. **Be thorough**: Collect all necessary information before generating |
| 174 | +2. **Verify calculations**: Always show calculations for user confirmation |
| 175 | +3. **Professional formatting**: Use consistent formatting and clear labels |
| 176 | +4. **Save templates**: If user has recurring invoices, save sender info for reuse |
| 177 | +5. **PDF option**: Offer PDF conversion if user needs to email or print |
| 178 | + |
| 179 | +## Error Handling |
| 180 | + |
| 181 | +- Validate all numeric inputs (quantities, prices must be positive numbers) |
| 182 | +- Ensure invoice number is unique (warn if file already exists) |
| 183 | +- Handle missing optional fields gracefully |
| 184 | +- Provide clear error messages if template or script fails |
| 185 | + |
| 186 | +## Scripts |
| 187 | + |
| 188 | +### generate_invoice.py |
| 189 | + |
| 190 | +Generates a professional HTML invoice from JSON data using a template. Validates input data, calculates totals, renders the template, and optionally generates a PDF. |
| 191 | + |
| 192 | +**Usage:** |
| 193 | +```bash |
| 194 | +python scripts/generate_invoice.py <input.json> <output.html> [--pdf] |
| 195 | +``` |
| 196 | + |
| 197 | +**Examples:** |
| 198 | +```bash |
| 199 | +# Generate HTML invoice |
| 200 | +python scripts/generate_invoice.py invoice_data.json invoice.html |
| 201 | + |
| 202 | +# Generate HTML + PDF |
| 203 | +python scripts/generate_invoice.py invoice_data.json invoice.html --pdf |
| 204 | +``` |
| 205 | + |
| 206 | +**Returns:** Dict with status, generated file paths, and invoice metadata. |
0 commit comments