@ktmcp-cli/billingo 1.0.0 → 1.0.1

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/AGENT.md CHANGED
@@ -1,447 +1,177 @@
1
- # Billingo CLI - AI Agent Usage Guide
1
+ # AGENT.md — Billingo API CLI for AI Agents
2
2
 
3
- This guide is designed for AI agents (like Claude, GPT-4, etc.) to effectively use the Billingo CLI.
3
+ This document explains how to use the Billingo API CLI as an AI agent.
4
4
 
5
- ## Quick Start for Agents
5
+ ## Overview
6
6
 
7
- ### 1. Configuration Check
7
+ The `billingohu` CLI provides access to the Billingo invoicing and accounting API for Hungarian businesses. Use it to manage invoices, partners, products, and bank accounts.
8
8
 
9
- Before making any API calls, verify the API key is configured:
9
+ ## Prerequisites
10
10
 
11
- ```bash
12
- billingo config get apiKey
13
- ```
14
-
15
- If not set, configure it:
11
+ The CLI must be configured with an API key before use:
16
12
 
17
13
  ```bash
18
- billingo config set apiKey YOUR_API_KEY
14
+ billingohu config set --api-key <key>
19
15
  ```
20
16
 
21
- ### 2. Common Workflows
22
-
23
- #### Create and Send an Invoice
24
-
25
- ```bash
26
- # Step 1: Create invoice from JSON
27
- billingo documents create --file invoice.json
28
-
29
- # Step 2: Get the document ID from response (e.g., 789)
17
+ ## All Commands
30
18
 
31
- # Step 3: Download PDF
32
- billingo documents download 789 --output invoice-789.pdf
33
-
34
- # Step 4: Send to customer
35
- billingo documents send 789 --emails "customer@example.com"
36
- ```
37
-
38
- #### List Recent Unpaid Invoices
19
+ ### Config
39
20
 
40
21
  ```bash
41
- billingo documents list \
42
- --payment-status unpaid \
43
- --start-date 2024-01-01 \
44
- --per-page 50 \
45
- --format json
22
+ billingohu config set --api-key <key>
23
+ billingohu config show
46
24
  ```
47
25
 
48
- #### Create Partner and Product, Then Invoice
26
+ ### Invoices
49
27
 
50
28
  ```bash
51
- # Step 1: Create partner
52
- billingo partners create --data '{
53
- "name": "New Customer Ltd.",
54
- "address": {
55
- "country_code": "HU",
56
- "post_code": "1234",
57
- "city": "Budapest",
58
- "address": "Main St 1"
59
- },
60
- "emails": ["customer@example.com"]
61
- }'
62
-
63
- # Step 2: Get partner ID from response (e.g., 456)
64
-
65
- # Step 3: Create document with partner
66
- billingo documents create --file invoice.json
67
- # (invoice.json must include "partner_id": 456)
68
- ```
29
+ # List invoices
30
+ billingohu invoices list
31
+ billingohu invoices list --page 2 --per-page 50
32
+ billingohu invoices list --type invoice --payment-method transfer
69
33
 
70
- ## Output Parsing
34
+ # Get invoice
35
+ billingohu invoices get <invoice-id>
71
36
 
72
- ### JSON Format (Recommended for Agents)
37
+ # Create invoice
38
+ billingohu invoices create --data '{...}'
73
39
 
74
- Always use `--format json` when you need to parse the output programmatically:
40
+ # Send invoice
41
+ billingohu invoices send <invoice-id> --emails "client@example.com,billing@example.com"
75
42
 
76
- ```bash
77
- billingo documents list --format json
43
+ # Delete invoice
44
+ billingohu invoices delete <invoice-id>
78
45
  ```
79
46
 
80
- This returns structured JSON that's easy to parse:
81
-
82
- ```json
83
- {
84
- "data": [
85
- {
86
- "id": 123,
87
- "invoice_number": "INV-2024-001",
88
- "partner_name": "Customer Name",
89
- "total_gross": 127000,
90
- "currency": "HUF",
91
- "payment_status": "paid"
92
- }
93
- ],
94
- "current_page": 1,
95
- "total": 42
96
- }
97
- ```
98
-
99
- ### Pretty Format (Human-Readable)
100
-
101
- Default format is good for displaying to users:
47
+ ### Partners
102
48
 
103
49
  ```bash
104
- billingo documents get 789
105
- # Returns nicely formatted output for humans
106
- ```
50
+ # List partners
51
+ billingohu partners list
52
+ billingohu partners list --page 1 --per-page 25
107
53
 
108
- ## Data Input Methods
54
+ # Get partner
55
+ billingohu partners get <partner-id>
109
56
 
