JA
ベータ版の翻訳

@core / invoices

1.0.3 ▾
認証済みMIT
GitHub

注文からスペインの請求書:法定採番、簡易/完全、訂正請求書、VeriFactu 形式のハッシュチェーン

コード0 ファイルコンテキスト約 901 トークンスキャン合格

インストール

$genpm add @core/invoices

含まれるもの

  • src/lib/invoices/ にソースコード(0 ファイル)。
  • src/lib/invoices/AGENTS.md に AI ルール、加えて IDE 用のルールファイル。
  • .env.example に追加される環境変数: INVOICE_ISSUER_NIF, INVOICE_ISSUER_NAME, INVOICE_ISSUER_ADDRESS, INVOICE_SERIES, INVOICE_VAT_RATE, INVOICE_RETAIL, INVOICE_QR_ENV。
  • @core/contracts, @core/db, @core/orders を自動で解決します。

README

@core/invoices

genpm license

Spanish invoices from paid orders: legal numbering, simplified/full, credit notes and VeriFactu-style hash chain

A GenPM module: source code + AI rules + MCP config, injected into your project instead of hidden in node_modules. The code lands in src/lib/invoices, pinned to a verified commit, and you own it.

Install

genpm add @core/invoices

No genpm yet? curl -fsSL https://genpm.net/install.sh | sh (macOS/Linux), irm https://genpm.net/install.ps1 | iex (Windows), or one-off with npx @genpm-net/cli add @core/invoices.

Or let your AI agent do it: run genpm mcp setup once, then ask "add @core/invoices with genpm" in Claude Code, Cursor, VS Code, Windsurf, Codex or Gemini CLI. It shows you a dry-run plan before writing anything.

What it does

Spanish invoices for paid orders (@core/orders): correlative numbering per series and year without gaps, simplified invoice up to the legal limit and full invoice above it, credit notes (rectificativas por diferencias) for refunds in their own series, full invoices that replace simplified ones when the customer gives their tax details, printable HTML with the mandatory content, and VeriFactu-style registration records: each record carries the SHA-256 hash of the previous one (format verified against the AEAT example) and the AEAT verification QR URL. Invoices are never edited or deleted. Tables: invoices, invoice_counters, invoice_records.

Scope of 1.0 (tell the person): this package prepares the data required by RD 1007/2023 and Order HAC/1177/2024, but it does not yet sign records (non-VeriFactu mode) nor send them to the AEAT (VeriFactu mode), and it is not a certified billing system. Deadlines changed several times. In force (BOE, RD-ley 15/2025): billing systems adapted before 1 Jan 2027 (corporate income tax payers) and 1 Jul 2027 (everyone else). On 5 Oct 2026 the Ministry announced a planned move to October 2028, not yet published in the BOE (checked 7 Oct 2026). Check the current official calendar with the AEAT or a tax advisor before relying on either date.

Setup

After genpm add, follow these steps (your AI agent finds the same steps in src/lib/invoices/AGENTS.md and can do them for you):

  1. Env: INVOICE_ISSUER_NIF, INVOICE_ISSUER_NAME, INVOICE_ISSUER_ADDRESS; optional INVOICE_SERIES (default A; credit notes use <series>R), INVOICE_VAT_RATE (default 21, prices include VAT), INVOICE_RETAIL=1 (simplified limit 3,000 € instead of 400 €), INVOICE_QR_ENV=test while testing.
  2. Migrations as in src/lib/db/AGENTS.md. Import @/lib/invoices once at startup (e.g. src/genpm/commerce.ts): it issues invoices when orders are paid and credit notes when they are refunded (background jobs, retried).
  3. Admin: add invoicesAdminResource({ printPath: (i) => \/invoices/${i.number}` })tosrc/genpm/admin.ts`.
  4. Printable page for the owner (protected by invoices:read) or the customer (signed order link): return new Response(invoiceHtml(inv, { qrImageSrc }), { headers: { 'content-type': 'text/html' } }). Generate the QR image from invoiceQrUrl(inv) with a QR library in the app.
  5. Verify: pay a test order → invoice A<year>-000001; refund part → credit note AR<year>-000001 with a negative total; verifyChain(nif) returns ok: true.

What's inside

Paths are relative to src/lib/invoices.

  • index.ts — invoiceOrder, rectifyRefund, rectifyInFull, remainingToRectify, replaceSimplified, verifyChain, invoiceHtml, invoiceQrUrl, invoicesAdminResource.
  • invoices.ts — issuing and order events. verifactu.ts — hash input, hash, Madrid dates, amounts, QR URL. html.ts — printable invoice.

At a glance

  • GenPM dependencies (installed with it): @core/db, @core/orders, @core/contracts
  • npm dependencies (proposed, never installed without asking): zod
  • Environment variables (added to .env.example): INVOICE_ISSUER_NIF, INVOICE_ISSUER_NAME, INVOICE_ISSUER_ADDRESS, INVOICE_SERIES, INVOICE_VAT_RATE, INVOICE_RETAIL, INVOICE_QR_ENV
  • AI rules: AGENTS.md, loaded by your agent only when it works in src/lib/invoices

Security

GenPM installs a 40-character commit SHA (never a branch), verifies an Ed25519-signed manifest, never runs install scripts and scans AI rules for prompt injection. Details: genpm.net/docs/security.

License

MIT — see LICENSE. Browse the full catalog at genpm.net.

@core/invoices を報告

パッケージを報告するには GitHub でログインしてください。

GitHub で続ける