@getpeppr/cli 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @getpeppr/cli
2
2
 
3
- The first Peppol e-invoice validator on npm. Validate invoices offline against Peppol BIS 3.0 business rules, structure checks, and country-specific requirements.
3
+ Developer toolkit for Peppol e-invoicing. Scaffold invoices, validate against Peppol BIS 3.0, convert to UBL XML, and look up participants in the Peppol Directory — all from the command line.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,12 +10,27 @@ npx @getpeppr/cli validate invoice.json
10
10
 
11
11
  # Or install globally
12
12
  npm install -g @getpeppr/cli
13
- getpeppr validate invoice.json
13
+ getpeppr --help
14
14
  ```
15
15
 
16
- ## Usage
16
+ ## Commands
17
+
18
+ ### `getpeppr init` — Scaffold an invoice
17
19
 
18
- ### Validate an invoice
20
+ Generate a starter JSON file with all required fields pre-filled:
21
+
22
+ ```bash
23
+ getpeppr init # creates invoice.json
24
+ getpeppr init my-invoice.json # custom filename
25
+ getpeppr init --credit-note # credit note template
26
+ getpeppr init --force # overwrite existing file
27
+ ```
28
+
29
+ The generated template includes a Belgian seller, a German buyer, and two invoice lines — ready to edit and validate.
30
+
31
+ ### `getpeppr validate` — Validate an invoice
32
+
33
+ Run offline validation against Peppol BIS 3.0 business rules:
19
34
 
20
35
  ```bash
21
36
  getpeppr validate invoice.json
@@ -39,47 +54,69 @@ Validating: invoice.json
39
54
  ✓ Invoice is valid (1 warning)
40
55
  ```
41
56
 
42
- ### Flags
43
-
44
57
  | Flag | Description |
45
58
  |------|-------------|
46
59
  | `--json` | Machine-readable JSON output |
47
60
  | `--quiet` | Exit code only, no output |
48
- | `--version` | Show version number |
49
- | `--help` | Show help |
50
61
 
51
- ### Exit codes
62
+ ### `getpeppr convert` — Convert to UBL XML
52
63
 
53
- | Code | Meaning |
54
- |------|---------|
55
- | `0` | Invoice is valid (may have warnings) |
56
- | `1` | Invoice has errors — non-compliant |
57
- | `2` | File not found or invalid JSON |
58
-
59
- ### JSON output
64
+ Convert a getpeppr JSON invoice to Peppol BIS 3.0 UBL 2.1 XML:
60
65
 
61
66
  ```bash
62
- getpeppr validate invoice.json --json
67
+ getpeppr convert invoice.json # XML to stdout
68
+ getpeppr convert invoice.json -o invoice.xml # write to file
69
+ getpeppr convert invoice.json --validate # validate first, convert only if valid
63
70
  ```
64
71
 
65
- Returns a structured result with errors and warnings grouped by category:
72
+ Automatically detects credit notes (`"isCreditNote": true`) and produces the correct UBL CreditNote document.
66
73
 
67
- ```json
68
- {
69
- "structure": { "errors": [], "warnings": [] },
70
- "schematron": { "errors": [], "warnings": [] },
71
- "countryRules": { "errors": [], "warnings": [] },
72
- "totalErrors": 0,
73
- "totalWarnings": 1,
74
- "valid": true
75
- }
74
+ | Flag | Description |
75
+ |------|-------------|
76
+ | `-o, --output <file>` | Write XML to file instead of stdout |
77
+ | `--validate` | Validate before converting (errors block conversion) |
78
+
79
+ ### `getpeppr lookup` — Peppol Directory search
80
+
81
+ Look up any participant registered on the Peppol network:
82
+
83
+ ```bash
84
+ # Direct lookup by Peppol ID
85
+ getpeppr lookup 0208:BE0685660237
86
+
87
+ # Search by company name
88
+ getpeppr lookup --name "Dupont"
89
+
90
+ # Filter by country
91
+ getpeppr lookup --name "GmbH" --country DE
92
+
93
+ # JSON output
94
+ getpeppr lookup 0208:BE0685660237 --json
76
95
  ```
