@fleetbase/ledger-engine

中文文档
0.0.13发布于 2026/10/14AGPL-3.0-or-later近 30 天下载 2428

Accounting & Invoicing Extension for Fleetbase

原始使用文档
文档目录20 节
  1. Overview
  2. Contents
  3. Features
  4. Accounting
  5. Billing and Invoicing
  6. Wallets and Transactions
  7. Payment Gateways
  8. Reports and Dashboard
  9. Fleetbase Integrations
  10. Architecture
  11. Requirements
  12. Installation
  13. Development
  14. Fleetbase workspace linking
  15. Package-level development
  16. API and Extension Points
  17. Documentation
  18. Contributing
  19. Security
  20. License

Fleetbase Ledger

Fleetbase Ledger

Accounting, invoicing, wallets, payments, and financial reporting for Fleetbase.

License: AGPL-3.0-or-later PHP CI Ember CI Coverage Packagist version npm version Ledger documentation

Fleetbase Ledger dashboard

Overview

Ledger is the finance and billing extension for Fleetbase. It adds a complete financial management layer to the Fleetbase console, including double-entry bookkeeping, customer invoicing, invoice templates, digital wallets, payment gateway processing, immutable transaction history, and standard financial reports.

Ledger ships as both a Laravel package and an Ember engine. The backend package provides the accounting models, services, routes, gateway drivers, events, observers, migrations, and console commands. The frontend engine provides the Ledger console experience for billing, payments, accounting, reports, and settings.

Ledger is included with standard Fleetbase installations. See the Fleetbase Ledger documentation for the product guide, concepts, and setup walkthroughs.

Contents

Features

Accounting

  • Chart of accounts for asset, liability, equity, revenue, and expense accounts.
  • Double-entry journal entries with debit and credit accounts.
  • Cached account balances with recalculation support.
  • General ledger views per account and across the company.
  • System-created and manual journal entries for operational accounting workflows.

Billing and Invoicing

  • Customer invoices with line items, tax, subtotal, total, balance, due date, notes, and terms.
  • Invoice lifecycle support for draft, sent, viewed, paid, overdue, cancelled, refunded, and void states.
  • Invoice templates with company branding and registered template context variables.
  • Invoice previews, rendered PDFs, invoice emails, and public customer invoice pages.
  • Manual payment recording and invoice transaction history.
  • Fleet-Ops purchase-rate integration for automatically generating draft invoices from orders.

Wallets and Transactions

  • Digital wallets for companies, users, customers, drivers, and other Fleetbase subjects.
  • Wallet operations for top-ups, credits, transfers, payouts, freezes, unfreezes, and recalculation.
  • Atomic balance changes through WalletService.
  • Immutable transaction records for wallet activity, payment activity, and operational money movement.
  • Direction-aware transaction history for credits, debits, deposits, payouts, transfers, refunds, and reversals.

Payment Gateways

  • Built-in gateway drivers for Stripe, QPay, and Cash/manual payments.
  • Gateway configuration with encrypted credentials at rest.
  • Sandbox and live environments.
  • Purchases, refunds, setup intents, tokenization where supported, and gateway transaction history.
  • Public gateway webhook endpoint with driver-level signature verification.
  • Idempotent gateway processing through GatewayTransaction records.

Reports and Dashboard

  • Financial dashboard with KPIs, revenue trends, cash flow summaries, invoice status, AR aging, wallet balances, and activity.
  • Standard financial reports for balance sheet, income statement, cash flow statement, trial balance, AR aging, wallet summary, and general ledger.
  • Report services built around double-entry accounting data and Fleetbase transaction records.

Fleetbase Integrations

  • Fleet-Ops integration for purchase-rate invoice creation and order accounting.
  • Storefront integration for direct storefront sale journal entries.
  • Company and user observers that provision default accounts and wallets automatically.
  • Invoice, payment, and accounting settings inside the Fleetbase console.

Architecture

Ledger is split into two distributable packages:

PackageRuntimeDescription
fleetbase/ledger-apiLaravel / PHPBackend models, routes, services, migrations, gateway drivers, observers, events, resources, reports, and console commands.
@fleetbase/ledger-engineEmberFleetbase console engine for the Ledger dashboard, billing, payments, accounting, reports, and settings screens.

Backend routes are mounted under the configured Ledger API prefix, which defaults to ledger.

