invoice-document-pdf
Generating invoices, contracts, forms, receipts, and business documents as professional PDFs
来源信息
- 仓库
- cosmicstack-labs/mercury-agent-skills
- 最近来源活动
- 2026年5月12日 09:02
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 476
- 分支
- 63
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- invoice-document-pdf
- description
- Generating invoices, contracts, forms, receipts, and business documents as professional PDFs
- metadata
- {"author":"cosmicstack-labs","version":"1.0.0","category":"pdf-generation","tags":["invoice","pdf-generation","business-documents","contracts","forms"]}
# Invoice & Document PDF Generation
Generate professional business documents — invoices, contracts, receipts, forms — as polished PDFs. This skill covers templates, data-driven generation, batch processing, digital signatures, and workflow automation.
---
## Invoice PDF Structure
A professional invoice follows a standard layout that makes it easy to process, pay, and reconcile.
### Standard Invoice Anatomy
```text
┌───────────────────────────────────────────┐
│ [LOGO] INVOICE │
│ Your Company #INV-2025-0042 │
│ 123 Business Rd │
│ City, State ZIP │
├─────────────────┬─────────────────────────┤
│ Bill To: │ Invoice Details: │
│ Client Name │ Date: 2025-01-15 │
│ Client Address │ Due: 2025-02-14 │
│ City, State │ Terms: Net 30 │
│ │ PO #: PO-2025-001 │
├─────────────────┴─────────────────────────┤
│ # │ Description │ Qty │ Rate│ Amt │
│ ───┼───────────────────┼─────┼─────┼─────┤
│ 1 │ Web Development │ 40 │ 150 │$6,000│
│ 2 │ UI/UX Design │ 20 │ 125 │$2,500│
│ 3 │ DevOps Setup │ 8 │ 175 │$1,400│
├────────────────────────┴─────┴─────┴─────┤
│ Subtotal: $9,900 │
│ Tax (8%): $792 │
│ Discount (5%): -$495 │
│ Total: $10,197 │
├───────────────────────────────────────────┤
│ Payment Information: │
│ Bank: First National Bank │
│ Account: XXXX-XXXX-1234 │
│ Routing: 021000021 │
│ PayPal: pay@company.com │
├───────────────────────────────────────────┤
│ Terms & Notes: │
│ Payment due within 30 days. │
│ Late payment subject to 1.5%/mo fee. │
└───────────────────────────────────────────┘
```
### Invoice Data Model
```python
"""Invoice data model with validation."""
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from decimal import Decimal
from typing import Optional, list
import uuid
@dataclass
class LineItem:
"""A single line item on an invoice."""
description: str
quantity: Decimal
unit_price: Decimal
sku: Optional[str] = None
@property
def amount(self) -> Decimal:
return self.quantity * self.unit_price
@dataclass
class InvoiceData:
"""Complete invoice data structure."""
# Invoice identifiers
invoice_number: str
po_number: Optional[str] = None
# Dates
issue_date: str = field(default_factory=lambda: datetime.now().strftime("%Y-%m-%d"))
due_date: Optional[str] = None
payment_terms: str = "Net 30"
# Seller (Your company)
seller_name: str = ""
seller_address: str = ""
seller_city: str = ""
seller_state: str = ""
seller_zip: str = ""
seller_phone: str = ""
seller_email: str = ""
seller_logo_path: Optional[str] = None
tax_id: Optional[str] = None
# Buyer (Client)
client_name: str = ""
client_address: str = ""
client_city: str = ""
client_state: str = ""
client_zip: str = ""
client_email: Optional[str] = None
# Line items
line_items: list[LineItem] = field(default_factory=list)
# Financial
tax_rate: Decimal = Decimal("0")
discount_rate: Decimal = Decimal("0")
discount_description: str = "Discount"
currency_symbol: str = "$"
# Payment
bank_name: Optional[str] = None
bank_account: Optional[str] = None
bank_routing: Optional[str] = None
payment_instructions: Optional[str] = None
# Notes
notes: Optional[str] = None
terms: Optional[str] = None
def __post_init__(self):
if not self.due_date:
due = datetime.now() + timedelta(days=30)
self.due_date = due.strftime("%Y-%m-%d")
if not self.invoice_number:
self.invoice_number = f"INV-{datetime.now().strftime('%Y%m')}-{uuid.uuid4().hex[:6].upper()}"
@property
def subtotal(self) -> Decimal:
return sum(item.amount for item in self.line_items)
@property
def tax_amount(self) -> Decimal:
return self.subtotal * self.tax_rate
@property
def discount_amount(self) -> Decimal:
return self.subtotal * self.discount_rate
@property
def total(self) -> Decimal:
return self.subtotal + self.tax_amount - self.discount_amount
```
---
## 2. HTML/CSS Print Templates for Invoices
### Invoice Print Template
```html
<!-- templates/invoice.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Invoice {{ invoice.invoice_number }}</title>
<style>
/* Page setup */
@page {
size: A4;
margin: 1.5cm 2cm 2cm 2cm;
@bottom-center {
content: "Invoice {{ invoice.invoice_number }} — Page " counter(page);
font-size: 8pt;
color: #999;
font-family: 'Helvetica', 'Arial', sans-serif;
}
}
body {
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 9.5pt;
color: #333;
line-height: 1.5;
margin: 0;
padding: 0;
}
/* Header section */
.invoice-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 2cm;
border-bottom: 3px solid #1a1a2e;
padding-bottom: 0.5cm;
}
.invoice-header .seller-info {
flex: 1;
}
.invoice-header .seller-info h1 {
font-size: 11pt;
color: #1a1a2e;
margin: 0 0 4px 0;
font-weight: bold;
}
.invoice-header .seller-info p {
margin: 1px 0;
font-size: 9pt;
color: #666;
}
.invoice-header .invoice-title {
text-align: right;
}
.invoice-header .invoice-title h2 {
font-size: 24pt;
color: #1a1a2e;
margin: 0;
letter-spacing: 3px;
text-transform: uppercase;
}
.invoice-header .invoice-title .invoice-number {
font-size: 12pt;
color: #e94560;
font-weight: bold;
margin-top: 4px;
}
.invoice-header .invoice-title .invoice-number span {
color: #333;
font-weight: normal;
}
/* Billing section */
.billing-section {
display: flex;
justify-content: space-between;
margin-bottom: 1.5cm;
}
.bill-to, .invoice-details {
width: 45%;
}
.bill-to h3, .invoice-details h3 {
font-size: 9pt;
color: #999;
text-transform: uppercase;
letter-spacing: 1px;
margin: 0 0 6px 0;
border-bottom: 1px solid #ddd;
padding-bottom: 4px;
}
.bill-to p, .invoice-details p {
margin: 2px 0;
font-size: 9pt;
}
.invoice-details table {
width: 100%;
border-collapse: collapse;
}
.invoice-details td {
padding: 2px 0;
font-size: 9pt;
}
.invoice-details td:first-child {
color: #999;
width: 40%;
}
.invoice-details td:last-child {
text-align: right;
font-weight: bold;
}
/* Line items table */
.items-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 1cm;
}
.items-table thead th {
background: #1a1a2e;
color: white;
padding: 8px 10px;
font-size: 8.5pt;
text-transform: uppercase;
letter-spacing: 0.5px;
text-align: left;
}
.items-table thead th:last-child {
text-align: right;
}
.items-table thead th:nth-child(3),
.items-table thead th:nth-child(4) {
text-align: right;
}
.items-table tbody td {
padding: 8px 10px;
border-bottom: 1px solid #eee;
font-size: 9pt;
}
.items-table tbody td:last-child {
text-align: right;
font-weight: bold;
}
.items-table tbody td:nth-child(3),
.items-table tbody td:nth-child(4) {
text-align: right;
}
.items-table tbody tr:nth-child(even) {
background: #f8f9fa;
}
.items-table tbody tr:last-child td {
border-bottom: 2px solid #1a1a2e;
}
/* Totals section */
.totals-section {
display: flex;
justify-content: flex-end;
margin-bottom: 1.5cm;
}
.totals-table {
width: 40%;
border-collapse: collapse;
}
.totals-table td {
padding: 4px 10px;
font-size: 9pt;
}
.totals-table td:first-child {
text-align: right;
color: #666;
width: 50%;
}
.totals-table td:last-child {
text-align: right;
font-weight: bold;
width: 50%;
}
.totals-table .total-row td {
border-top: 2px solid #1a1a2e;
font-size: 11pt;
font-weight: bold;
padding-top: 8px;
color: #1a1a2e;
}
.totals-table .discount-row td {
color: #e94560;
}
/* Payment section */
.payment-section {
background: #f8f9fa;
border: 1px solid #dee2e6;
padding: 12px 16px;
margin-bottom: 1cm;
page-break-inside: avoid;
}
.payment-section h3 {
font-size: 9pt;
color: #1a1a2e;
text-transform: uppercase;
letter-spacing: 1px;
margin: 0 0 8px 0;
}
.payment-section p {
margin: 2px 0;
font-size: 8.5pt;
}
/* Notes section */
.notes-section {
font-size: 8.5pt;
color: #666;
margin-top: 1cm;
border-top: 1px solid #ddd;
padding-top: 0.5cm;
}
.notes-section h3 {
font-size: 8pt;
text-transform: uppercase;
letter-spacing: 1px;
color: #999;
margin: 0 0 4px 0;
}
/* Logo */
.logo {
max-height: 1.5cm;
max-width: 4cm;
}
/* QR Code placement */
.qr-code {
position: absolute;
top: 1cm;
right: 2cm;
width: 2cm;
height: 2cm;
}
</style>
</head>
<body>
<div class="invoice-header">
<div class="seller-info">
{% if invoice.seller_logo_path %}
<img src="{{ invoice.seller_logo_path }}" class="logo" alt="Logo">
{% endif %}
<h1>{{ invoice.seller_name }}</h1>
<p>{{ invoice.seller_address }}</p>
<p>{{ invoice.seller_city }}, {{ invoice.seller_state }} {{ invoice.seller_zip }}</p>
{% if invoice.seller_phone %}<p>Phone: {{ invoice.seller_phone }}</p>{% endif %}
{% if invoice.seller_email %}<p>Email: {{ invoice.seller_email }}</p>{% endif %}
{% if invoice.tax_id %}<p>Tax ID: {{ invoice.tax_id }}</p>{% endif %}
</div>
<div class="invoice-title">
<h2>Invoice</h2>
<div class="invoice-number">#<span>{{ invoice.invoice_number }}</span></div>
</div>
</div>
<div class="billing-section">
<div class="bill-to">
<h3>Bill To</h3>
<p><strong>{{ invoice.client_name }}</strong></p>
<p>{{ invoice.client_address }}</p>
<p>{{ invoice.client_city }}, {{ invoice.client_state }} {{ invoice.client_zip }}</p>
{% if invoice.client_email %}<p>{{ invoice.client_email }}</p>{% endif %}
</div>
<div class="invoice-details">
<h3>Invoice Details</h3>
<table>
<tr><td>Invoice Date</td><td>{{ invoice.issue_date }}</td></tr>
<tr><td>Due Date</td><td>{{ invoice.due_date }}</td></tr>
<tr><td>Payment Terms</td><td>{{ invoice.payment_terms }}</td></tr>
在 GitHub 查看这个 SKILL.md 很大,SkillsMP 这里只预览前一段内容。 在 GitHub 查看