77
96
 
78
- ### CI/CD integration
97
+ | Flag | Description |
98
+ |------|-------------|
99
+ | `--name <name>` | Search by company name (min 3 characters) |
100
+ | `--country <code>` | Filter by ISO 2-letter country code |
101
+ | `--json` | Output results as JSON |
102
+ | `--limit <n>` | Max results for search (default: 10) |
103
+
104
+ ## Exit codes
105
+
106
+ | Code | Meaning |
107
+ |------|---------|
108
+ | `0` | Success (valid invoice, participant found, conversion OK) |
109
+ | `1` | Failure (invalid invoice, participant not found) |
110
+ | `2` | Input error (file not found, invalid JSON, bad arguments) |
111
+
112
+ ## CI/CD integration
79
113
 
80
114
  ```bash
81
115
  # Fail pipeline if invoice is invalid
82
116
  getpeppr validate invoice.json --quiet || exit 1
117
+
118
+ # Validate + convert in one step
119
+ getpeppr convert invoice.json --validate -o output.xml
83
120
  ```
84
121
 
85
122
  ## What it validates
@@ -90,7 +127,7 @@ The CLI runs three validation engines from the [@getpeppr/sdk](https://www.npmjs
90
127
  2. **Business Rules** — Peppol BIS 3.0 / EN 16931 compliance (BR-xx, BR-CO-xx, PEPPOL-xx rules)
91
128
  3. **Country Rules** — Belgium (BE), France (FR), Italy (IT), Netherlands (NL), Germany (DE)
92
129
 
93
- All validation runs offline — no API key or network connection required.
130
+ Validation runs offline — no API key or network connection required. Only `lookup` needs an internet connection.
94
131
 
95
132
  ## Invoice format
96
133
 
@@ -99,30 +136,47 @@ The input file must be a JSON object matching the getpeppr `InvoiceInput` type:
99
136
  ```json
100
137
  {
101
138
  "number": "INV-2026-001",
102
- "date": "2026-04-07",
103
- "dueDate": "2026-05-07",
139
+ "date": "2026-01-15",
140
+ "dueDate": "2026-02-15",
104
141
  "currency": "EUR",
105
- "buyerReference": "PO-12345",
106
- "to": {
107
- "name": "Buyer Company",
142
+ "buyerReference": "PO-2026-042",
143
+ "from": {
144
+ "name": "Dupont & Fils SPRL",
108
145
  "peppolId": "0208:BE0123456789",
109
- "street": "123 Main St",
110
- "city": "Brussels",
146
+ "street": "Avenue Louise 54",
147
+ "city": "Bruxelles",
111
148
  "postalCode": "1050",
112
149
  "country": "BE"
113
150
  },
151
+ "to": {
152
+ "name": "Müller & Partner GmbH",
153
+ "peppolId": "0204:DE987654321",
154
+ "street": "Friedrichstraße 123",
155
+ "city": "Berlin",
156
+ "postalCode": "10117",
157
+ "country": "DE"
158
+ },
114
159
  "lines": [
115
160
  {
116
- "description": "Consulting services",
161
+ "description": "Conseil en transformation numérique",
117
162
  "quantity": 10,
118
- "unitPrice": 150,
163
+ "unitPrice": 950,
119
164
  "vatRate": 21
165
+ },
166
+ {
167
+ "description": "Software license — annual subscription",
168
+ "quantity": 1,
169
+ "unitPrice": 2400,
170
+ "vatRate": 0,
171
+ "vatCategory": "AE"
120
172
  }
121
- ]
173
+ ],
174
+ "paymentTerms": "Net 30 days",
175
+ "paymentReference": "+++000/0000/00097+++"
122
176
  }
123
177
  ```
124
178
 
125
- See the [full type reference](https://getpeppr.dev/docs/types/) for all available fields.
179
+ This is the exact template generated by `getpeppr init`. See the [full type reference](https://getpeppr.dev/docs/types/) for all available fields.
126
180
 
127
181
  ## Ready to send?
128
182