Route groupAuthenticationPurpose
POST /ledger/webhooks/{driver}Public, driver verifiedPayment gateway webhook callbacks.
/ledger/public/invoices/{public_id}PublicCustomer invoice view, gateway list, and payment flow.
/ledger/v1/wallet/*API keyCustomer and driver wallet API endpoints.
/ledger/int/v1/*Fleetbase sessionConsole APIs for accounts, invoices, journals, wallets, transactions, gateways, settings, and reports.

The Ember engine mounts at the Fleetbase extension route ledger and exposes console sections for billing, payments, accounting, reports, and settings.

Requirements

  • PHP ^8.0
  • Composer
  • Fleetbase Core API
  • Fleetbase FleetOps API
  • Node.js >=18
  • pnpm
  • Ember CLI compatible with the workspace

Installation

Ledger comes pre-installed with Fleetbase. In a standard Fleetbase instance, open the console sidebar and navigate to Ledger to begin. Default accounts and wallets are provisioned automatically for new companies and users.

For package-level installation:

composer require fleetbase/ledger-api
pnpm install @fleetbase/ledger-engine

If you are adding Ledger to an existing Fleetbase installation, run migrations through your normal Fleetbase deployment flow, then provision defaults for existing records:

php artisan ledger:provision

Development

Fleetbase workspace linking

When working on Ledger inside a full Fleetbase checkout, use Fleetbase's package linker from the repository root instead of hand-editing console/package.json, api/composer.json, or console/pnpm-workspace.yaml.

Install the linker once from the Fleetbase repository root:

npm link

Enable Ledger as a local development package:

flb-package-linker enable ledger
flb-package-linker install ledger

Use --install to let the linker run the required package-manager commands immediately:

flb-package-linker enable ledger --install

Check link state with:

flb-package-linker status
flb-package-linker doctor

See the Fleetbase development setup guide for Docker mounts, local Ember dev server setup, package-linker details, and unlink/reset commands. Fleetbase runs Laravel Octane, so reload the API worker after PHP changes:

docker compose exec application php artisan octane:reload

Package-level development

Install dependencies:

composer install
pnpm install

Run the Ember engine locally:

pnpm start

Frontend checks:

pnpm lint
pnpm test
pnpm build

Backend checks:

composer test:lint
composer test:types
composer test:unit
composer test

Ledger Artisan commands:

php artisan ledger:provision
php artisan ledger:backfill-direction
php artisan ledger:update-overdue-invoices

ledger:provision is idempotent and can target all companies, one company, accounts only, or wallets only. ledger:backfill-direction fills missing transaction directions on older transaction rows. ledger:update-overdue-invoices marks sent or viewed invoices as overdue when their due date has passed.

API and Extension Points

Ledger exposes backend services for accounting, wallets, invoices, and payments:

  • LedgerService creates double-entry journal entries and powers financial reports.
  • WalletService manages wallet provisioning and balance-changing operations.
  • InvoiceService creates and manages invoices, including order-based invoice creation.
  • PaymentService coordinates gateway charges, refunds, setup intents, events, and gateway transaction persistence.
  • PaymentGatewayManager resolves and initializes configured payment gateway drivers.

Custom payment gateways can extend AbstractGatewayDriver and implement the GatewayDriverInterface contract. Gateway drivers provide a code, name, capability list, configuration schema, purchase/refund behavior, and optional webhook or tokenization support.

Ledger also registers invoice template context variables with Fleetbase's template rendering system so invoice templates can reference invoice, transaction, account, and wallet data during rendering.

Documentation

Contributing

Contributions are welcome. Please read the contributing guide before opening a pull request.

For local changes, keep frontend and backend checks focused on the area you touched and include relevant test output in your pull request.

Security

Please do not report security issues in public GitHub issues. Contact Fleetbase at [email protected] with details so the team can coordinate a responsible fix.

License

Fleetbase Ledger is open-source software licensed under the AGPL-3.0-or-later.

版本与发布记录

@fleetbase/ledger-engine 共发布 13 个版本,首次发布于 2026/03/26;过去 12 个月发布了 13 个版本。

版本发布日期距今
0.0.13latest2026/10/141 个月前
0.0.122026/10/051 个月前
0.0.112026/09/281 个月前
0.0.102026/08/172 个月前
0.0.92026/08/073 个月前
0.0.82026/07/173 个月前

关于 @fleetbase/ledger-engine 的常见问题

@fleetbase/ledger-engine 是什么?

Accounting & Invoicing Extension for Fleetbase

如何安装 @fleetbase/ledger-engine?

在项目目录运行 npm install @fleetbase/ledger-engine,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ember-engines(^0.9.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fleetbase/ledger-engine 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fleetbase__ledger-engine 是否存在。

@fleetbase/ledger-engine 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@fleetbase/ledger-engine 可以商用吗?

@fleetbase/ledger-engine 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@fleetbase/ledger-engine 的下载量有多少?

根据 npm 官方下载统计,@fleetbase/ledger-engine 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,428 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fleetbase/ledger-engine 还在维护吗?

最新版本 0.0.13 发布于 2026/10/14(1 个月前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/03/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。