110
- ### Method 1: File-Based (Recommended for Complex Data)
57
+ # Create partner
58
+ billingohu partners create --data '{"name":"Company","email":"contact@example.com"}'
111
59
 
112
- ```bash
113
- # Save data to file
114
- cat > invoice.json << 'EOF'
115
- {
116
- "vendor_id": 1,
117
- "partner_id": 123,
118
- "block_id": 1,
119
- "type": "invoice",
120
- "fulfillment_date": "2024-01-15",
121
- "due_date": "2024-01-30",
122
- "payment_method": "transfer",
123
- "language": "hu",
124
- "currency": "HUF",
125
- "items": [
126
- {
127
- "name": "Service",
128
- "unit_price": 50000,
129
- "quantity": 10,
130
- "unit": "hour",
131
- "vat": "27%"
132
- }
133
- ]
134
- }
135
- EOF
60
+ # Update partner
61
+ billingohu partners update <partner-id> --data '{...}'
136
62
 
137
- # Use the file
138
- billingo documents create --file invoice.json
63
+ # Delete partner
64
+ billingohu partners delete <partner-id>
139
65
  ```
140
66
 
141
- ### Method 2: Inline JSON (For Simple Data)
67
+ ### Products
142
68
 
143
69
  ```bash
144
- billingo partners create --data '{"name":"Quick Partner","emails":["test@example.com"]}'
145
- ```
70
+ # List products
71
+ billingohu products list
146
72
 
147
- ## Error Handling for Agents
73
+ # Get product
74
+ billingohu products get <product-id>
148
75
 
149
- ### Check Exit Codes
76
+ # Create product
77
+ billingohu products create --data '{"name":"Service","net_unit_price":10000,"currency":"HUF"}'
150
78
 
151
- The CLI uses standard exit codes:
152
- - `0` - Success
153
- - `1` - Error (check stderr for details)
79
+ # Update product
80
+ billingohu products update <product-id> --data '{...}'
154
81
 
155
- Example in bash:
156
-
157
- ```bash
158
- if billingo documents get 789 --format json > document.json; then
159
- echo "Success"
160
- else
161
- echo "Failed with exit code $?"
162
- fi
82
+ # Delete product
83
+ billingohu products delete <product-id>
163
84
  ```
164
85
 
165
- ### Common Error Patterns
86
+ ### Bank Accounts
166
87
 
167
- **API Key Not Configured:**
168
- ```
169
- Error: API key not configured. Set it with: billingo config set apiKey <your-api-key>
170
- ```
88
+ ```bash
89
+ # List bank accounts
90
+ billingohu bank-accounts list
171
91
 
172
- **Resource Not Found:**
173
- ```
174
- Error: Resource not found.
175
- ```
92
+ # Get bank account
93
+ billingohu bank-accounts get <account-id>
176
94
 
177
- **Validation Error:**
178
- ```
179
- Error: Validation error: {"field":"partner_id","message":"required"}
95
+ # Create bank account
96
+ billingohu bank-accounts create --data '{...}'
180
97
  ```
181
98
 
182
- **Rate Limit:**
183
- ```
184
- Error: Rate limit exceeded. Retry after 60 seconds.
185
- ```
99
+ ### Organization
186
100
 
187
- ### Handling Rate Limits
101
+ ```bash
102
+ # Show organization
103
+ billingohu organization show
188
104
 
189
- Monitor warnings in stderr:
190
- ```
191
- Warning: Only 5/60 API calls remaining in this window
105
+ # List currencies
106
+ billingohu organization currencies
192
107
  ```
193
108
 
194
- Implement exponential backoff:
195
- 1. Wait 1 second, retry
196
- 2. Wait 2 seconds, retry
197
- 3. Wait 4 seconds, retry
198
- 4. etc.
199
-
200
- ## Pagination Best Practices
109
+ ## JSON Output
201
110
 
202
- When listing resources, handle pagination properly:
111
+ All commands support `--json` for structured output. Always use `--json` when parsing results programmatically:
203
112
 
204
113
  ```bash
205
- # Get first page
206
- billingo documents list --page 1 --per-page 25 --format json > page1.json
207
-
208
- # Check if more pages exist (look at "last_page" field)
209
-
210
- # Get next page
211
- billingo documents list --page 2 --per-page 25 --format json > page2.json
212
- ```
213
-
214
- Response includes pagination metadata:
215
- ```json
216
- {
217
- "data": [...],
218
- "current_page": 1,
219
- "last_page": 5,
220
- "per_page": 25,
221
- "total": 120,
222
- "next_page_url": "...",
223
- "prev_page_url": null
224
- }
114
+ billingohu invoices list --json
115
+ billingohu partners get <id> --json
116
+ billingohu products list --json
225
117
  ```
226
118
 
227
- ## Resource ID Management
228
-
229
- ### Getting IDs from Create Operations
119
+ ## Example Workflows
230
120
 
