invoice-template by claude-office-skills/skills
npx skills add https://github.com/claude-office-skills/skills --skill invoice-template此技能可根据结构化数据和模板生成专业的 PDF 发票。可创建包含公司品牌、明细项目、税费计算和付款详情的发票。
示例提示:
invoice_data = {
"invoice_number": "INV-2026-001",
"date": "2026-01-30",
"due_date": "2026-02-28",
"from": {
"name": "Your Company",
"address": "123 Business St",
"email": "billing@company.com"
},
"to": {
"name": "Client Name",
"address": "456 Client Ave",
"email": "client@example.com"
},
"items": [
{"description": "Consulting", "quantity": 10, "rate": 150.00},
{"description": "Development", "quantity": 20, "rate": 100.00}
],
"tax_rate": 0.08,
"notes": "Payment due within 30 days"
}
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def create_invoice(data: dict, output_path: str):
c = canvas.Canvas(output_path, pagesize=letter)
width, height = letter
# 页眉
c.setFont("Helvetica-Bold", 24)
c.drawString(1*inch, height - 1*inch, "INVOICE")
# 发票详情
c.setFont("Helvetica", 12)
c.drawString(1*inch, height - 1.5*inch, f"Invoice #: {data['invoice_number']}")
c.drawString(1*inch, height - 1.75*inch, f"Date: {data['date']}")
# 发件人/收件人
y = height - 2.5*inch
c.drawString(1*inch, y, f"From: {data['from']['name']}")
c.drawString(4*inch, y, f"To: {data['to']['name']}")
# 项目表格
y = height - 4*inch
c.setFont("Helvetica-Bold", 10)
c.drawString(1*inch, y, "Description")
c.drawString(4*inch, y, "Qty")
c.drawString(5*inch, y, "Rate")
c.drawString(6*inch, y, "Amount")
c.setFont("Helvetica", 10)
subtotal = 0
for item in data['items']:
y -= 0.3*inch
amount = item['quantity'] * item['rate']
subtotal += amount
c.drawString(1*inch, y, item['description'])
c.drawString(4*inch, y, str(item['quantity']))
c.drawString(5*inch, y, f"${item['rate']:.2f}")
c.drawString(6*inch, y, f"${amount:.2f}")
# 总计
tax = subtotal * data['tax_rate']
total = subtotal + tax
y -= 0.5*inch
c.drawString(5*inch, y, f"Subtotal: ${subtotal:.2f}")
y -= 0.25*inch
c.drawString(5*inch, y, f"Tax ({data['tax_rate']*100}%): ${tax:.2f}")
y -= 0.25*inch
c.setFont("Helvetica-Bold", 12)
c.drawString(5*inch, y, f"Total: ${total:.2f}")
c.save()
return output_path
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
from weasyprint import HTML
from jinja2 import Template
invoice_template = """
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial; margin: 40px; }
.header { display: flex; justify-content: space-between; }
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
.total { font-weight: bold; font-size: 18px; }
</style>
</head>
<body>
<div class="header">
<h1>INVOICE</h1>
<div>
<p>Invoice #: {{ invoice_number }}</p>
<p>Date: {{ date }}</p>
</div>
</div>
<table>
<tr><th>Description</th><th>Qty</th><th>Rate</th><th>Amount</th></tr>
{% for item in items %}
<tr>
<td>{{ item.description }}</td>
<td>{{ item.quantity }}</td>
<td>${{ "%.2f"|format(item.rate) }}</td>
<td>${{ "%.2f"|format(item.quantity * item.rate) }}</td>
</tr>
{% endfor %}
</table>
<p class="total">Total: ${{ "%.2f"|format(total) }}</p>
</body>
</html>
"""
def create_invoice_html(data: dict, output_path: str):
template = Template(invoice_template)
# 计算总计
total = sum(i['quantity'] * i['rate'] for i in data['items'])
total *= (1 + data.get('tax_rate', 0))
data['total'] = total
html = template.render(**data)
HTML(string=html).write_pdf(output_path)
return output_path
# 安装所需的依赖项
pip install python-docx openpyxl python-pptx reportlab jinja2
每周安装次数
24
仓库
GitHub 星标数
5
首次出现
1 天前
安全审计
已安装于
claude-code23
opencode4
gemini-cli4
github-copilot4
codex4
amp4
This skill generates professional PDF invoices from structured data and templates. Create invoices with company branding, itemized lists, tax calculations, and payment details.
Example prompts:
invoice_data = {
"invoice_number": "INV-2026-001",
"date": "2026-01-30",
"due_date": "2026-02-28",
"from": {
"name": "Your Company",
"address": "123 Business St",
"email": "billing@company.com"
},
"to": {
"name": "Client Name",
"address": "456 Client Ave",
"email": "client@example.com"
},
"items": [
{"description": "Consulting", "quantity": 10, "rate": 150.00},
{"description": "Development", "quantity": 20, "rate": 100.00}
],
"tax_rate": 0.08,
"notes": "Payment due within 30 days"
}
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def create_invoice(data: dict, output_path: str):
c = canvas.Canvas(output_path, pagesize=letter)
width, height = letter
# Header
c.setFont("Helvetica-Bold", 24)
c.drawString(1*inch, height - 1*inch, "INVOICE")
# Invoice details
c.setFont("Helvetica", 12)
c.drawString(1*inch, height - 1.5*inch, f"Invoice #: {data['invoice_number']}")
c.drawString(1*inch, height - 1.75*inch, f"Date: {data['date']}")
# From/To
y = height - 2.5*inch
c.drawString(1*inch, y, f"From: {data['from']['name']}")
c.drawString(4*inch, y, f"To: {data['to']['name']}")
# Items table
y = height - 4*inch
c.setFont("Helvetica-Bold", 10)
c.drawString(1*inch, y, "Description")
c.drawString(4*inch, y, "Qty")
c.drawString(5*inch, y, "Rate")
c.drawString(6*inch, y, "Amount")
c.setFont("Helvetica", 10)
subtotal = 0
for item in data['items']:
y -= 0.3*inch
amount = item['quantity'] * item['rate']
subtotal += amount
c.drawString(1*inch, y, item['description'])
c.drawString(4*inch, y, str(item['quantity']))
c.drawString(5*inch, y, f"${item['rate']:.2f}")
c.drawString(6*inch, y, f"${amount:.2f}")
# Totals
tax = subtotal * data['tax_rate']
total = subtotal + tax
y -= 0.5*inch
c.drawString(5*inch, y, f"Subtotal: ${subtotal:.2f}")
y -= 0.25*inch
c.drawString(5*inch, y, f"Tax ({data['tax_rate']*100}%): ${tax:.2f}")
y -= 0.25*inch
c.setFont("Helvetica-Bold", 12)
c.drawString(5*inch, y, f"Total: ${total:.2f}")
c.save()
return output_path
from weasyprint import HTML
from jinja2 import Template
invoice_template = """
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial; margin: 40px; }
.header { display: flex; justify-content: space-between; }
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
th, td { border: 1px solid #ddd; padding: 10px; text-align: left; }
.total { font-weight: bold; font-size: 18px; }
</style>
</head>
<body>
<div class="header">
<h1>INVOICE</h1>
<div>
<p>Invoice #: {{ invoice_number }}</p>
<p>Date: {{ date }}</p>
</div>
</div>
<table>
<tr><th>Description</th><th>Qty</th><th>Rate</th><th>Amount</th></tr>
{% for item in items %}
<tr>
<td>{{ item.description }}</td>
<td>{{ item.quantity }}</td>
<td>${{ "%.2f"|format(item.rate) }}</td>
<td>${{ "%.2f"|format(item.quantity * item.rate) }}</td>
</tr>
{% endfor %}
</table>
<p class="total">Total: ${{ "%.2f"|format(total) }}</p>
</body>
</html>
"""
def create_invoice_html(data: dict, output_path: str):
template = Template(invoice_template)
# Calculate total
total = sum(i['quantity'] * i['rate'] for i in data['items'])
total *= (1 + data.get('tax_rate', 0))
data['total'] = total
html = template.render(**data)
HTML(string=html).write_pdf(output_path)
return output_path
# Install required dependencies
pip install python-docx openpyxl python-pptx reportlab jinja2
Weekly Installs
24
Repository
GitHub Stars
5
First Seen
1 day ago
Security Audits
Gen Agent Trust HubPassSocketFailSnykPass
Installed on
claude-code23
opencode4
gemini-cli4
github-copilot4
codex4
amp4
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
22,500 周安装
Schema结构化数据完整指南:实现富媒体结果与AI搜索优化(2025)
244 周安装
实用程序员框架:DRY、正交性等七大元原则提升软件质量与架构设计
244 周安装
Python PDF处理指南:合并拆分、提取文本表格、创建PDF文件教程
244 周安装
Ruby on Rails 应用开发指南:构建功能全面的Rails应用,包含模型、控制器、身份验证与最佳实践
245 周安装
代码规范库技能 - 多语言编码标准库,支持Python/Go/Rust/TypeScript等自动加载
245 周安装
阿里云Model Studio模型爬取与技能自动生成工具 - 自动化AI技能开发
245 周安装