Skip to content

Commit 8dd3b0e

Browse files
authored
Merge pull request #9 from fleetbase/dev-v0.0.4
v0.0.4
2 parents 952b92e + f5834cf commit 8dd3b0e

98 files changed

Lines changed: 4485 additions & 863 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ember.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,19 @@ on:
88
pull_request:
99
branches: [ main ]
1010

11+
env:
12+
NODE_VERSION: 22.x
13+
1114
jobs:
1215
build:
1316
runs-on: ubuntu-latest
14-
15-
strategy:
16-
matrix:
17-
node-version: [18.x] # Build on Node.js 18
18-
1917
steps:
2018
- uses: actions/checkout@v2
2119

22-
- name: Setup Node.js ${{ matrix.node-version }}
20+
- name: Setup Node.js ${{ env.NODE_VERSION }}
2321
uses: actions/setup-node@v2
2422
with:
25-
node-version: ${{ matrix.node-version }}
23+
node-version: ${{ env.NODE_VERSION }}
2624

2725
- name: Setup pnpm
2826
uses: pnpm/action-setup@v2.0.1
@@ -45,10 +43,10 @@ jobs:
4543
steps:
4644
- uses: actions/checkout@v2
4745

48-
- name: Setup Node.js 18.x
46+
- name: Setup Node.js ${{ env.NODE_VERSION }}
4947
uses: actions/setup-node@v2
5048
with:
51-
node-version: 18.x
49+
node-version: ${{ env.NODE_VERSION }}
5250

5351
- name: Setup pnpm
5452
uses: pnpm/action-setup@v2.0.1
@@ -74,10 +72,10 @@ jobs:
7472
steps:
7573
- uses: actions/checkout@v2
7674

77-
- name: Setup Node.js 18.x
75+
- name: Setup Node.js ${{ env.NODE_VERSION }}
7876
uses: actions/setup-node@v2
7977
with:
80-
node-version: 18.x
78+
node-version: ${{ env.NODE_VERSION }}
8179

8280
- name: Setup pnpm
8381
uses: pnpm/action-setup@v2.0.1

README.md

Lines changed: 208 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,262 @@
11
<p align="center">
2-
<p align="center">
3-
<img src="https://github.com/user-attachments/assets/197c404c-06b1-4fd4-8a26-624f1d481966" width="140" height="140" />
4-
</p>
5-
<p align="center">
6-
Accounting & Invoicing Extension for Fleetbase
7-
</p>
2+
<a href="https://fleetbase.io">
3+
<img src="https://github.com/user-attachments/assets/197c404c-06b1-4fd4-8a26-624f1d481966" width="120" height="120" alt="Fleetbase Ledger" />
4+
</a>
85
</p>
96

10-
---
7+
<h1 align="center">Fleetbase Ledger</h1>
8+
9+
<p align="center">
10+
Accounting, invoicing, wallets, payments, and financial reporting for Fleetbase.
11+
</p>
12+
13+
<p align="center">
14+
<a href="https://github.com/fleetbase/ledger/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue.svg" alt="License: AGPL-3.0-or-later" /></a>
15+
<a href="https://github.com/fleetbase/ledger/actions/workflows/server.yml"><img src="https://github.com/fleetbase/ledger/actions/workflows/server.yml/badge.svg" alt="PHP CI" /></a>
16+
<a href="https://github.com/fleetbase/ledger/actions/workflows/ember.yml"><img src="https://github.com/fleetbase/ledger/actions/workflows/ember.yml/badge.svg" alt="Ember CI" /></a>
17+
<a href="https://packagist.org/packages/fleetbase/ledger-api"><img src="https://img.shields.io/packagist/v/fleetbase/ledger-api.svg" alt="Packagist version" /></a>
18+
<a href="https://www.npmjs.com/package/@fleetbase/ledger-engine"><img src="https://img.shields.io/npm/v/@fleetbase/ledger-engine.svg" alt="npm version" /></a>
19+
<a href="https://www.fleetbase.io/docs/ledger"><img src="https://img.shields.io/badge/docs-ledger-111827.svg" alt="Ledger documentation" /></a>
20+
</p>
21+
22+
<p align="center">
23+
<a href="https://www.fleetbase.io/images/screenshots/ledger/ledger-dashboard.webp">
24+
<img src="https://www.fleetbase.io/images/screenshots/ledger/ledger-dashboard.webp" alt="Fleetbase Ledger dashboard" />
25+
</a>
26+
</p>
1127