231
- When you create a resource, the response includes its ID:
121
+ ### Create and send invoice
232
122
 
233
123
  ```bash
234
- billingo partners create --file partner.json --format json
235
- # Response: {"id": 456, "name": "...", ...}
236
- ```
237
-
238
- Extract the ID (example with jq):
239
- ```bash
240
- ID=$(billingo partners create --file partner.json --format json | jq -r '.id')
241
- echo "Created partner with ID: $ID"
242
- ```
243
-
244
- ### Converting Legacy IDs
124
+ # Create partner first
125
+ PARTNER_ID=$(billingohu partners create \
126
+ --data '{"name":"Client Name","email":"client@example.com"}' \
127
+ --json | jq -r '.id')
245
128
 
246
- If you have IDs from Billingo API v2:
129
+ # Create invoice
130
+ INVOICE_ID=$(billingohu invoices create \
131
+ --data '{
132
+ "partner_id": '$PARTNER_ID',
133
+ "type": "invoice",
134
+ "currency": "HUF",
135
+ "items": [{"name":"Service","net_unit_price":50000,"quantity":1}]
136
+ }' \
137
+ --json | jq -r '.id')
247
138
 
248
- ```bash
249
- billingo utils convert-id 12345 --format json
139
+ # Send invoice
140
+ billingohu invoices send $INVOICE_ID --emails "client@example.com"
250
141
  ```
251
142
 
252
- ## Complete Invoice Workflow Example
253
-
254
- Here's a complete workflow an agent might execute:
143
+ ### List unpaid invoices
255
144
 
256
145
  ```bash
257
- # 1. Check organization setup
258
- billingo organization get --format json > org.json
146
+ billingohu invoices list --json | jq '.[] | select(.payment_status != "paid")'
147
+ ```
259
148
 
260
- # 2. List available document blocks (invoice pads)
261
- billingo document-blocks list --format json > blocks.json
149
+ ## Invoice Data Format
262
150
 
263
- # 3. Get or create partner
264
- billingo partners list --format json > partners.json
265
- # If partner doesn't exist, create:
266
- billingo partners create --file new-partner.json --format json
151
+ When creating invoices, use this structure:
267
152
 
268
- # 4. Prepare invoice data with correct IDs
269
- cat > invoice.json << 'EOF'
153
+ ```json
270
154
  {
271
- "vendor_id": 1,
272
- "partner_id": 456,
273
- "block_id": 1,
155
+ "partner_id": 123,
274
156
  "type": "invoice",
275
- "fulfillment_date": "2024-01-15",
276
- "due_date": "2024-01-30",
277
- "payment_method": "transfer",
278
- "language": "hu",
279
157
  "currency": "HUF",
280
158
  "items": [
281
159
  {
282
- "name": "Web Development",
283
- "unit_price": 50000,
284
- "quantity": 10,
285
- "unit": "hour",
160
+ "name": "Product/Service Name",
161
+ "net_unit_price": 10000,
162
+ "quantity": 1,
163
+ "unit": "db",
286
164
  "vat": "27%"
287
165
  }
288
166
  ]
289
167
  }
290
- EOF
291
-
292
- # 5. Create invoice
293
- billingo documents create --file invoice.json --format json > created-invoice.json
294
-
295
- # 6. Get document ID
296
- DOC_ID=$(jq -r '.id' created-invoice.json)
297
-
298
- # 7. Download PDF
299
- billingo documents download "$DOC_ID" --output "invoice-$DOC_ID.pdf"
300
-
301
- # 8. Send to customer
302
- billingo documents send "$DOC_ID" --emails "customer@example.com"
303
-
304
- # 9. Get public URL for customer portal
305
- billingo documents public-url "$DOC_ID" --format json
306
168
  ```
307
169
 
