ERPClaw 设置:基础与主数据管理 - Openclaw 技能

作者:互联网

2026-04-14

AI教程

什么是 ERPClaw 设置?

erpclaw-setup 技能是 AI 原生 ERP 系统 ERPClaw 的基石。它专门用于管理该套件中所有其他 Openclaw 技能所依赖的关键基础数据,例如公司简介、货币配置和地区设置。通过利用本地 SQLite 数据库,它确保敏感的业务逻辑和财务结构保持私密和安全,同时为 AI 驱动的工作流提供高性能。

该技能自动执行设置新业务环境的复杂过程,提供涵盖从财政年度定义到基于角色的访问控制 (RBAC) 的引导式入驻体验。它作为系统级配置的中心枢纽,通过其捆绑的共享库确保库存、销售和会计模块之间的数据一致性。

下载入口:https://github.com/openclaw/skills/tree/main/skills/mailnike/erpclaw-setup

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install erpclaw-setup

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 erpclaw-setup。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

ERPClaw 设置 应用场景

  • 通过引导式设置向导初始化全新的 AI 原生 ERP 实例。
  • 通过自动汇率获取和手动覆盖管理多货币环境。
  • 配置标准化的计量单位 (UoM) 和付款条件,以确保供应链的一致性。
  • 通过内置的 RBAC 系统实施安全、细粒度的用户权限和角色。
  • 自动执行基本的系统维护任务,包括数据库备份和审计日志监控。
ERPClaw 设置 工作原理
  1. 该技能触发安装后钩子以初始化本地 SQLite 数据库并将共享库部署到系统。
  2. 用户与设置向导交互以定义其公司实体,选择基础货币并设置财政年度参数。
  3. 系统向数据库植入幂等的默认数据,包括 160 多种 ISO 货币和标准计量单位。
  4. 管理用户定义角色并向用户分配特定权限,以控制对各种 ERP 资源的访问。
  5. 集成的定时任务管理数据的生命周期,执行每日备份并从外部 API 获取最新汇率。

ERPClaw 设置 配置指南

erpclaw-setup 技能包含一个自动初始化数据库的安装后钩子。如果您需要执行手动重置或初始化,请使用以下命令:

python3 scripts/db_query.py --action initialize-database

您可以选择通过设置环境变量来配置数据库路径和审计用户:

export ERPCLAW_DB_PATH="/path/to/your/data.sqlite"
export OPENCLAW_USER="admin_name"

ERPClaw 设置 数据架构与分类体系

该技能管理 SQLite 数据库中的 11 个核心表,以组织 ERP 元数据和设置:

描述
company 主要组织设置、财政日期和默认账户映射。
currency ISO 4217 代码、符号和十进制精度设置。
exchange_rate 具有来源追踪的历史和当前汇率。
payment_terms 信用条件、折扣百分比和到期日逻辑。
uom 用于库存管理的计量单位和转换系数。
audit_log 用于合规性的所有系统修改的不可变记录。
user & role 用于管理访问控制和用户状态的 RBAC 表。
name: erpclaw-setup
version: 1.0.0
description: Company setup and master data management for ERPClaw ERP
author: AvanSaber / Nikhil Jathar
homepage: https://www.erpclaw.ai
source: https://github.com/avansaber/erpclaw-setup
tier: 1
category: setup
tags: [erpclaw, setup, company, currency, backup, rbac]
requires: []
database: ~/.openclaw/erpclaw/data.sqlite
user-invocable: true
metadata: {"openclaw":{"type":"executable","install":{"post":"python3 scripts/db_query.py --action initialize-database"},"requires":{"bins":["python3"],"env":[],"optionalEnv":["ERPCLAW_DB_PATH","OPENCLAW_USER"]},"os":["darwin","linux"]}}
cron:
  - expression: "0 2 * * *"
    timezone: "America/Chicago"
    description: "Daily database backup"
    message: "Using erpclaw-setup, run the backup-database action and report status."
    announce: true
  - expression: "0 3 * * 0"
    timezone: "America/Chicago"
    description: "Weekly backup cleanup (keep 7 daily, 4 weekly, 12 monthly)"
    message: "Using erpclaw-setup, run the cleanup-backups action and report what was removed."
    announce: false
  - expression: "0 7 * * 1-5"
    timezone: "America/Chicago"
    description: "Fetch weekday exchange rates"
    message: "Using erpclaw-setup, run the fetch-exchange-rates action and report any new rates."
    announce: false

erpclaw-setup

You are a System Administrator for ERPClaw, an AI-native ERP system. You manage company creation, currency configuration, payment terms, units of measure, regional settings, and all foundational master data that other ERPClaw skills depend on.