1228
## Overview
1329

14-
This monorepo contains both the frontend and backend components of the Ledger extension for Fleetbase. The frontend is built using Ember.js and the backend is implemented in PHP.
30+
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.
1531

16-
* PHP 7.3.0 or above
17-
* Ember.js v4.8 or above
18-
* Ember CLI v4.8 or above
19-
* Node.js v18 or above
32+
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.
2033

21-
## Structure
34+
Ledger is included with standard Fleetbase installations. See the [Fleetbase Ledger documentation](https://www.fleetbase.io/docs/ledger) for the product guide, concepts, and setup walkthroughs.
2235

23-
```
24-
├── addon
25-
├── app
26-
├── assets
27-
├── translations
28-
├── config
29-
├── node_modules
30-
├── server
31-
│ ├── config
32-
│ ├── data
33-
│ ├── migrations
34-
│ ├── resources
35-
│ ├── src
36-
│ ├── tests
37-
│ └── vendor
38-
├── tests
39-
├── testem.js
40-
├── index.js
41-
├── package.json
42-
├── phpstan.neon.dist
43-
├── phpunit.xml.dist
44-
├── pnpm-lock.yaml
45-
├── ember-cli-build.js
46-
├── composer.json
47-
├── CONTRIBUTING.md
48-
├── LICENSE.md
49-
├── README.md
50-
```
36+
## Contents
37+
38+
- [Features](#features)
39+
- [Architecture](#architecture)
40+
- [Requirements](#requirements)
41+
- [Installation](#installation)
42+
- [Development](#development)
43+
- [API and Extension Points](#api-and-extension-points)
44+
- [Documentation](#documentation)
45+
- [Contributing](#contributing)
46+
- [Security](#security)
47+
- [License](#license)
48+
49+
## Features
50+
51+
### Accounting
52+
53+
- Chart of accounts for asset, liability, equity, revenue, and expense accounts.
54+
- Double-entry journal entries with debit and credit accounts.
55+
- Cached account balances with recalculation support.
56+
- General ledger views per account and across the company.
57+
- System-created and manual journal entries for operational accounting workflows.
58+
59+
### Billing and Invoicing
60+
61+
- Customer invoices with line items, tax, subtotal, total, balance, due date, notes, and terms.
62+
- Invoice lifecycle support for draft, sent, viewed, paid, overdue, cancelled, refunded, and void states.
63+
- Invoice templates with company branding and registered template context variables.
64+
- Invoice previews, rendered PDFs, invoice emails, and public customer invoice pages.
65+
- Manual payment recording and invoice transaction history.
66+
- Fleet-Ops purchase-rate integration for automatically generating draft invoices from orders.
67+
68+
### Wallets and Transactions
69+
70+
- Digital wallets for companies, users, customers, drivers, and other Fleetbase subjects.
71+
- Wallet operations for top-ups, credits, transfers, payouts, freezes, unfreezes, and recalculation.
72+
- Atomic balance changes through `WalletService`.
73+
- Immutable transaction records for wallet activity, payment activity, and operational money movement.
74+
- Direction-aware transaction history for credits, debits, deposits, payouts, transfers, refunds, and reversals.
75+
76+
### Payment Gateways
77+
78+
- Built-in gateway drivers for Stripe, QPay, and Cash/manual payments.
79+
- Gateway configuration with encrypted credentials at rest.
80+
- Sandbox and live environments.
81+
- Purchases, refunds, setup intents, tokenization where supported, and gateway transaction history.
82+
- Public gateway webhook endpoint with driver-level signature verification.
83+
- Idempotent gateway processing through `GatewayTransaction` records.
84+
85+
### Reports and Dashboard
86+
87+
- Financial dashboard with KPIs, revenue trends, cash flow summaries, invoice status, AR aging, wallet balances, and activity.
88+
- Standard financial reports for balance sheet, income statement, cash flow statement, trial balance, AR aging, wallet summary, and general ledger.
89+
- Report services built around double-entry accounting data and Fleetbase transaction records.
90+
91+
### Fleetbase Integrations
92+
93+
- Fleet-Ops integration for purchase-rate invoice creation and order accounting.
94+
- Storefront integration for direct storefront sale journal entries.
95+
- Company and user observers that provision default accounts and wallets automatically.
96+
- Invoice, payment, and accounting settings inside the Fleetbase console.
97+
98+
## Architecture
99+
100+
Ledger is split into two distributable packages:
101+
102+
| Package | Runtime | Description |
103+
| --- | --- | --- |
104+
| [`fleetbase/ledger-api`](https://packagist.org/packages/fleetbase/ledger-api) | Laravel / PHP | Backend models, routes, services, migrations, gateway drivers, observers, events, resources, reports, and console commands. |
105+
| [`@fleetbase/ledger-engine`](https://www.npmjs.com/package/@fleetbase/ledger-engine) | Ember | Fleetbase console engine for the Ledger dashboard, billing, payments, accounting, reports, and settings screens. |
106+
107+
Backend routes are mounted under the configured Ledger API prefix, which defaults to `ledger`.
108+
109+
| Route group | Authentication | Purpose |
110+
| --- | --- | --- |
111+
| `POST /ledger/webhooks/{driver}` | Public, driver verified | Payment gateway webhook callbacks. |
112+
| `/ledger/public/invoices/{public_id}` | Public | Customer invoice view, gateway list, and payment flow. |
113+
| `/ledger/v1/wallet/*` | API key | Customer and driver wallet API endpoints. |
114+
| `/ledger/int/v1/*` | Fleetbase session | Console APIs for accounts, invoices, journals, wallets, transactions, gateways, settings, and reports. |
115+
116+
The Ember engine mounts at the Fleetbase extension route `ledger` and exposes console sections for billing, payments, accounting, reports, and settings.
117+
118+
## Requirements
119+
120+
- PHP `^8.0`
121+
- Composer
122+
- Fleetbase Core API
123+
- Fleetbase FleetOps API
124+
- Node.js `>=18`
125+
- pnpm
126+
- Ember CLI compatible with the workspace
51127

52128
## Installation
53129

54-
### Backend
130+
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.
55131

56-
Install the PHP packages using Composer:
132+
For package-level installation:
57133

58134
```bash
59-
composer require fleetbase/core-api
60-
composer require fleetbase/fleetops-api
61135
composer require fleetbase/ledger-api
62136
```
63-
### Frontend
64-
65-
Install the Ember.js Engine/Addon:
66137

67138
```bash
68139
pnpm install @fleetbase/ledger-engine
69140
```
70141

71-
## Usage
142+
If you are adding Ledger to an existing Fleetbase installation, run migrations through your normal Fleetbase deployment flow, then provision defaults for existing records:
143+
144+
```bash
145+
php artisan ledger:provision
146+
```
147+
148+
## Development
149+
150+
### Fleetbase workspace linking
72151

73-
### Backend
152+
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`.
153+
154+
Install the linker once from the Fleetbase repository root:
74155

75-
🧹 Keep a modern codebase with **PHP CS Fixer**:
76156
```bash
77-
composer lint
157+
npm link
78158
```
79159

80-
⚗️ Run static analysis using **PHPStan**:
160+
Enable Ledger as a local development package:
161+
81162
```bash
82-
composer test:types
163+
flb-package-linker enable ledger
164+
flb-package-linker install ledger
83165
```
84166

85-
✅ Run unit tests using **PEST**
167+
Use `--install` to let the linker run the required package-manager commands immediately:
168+
86169
```bash
87-
composer test:unit
170+
flb-package-linker enable ledger --install
88171
```
89172

90-
🚀 Run the entire test suite:
173+
Check link state with:
174+
91175
```bash
92-
composer test
176+
flb-package-linker status
177+
flb-package-linker doctor
93178
```
94179

95-
### Frontend
180+
See the [Fleetbase development setup guide](https://www.fleetbase.io/docs/platform/quickstart/development-setup) 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:
96181

97-
🧹 Keep a modern codebase with **ESLint**:
98182
```bash
99-
pnpm lint
183+
docker compose exec application php artisan octane:reload
100184
```
101185

102-
✅ Run unit tests using **Ember/QUnit**
186+
### Package-level development
187+
188+
Install dependencies:
189+
103190
```bash
104-
pnpm test
105-
pnpm test:ember
106-
pnpm test:ember-compatibility
191+
composer install
192+
pnpm install
107193
```
108194

109-
🚀 Start the Ember Addon/Engine
195+
Run the Ember engine locally:
196+
110197
```bash
111198
pnpm start
112199
```
113200

114-
🔨 Build the Ember Addon/Engine
201+
Frontend checks:
202+
115203
```bash
204+
pnpm lint
205+
pnpm test
116206
pnpm build
117207
```
118208

209+
Backend checks:
210+
211+
```bash
212+
composer test:lint
213+
composer test:types
214+
composer test:unit
215+
composer test
216+
```
217+
218+
Ledger Artisan commands:
219+
220+
```bash
221+
php artisan ledger:provision
222+
php artisan ledger:backfill-direction
223+
php artisan ledger:update-overdue-invoices
224+
```
225+
226+
`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.
227+
228+
## API and Extension Points
229+
230+
Ledger exposes backend services for accounting, wallets, invoices, and payments:
231+
232+
- `LedgerService` creates double-entry journal entries and powers financial reports.
233+
- `WalletService` manages wallet provisioning and balance-changing operations.
234+
- `InvoiceService` creates and manages invoices, including order-based invoice creation.
235+
- `PaymentService` coordinates gateway charges, refunds, setup intents, events, and gateway transaction persistence.
236+
- `PaymentGatewayManager` resolves and initializes configured payment gateway drivers.
237+
238+
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.
239+
240+
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.
241+
242+
## Documentation
243+
244+
- [Ledger documentation](https://www.fleetbase.io/docs/ledger)
245+
- [Core concepts](https://www.fleetbase.io/docs/ledger/getting-started/core-concepts)
246+
- [Payment gateways](https://www.fleetbase.io/docs/ledger/payments/gateways)
247+
- [Adding a payment gateway driver](https://www.fleetbase.io/docs/extension-development/recipes/adding-a-payment-gateway-driver)
248+
- [Fleetbase development setup](https://www.fleetbase.io/docs/platform/quickstart/development-setup)
249+
119250
## Contributing
120-
See the Contributing Guide for details on how to contribute to this project.
251+
252+
Contributions are welcome. Please read the [contributing guide](CONTRIBUTING.md) before opening a pull request.
253+
254+
For local changes, keep frontend and backend checks focused on the area you touched and include relevant test output in your pull request.
255+
256+
## Security
257+
258+
Please do not report security issues in public GitHub issues. Contact Fleetbase at [hello@fleetbase.io](mailto:hello@fleetbase.io) with details so the team can coordinate a responsible fix.
121259

122260
## License
123-
This project is licensed under the MIT License.
261+
262+
Fleetbase Ledger is open-source software licensed under the [AGPL-3.0-or-later](LICENSE.md).

0 commit comments

Comments
 (0)