308
- ## Field Validation Tips
309
-
310
- ### Required Fields by Resource
311
-
312
- **Partner (Minimum):**
313
- - `name` (string)
314
- - `address.country_code` (string, ISO 3166-1 alpha-2)
315
- - `emails` (array of strings) OR `phone` (string)
316
-
317
- **Document (Invoice):**
318
- - `vendor_id` (integer) - Your organization ID
319
- - `partner_id` (integer) - Customer ID
320
- - `block_id` (integer) - Document block/pad ID
321
- - `type` (string) - "invoice", "proforma", etc.
322
- - `fulfillment_date` (date, YYYY-MM-DD)
323
- - `due_date` (date, YYYY-MM-DD)
324
- - `payment_method` (string) - "transfer", "cash", "card", etc.
325
- - `language` (string) - "hu", "en", "de", etc.
326
- - `currency` (string) - ISO 4217 code
327
- - `items` (array) - At least one item
328
-
329
- **Product:**
330
- - `name` (string)
331
- - `unit_price` (number)
332
- - `unit` (string) - "piece", "hour", etc.
333
- - `vat` (string) - "27%", "18%", "5%", "0%", "EU", "TAM", etc.
334
-
335
- ### Common Hungarian VAT Rates
336
-
337
- - `27%` - Standard rate
338
- - `18%` - Reduced rate (some foods, accommodation)
339
- - `5%` - Super-reduced rate (medicines, books)
340
- - `0%` - Zero-rated
341
- - `EU` - Intra-EU supply
342
- - `TAM` - Reverse charge (buyer pays VAT)
343
- - `AAM` - Special case
344
- - `FAD` - Agricultural products
345
-
346
- ### Date Formats
347
-
348
- All dates must be in `YYYY-MM-DD` format:
349
- - `2024-01-15` ✓
350
- - `01/15/2024` ✗
351
- - `15.01.2024` ✗
352
-
353
- ## Currency Support
354
-
355
- Supported currencies (ISO 4217):
356
- ```
357
- HUF, EUR, USD, GBP, CHF, AUD, CAD, DKK, NOK, SEK,
358
- CZK, PLN, RON, BGN, HRK, RSD, RUB, UAH, CNY, JPY,
359
- KRW, INR, BRL, MXN, ZAR, TRY, SGD, NZD, HKD, THB,
360
- MYR, PHP, IDR, AED, SAR, ILS, EGP
361
- ```
362
-
363
- Get conversion rates:
364
- ```bash
365
- billingo currencies convert --from HUF --to EUR --format json
366
- ```
367
-
368
- ## Payment Methods
369
-
370
- Common payment methods:
371
- - `transfer` - Bank transfer
372
- - `cash` - Cash payment
373
- - `card` - Card payment
374
- - `cheque` - Cheque
375
- - `cod` - Cash on delivery
376
- - `paypal` - PayPal
377
- - `other` - Other method
378
-
379
- ## Document Types
380
-
381
- - `invoice` - Regular invoice
382
- - `proforma` - Proforma invoice
383
- - `advance` - Advance invoice
384
- - `draft` - Draft document
385
-
386
- ## Best Practices for Agents
387
-
388
- 1. **Always use JSON format for parsing**: Add `--format json` to commands when you need to process the output
389
- 2. **Handle errors gracefully**: Check exit codes and parse error messages
390
- 3. **Respect rate limits**: Monitor warnings and implement backoff strategies
391
- 4. **Validate data before creation**: Check required fields match the API spec
392
- 5. **Store IDs for reference**: Keep track of created resource IDs for subsequent operations
393
- 6. **Use file-based input for complex data**: It's more reliable than inline JSON for large payloads
394
- 7. **Test with list commands first**: Before creating resources, list existing ones to understand the data structure
395
- 8. **Download invoices after creation**: Always download PDFs and store them securely
396
-
397
- ## Debugging Tips
398
-
399
- ### Enable Verbose Output
400
-
401
- For debugging, you can inspect the full API response:
402
-
403
- ```bash
404
- billingo documents get 789 --format json | jq '.'
405
- ```
406
-
407
- ### Check Configuration
408
-
409
- ```bash
410
- billingo config list
411
- ```
412
-
413
- ### Test API Connection
414
-
415
- ```bash
416
- billingo organization get
417
- ```
418
-
419
- If this works, your API key is valid and the connection is working.
420
-
421
- ## API Rate Limits
422
-
423
- The Billingo API has rate limits (typically 60 requests per minute). The CLI:
424
- - Shows warnings when you're close to the limit
425
- - Includes rate limit info in response headers
426
- - Provides clear error messages when rate limited
427
-
428
- Monitor your usage and implement delays between batch operations.
429
-
430
- ## Security Notes
431
-
432
- - Never log or expose API keys in plain text
433
- - Store API keys securely using the config system or environment variables
434
- - Don't commit API keys to version control
435
- - Use read-only API keys when possible (if Billingo supports different permission levels)
436
-
437
- ## Getting Help
438
-
439
- For any command, use `--help`:
440
-
441
- ```bash
442
- billingo --help
443
- billingo documents --help
444
- billingo documents create --help
445
- ```
170
+ ## Tips for Agents
446
171
 
447
- This provides up-to-date information about available options and usage.
172
+ 1. Always use `--json` when you need to extract specific fields
173
+ 2. Partner must exist before creating invoice - create partner first if needed
174
+ 3. Prices are in the smallest currency unit (e.g., HUF forints)
175
+ 4. Invoice types: invoice, draft, proforma, receipt, etc.
176
+ 5. Payment methods: transfer, cash, credit_card, etc.
177
+ 6. Pagination is available for list commands with --page and --per-page