← 返回
数据分析

Invoice Generator

Generate professional PDF invoices from JSON data. Use when the user needs to create an invoice, billing document, or payment request with company/client details and line items.
从JSON数据生成专业PDF发票。适用于需要创建包含公司与客户信息及明细项的发票、账单或付款请求的场景。
tmigone
数据分析 clawhub v1.0.0 1 版本 98941.2 Key: 无需
★ 2
Stars
📥 4,819
下载
💾 592
安装
1
版本
#latest

概述

Invoice Generator

Generate PDF invoices from structured JSON data.

Setup

  1. Install Node.js dependencies:
cd invoice-generator && npm install
  1. Set INVOICE_DIR environment variable (or in skills.entries.invoice-generator.env):
export INVOICE_DIR="/path/to/your/invoices"

This creates the directory structure:

$INVOICE_DIR/
├── configs/    # Optional: saved invoice configs
└── invoices/   # Generated PDF output

Usage

# From stdin (on-the-fly)
cat invoice-data.json | {baseDir}/scripts/generate.sh

# From a full file path
{baseDir}/scripts/generate.sh /path/to/invoice-data.json

# From a saved config (looks in $INVOICE_DIR/configs/)
{baseDir}/scripts/generate.sh client-template
# Loads: $INVOICE_DIR/configs/client-template.json

# Output goes to: $INVOICE_DIR/invoices/invoice-{number}.pdf (auto-versions if exists)

Input Data Format

The JSON input must contain these fields:

{
  "company": {
    "name": "Your Company",
    "address": "123 Main St",
    "cityStateZip": "City, State, 12345",
    "country": "Country"
  },
  "client": {
    "name": "Client Name",
    "address": "456 Client Ave",
    "cityStateZip": "City, State, 67890",
    "country": "Country",
    "taxId": "TAX123"
  },
  "invoice": {
    "number": "INV-2025.01",
    "date": "Jan 15 2025",
    "dueDate": "Jan 30 2025"
  },
  "items": [
    {
      "description": "Service description",
      "rate": "1000.00",
      "currency": "USD"
    }
  ],
  "totals": {
    "currency": "USD",
    "total": "1,000.00"
  }
}

See references/data-schema.md for complete field documentation.

Output

The script outputs the path to the generated PDF file on success:

$INVOICE_DIR/invoices/invoice-INV-2025.01.pdf
# If that filename already exists, the script will write:
# $INVOICE_DIR/invoices/invoice-INV-2025.01-2.pdf (then -3, etc.)

Error Handling

  • Exits with code 1 if JSON is invalid or missing required fields
  • Exits with code 2 if weasyprint fails to generate PDF
  • Error messages are written to stderr

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-28 10:31 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 162 📥 59,660
data-analysis

Data Analysis

ivangdavila
{"answer":"数据分析与可视化。查询数据库、生成报告、自动化电子表格,将原始数据转化为清晰可行的见解。适用于:(1) 您……"}
★ 198 📥 64,843
data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 366 📥 139,944