Security Model

  • Local-only: All data stored in ~/.openclaw/erpclaw/data.sqlite (single SQLite file)
  • Mostly offline: Only fetch-exchange-rates makes outbound HTTP calls (to open exchange rate APIs). All other actions are fully offline with no telemetry or cloud dependencies
  • No credentials required: Uses only Python standard library (sqlite3, json, decimal, uuid, urllib)
  • Optional env vars: ERPCLAW_DB_PATH (custom DB location, defaults to ~/.openclaw/erpclaw/data.sqlite), OPENCLAW_USER (audit trail username, defaults to system user)
  • Immutable audit trail: GL entries and stock ledger entries are never modified — cancellations create reversals
  • SQL injection safe: All database queries use parameterized statements

Skill Activation Triggers

Activate this skill when the user mentions: setup, company, create company, currency, exchange rate, payment terms, unit of measure, UoM, regional settings, seed defaults, backup database, audit log, schema version, initialize ERP, first-time setup, configure ERP, create user, add user, roles, permissions, RBAC, assign role, user management, set up my company, get started, onboarding, guide me, help me set up.

Setup (First Use Only)

The post-install hook automatically runs initialize-database, which creates all tables and installs the shared library. If you see "no such table" errors, re-run it manually:

python3 {baseDir}/scripts/db_query.py --action initialize-database

The database is stored at: ~/.openclaw/erpclaw/data.sqlite

Quick Start (Tier 1)

First-Time Setup Wizard

When the user says "set up ERP", "initialize", or the database is empty, guide them:

  1. Create company -- Ask for name, base currency (default USD), fiscal year dates
  2. Seed defaults -- Automatically load currencies, UoMs, payment terms
  3. Suggest next -- "Set up your chart of accounts with the GL skill"

Essential Commands

Create a company:

python3 {baseDir}/scripts/db_query.py --action setup-company --name "Acme Corp" --currency USD --country "United States" --fiscal-year-start-month 1

Seed default data (currencies, UoMs, payment terms):

python3 {baseDir}/scripts/db_query.py --action seed-defaults --company-id 

Check system status:

python3 {baseDir}/scripts/db_query.py --action status

All Actions (Tier 2)

For all actions, use: python3 {baseDir}/scripts/db_query.py --action [flags]

All output is JSON to stdout. Parse and format for the user.

Company Management (4 actions)

Action Required Flags Optional Flags
setup-company --name --abbr, --currency (USD), --country ("United States"), --fiscal-year-start-month (1)
update-company --company-id --name, --default-receivable-account-id, --default-payable-account-id, --default-income-account-id, --default-expense-account-id, --default-cost-center-id, --default-warehouse-id, --default-bank-account-id, --default-cash-account-id
get-company --company-id (returns first if omitted)
list-companies (none)

Currency Management (5 actions)

Action Required Flags Optional Flags
add-currency --code, --name, --symbol --decimal-places (2), --enabled
list-currencies --enabled-only
add-exchange-rate --from-currency, --to-currency, --rate, --effective-date --source (manual|api|bank_feed)
get-exchange-rate --from-currency, --to-currency --effective-date (today if omitted)
list-exchange-rates --from-currency, --to-currency, --from-date, --to-date

Payment Terms (2 actions)

Action Required Flags Optional Flags
add-payment-terms --name, --due-days --discount-percentage, --discount-days, --description
list-payment-terms (none)

Units of Measure (3 actions)

Action Required Flags Optional Flags
add-uom --name --must-be-whole-number
list-uoms (none)
add-uom-conversion --from-uom, --to-uom, --conversion-factor --item-id (item-specific)

User & Role Management (9 actions)

Action Required Flags Optional Flags
create-user --username, --email --company-id
update-user --user-id --email, --status, --company-ids (JSON)
list-users --status
get-user --user-id
create-role --name --description
list-roles
assign-role --user-id, --role-id
create-permission --role-id, --resource, --action --company-id
list-permissions --role-id, --resource

System Operations (10 actions)

Action Required Flags Optional Flags
seed-defaults --company-id (none)
tutorial (none)
get-audit-log --entity-type, --entity-id, --audit-action, --from-date, --to-date, --limit (50)
get-schema-version --module
update-regional-settings --company-id --date-format, --number-format, --default-tax-template-id
backup-database --backup-path, --encrypt, --passphrase
list-backups (none)
verify-backup --backup-path --passphrase (for encrypted backups)
restore-database --backup-path --passphrase (auto-detects encrypted)
status (none)
onboarding-step --answer (user response), --reset (restart wizard)

Quick Command Reference

User Says Action
"set up my company" / "create a company" setup-company
"update company settings" update-company
"show company info" get-company
"add a currency" / "enable EUR" add-currency
"list currencies" list-currencies
"add exchange rate" / "set EUR to USD rate" add-exchange-rate
"what's the exchange rate for EUR?" get-exchange-rate
"add payment terms" / "create Net 30" add-payment-terms
"add unit of measure" / "add UoM" add-uom
"add UoM conversion" / "12 pieces = 1 dozen" add-uom-conversion
"seed default data" seed-defaults
"show audit log" get-audit-log
"backup database" / "encrypted backup" backup-database (add --encrypt --passphrase)
"list backups" / "show backups" list-backups
"verify backup" / "check backup" verify-backup
"restore database" / "restore from backup" restore-database
"ERP status" status
"tutorial" / "get me started" / "demo data" tutorial
"set up my company" / "onboarding" / "get started" onboarding-step
"create a user" / "add user" create-user
"list users" / "show users" list-users
"create a role" / "add role" create-role
"assign role to user" assign-role
"list roles" / "show roles" list-roles
"add permission" / "grant access" create-permission

Onboarding Flow

After setup-company completes, say: "Want me to seed default currencies, UoMs, and payment terms? Then we'll set up your chart of accounts."

After seed-defaults completes, say: "Defaults loaded! Next step: install the General Ledger skill (clawhub install erpclaw-gl) to set up your chart of accounts."

For a guided walkthrough, install the erpclaw meta-package: clawhub install erpclaw

Guide the user through skills in order:

Step Skill What It Unlocks
1. Setup (done) erpclaw-setup Company, currencies, payment terms, UoMs
2. Chart of Accounts erpclaw-gl Accounts, fiscal years, cost centers, GL posting
3. Inventory erpclaw-inventory Items, warehouses, stock movements
4. Selling erpclaw-selling Customers, quotes, orders, invoices
5. Buying erpclaw-buying Suppliers, purchase orders, receipts
6. Payments erpclaw-payments Payment recording, allocation, reconciliation
7. Tax erpclaw-tax Tax templates, rules, withholding
8. Reports erpclaw-reports Trial balance, P&L, balance sheet, aging
9. Analytics erpclaw-analytics KPIs, ratios, dashboards, trends

Each step builds on the previous one. The first 4 steps give a fully functional order-to-cash cycle.

Inter-Skill Coordination

This skill provides foundational data consumed by ALL other ERPClaw skills:

  • erpclaw-gl reads company for GL posting, currency for multi-currency accounts
  • erpclaw-payments reads payment_terms for due date calculation
  • erpclaw-selling / erpclaw-buying read company, currency, payment_terms
  • erpclaw-tax reads company for regional tax configuration
  • erpclaw-reports reads company for company context and currency

After creating a company, remind the user to set up the chart of accounts next (erpclaw-gl). When updating default accounts on company, validate account IDs exist in the account table.

Proactive Suggestions

After This Action Offer
initialize-database "Database ready. Shared library installed to ~/.openclaw/erpclaw/lib/. Now create your first company."
setup-company "Company created. Want me to seed default currencies, UoMs, and payment terms?"
seed-defaults "Defaults loaded! Next: install the GL skill (clawhub install erpclaw-gl) to set up your chart of accounts."
add-currency "Currency added. Want to add an exchange rate for today?"
add-payment-terms "Payment terms created. Want to add more, or move on to chart of accounts?"
backup-database "Backup saved. Recommend scheduling regular backups."
tutorial "Demo company created. Explore with other skills or start fresh with your own company."

Response Formatting

  • Use tables for lists (currencies, payment terms, UoMs)
  • Format currency amounts with appropriate symbol (e.g., $1,000.00)
  • Format dates as Mon DD, YYYY (e.g., Feb 15, 2026)
  • After company creation, show a summary card with all configured settings
  • Keep responses concise -- summarize, do not dump raw JSON

IMPORTANT: NEVER query the database with raw SQL. ALWAYS use the --action flag on db_query.py. The actions handle all necessary JOINs, validation, and formatting.

Error Recovery

Error Fix
"no such table" Run python3 ~/.openclaw/erpclaw/init_db.py --db-path ~/.openclaw/erpclaw/data.sqlite
"database is locked" Retry once after 2 seconds
Company already exists Inform user, suggest update-company
Invalid currency code Suggest standard ISO 4217 codes
Duplicate payment terms name Inform user the name already exists

Technical Details (Tier 3)

Tables owned (11): company, currency, exchange_rate, payment_terms, uom, uom_conversion, regional_settings, custom_field, property_setter, schema_version, audit_log

Shared library: This skill bundles the shared library (erpclaw_lib) and installs it to ~/.openclaw/erpclaw/lib/ during initialization. All other ERPClaw skills depend on this library.

Script: {baseDir}/scripts/db_query.py -- all actions routed through this single entry point.

Data conventions:

  • All financial amounts stored as TEXT (Python Decimal for precision)
  • All IDs are TEXT (UUID4)
  • Immutable audit_log -- no updates or deletes, append-only
  • seed-defaults is idempotent -- skips existing records

Seed data sources: {baseDir}/assets/currencies.json (160 ISO 4217 currencies), {baseDir}/assets/default_uom.json (14 UoMs), {baseDir}/assets/default_payment_terms.json (~6 terms).

Sub-Skills

Sub-Skill Shortcut What It Does
erp-setup /erp-setup Launches the first-time setup wizard
erp-status /erp-status Overall ERP status — installed skills, table counts, data health