@factucat/cli 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/README.md +337 -0
  2. package/package.json +21 -1
package/README.md ADDED
@@ -0,0 +1,337 @@
1
+ # FactuCat CLI
2
+
3
+ FactuCat CLI is the command-line interface for [FactuCat](https://factucat.com), a cloud-only product for issuing **Mexican CFDI 4.0 invoices**.
4
+
5
+ It is designed for two use cases:
6
+
7
+ - interactive invoicing for humans who want a guided flow
8
+ - unattended automation for agents, scripts, and integrations that need stable `--json` output
9
+
10
+ FactuCat CLI works with **Mexican tax concepts and SAT terminology** such as CFDI, timbrado, RFC, razón social, régimen fiscal, uso CFDI, XML, and PDF.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g @factucat/cli
16
+ ```
17
+
18
+ Verify the installation:
19
+
20
+ ```bash
21
+ factucat --help
22
+ ```
23
+
24
+ Update to the latest version:
25
+
26
+ ```bash
27
+ npm install -g @factucat/cli@latest
28
+ ```
29
+
30
+ ## Authenticate
31
+
32
+ Generate an API key in FactuCat, then save it locally:
33
+
34
+ ```bash
35
+ factucat auth api-key set
36
+ ```
37
+
38
+ You can also provide it explicitly:
39
+
40
+ ```bash
41
+ factucat auth api-key set --value fc_live_xxxxx
42
+ ```
43
+
44
+ Or through standard input:
45
+
46
+ ```bash
47
+ printf 'fc_live_xxxxx\n' | factucat auth api-key set
48
+ ```
49
+
50
+ Validate the current key:
51
+
52
+ ```bash
53
+ factucat auth status
54
+ factucat auth status --json
55
+ ```
56
+
57
+ ## How the workflow works
58
+
59
+ FactuCat CLI uses a **remote draft workflow**:
60
+
61
+ 1. Create a draft in FactuCat Cloud
62
+ 2. Assign the customer or receiver data
63
+ 3. Set invoice metadata such as `uso CFDI`, payment method, and currency
64
+ 4. Add line items
65
+ 5. Review the invoice preview
66
+ 6. Stamp the invoice
67
+ 7. Download the XML or PDF if needed
68
+
69
+ The server is always the source of truth. The CLI only remembers your current draft locally for convenience.
70
+
71
+ ## Interactive workflow
72
+
73
+ Create a draft:
74
+
75
+ ```bash
76
+ factucat invoice create
77
+ ```
78
+
79
+ Create a draft and automatically resolve a customer by name or RFC:
80
+
81
+ ```bash
82
+ factucat invoice create --customer "Donde nacen las ideas"
83
+ ```
84
+
85
+ That command is a shortcut: it creates the draft and internally tries to find the customer before linking it to the draft.
86
+
87
+ Add a line item:
88
+
89
+ ```bash
90
+ factucat invoice add-item \
91
+ --description "Desarrollo de sistema de facturación" \
92
+ --unit-price 10000
93
+ ```
94
+
95
+ If you omit SAT product code, SAT unit code, IVA, or retained ISR, FactuCat tries to infer them automatically.
96
+
97
+ Set invoice metadata:
98
+
99
+ ```bash
100
+ factucat invoice set-meta \
101
+ --cfdi-use G03 \
102
+ --payment-method PUE \
103
+ --payment-form 03
104
+ ```
105
+
106
+ If you switch the invoice to USD without specifying an exchange rate, FactuCat automatically fetches the official DOF exchange rate:
107
+
108
+ ```bash
109
+ factucat invoice set-meta --currency USD
110
+ ```
111
+
112
+ Preview the full invoice before stamping:
113
+
114
+ ```bash
115
+ factucat invoice show
116
+ ```
117
+
118
+ Stamp interactively:
119
+
120
+ ```bash
121
+ factucat invoice stamp
122
+ ```
123
+
124
+ In an interactive terminal, `invoice stamp` shows the full preview first and can ask whether you want to send the stamped invoice through the customer contact channels registered in FactuCat.
125
+
126
+ ## Unattended workflow
127
+
128
+ For agents and scripts, prefer `--json` and `--no-input`.
129
+
130
+ Create a draft:
131
+
132
+ ```bash
133
+ factucat invoice create --json
134
+ ```
135
+
136
+ Set receiver data:
137
+
138
+ ```bash
139
+ factucat invoice set-receiver \
140
+ --draft-id dft_123 \
141
+ --rfc XAXX010101000 \
142
+ --legal-name "Público en general" \
143
+ --postal-code 06000 \
144
+ --tax-regime 616 \
145
+ --json
146
+ ```
147
+
148
+ Set invoice metadata:
149
+
150
+ ```bash
151
+ factucat invoice set-meta \
152
+ --draft-id dft_123 \
153
+ --cfdi-use S01 \
154
+ --payment-method PUE \
155
+ --payment-form 01 \
156
+ --currency MXN \
157
+ --json
158
+ ```
159
+
160
+ Add a line item with explicit taxes:
161
+
162
+ ```bash
163
+ factucat invoice add-item \
164
+ --draft-id dft_123 \
165
+ --description "Servicios de consultoría" \
166
+ --quantity 1 \
167
+ --unit-price 1000 \
168
+ --iva 16 \
169
+ --isr-retenido 10 \
170
+ --json
171
+ ```
172
+
173
+ Preview the draft:
174
+
175
+ ```bash
176
+ factucat invoice show --draft-id dft_123 --json
177
+ ```
178
+
179
+ Stamp without prompts:
180
+
181
+ ```bash
182
+ factucat invoice stamp --draft-id dft_123 --no-input --json
183
+ ```
184
+
185
+ Stamp and request delivery to customer contacts:
186
+
187
+ ```bash
188
+ factucat invoice stamp \
189
+ --draft-id dft_123 \
190
+ --send-to-customer-contacts \
191
+ --no-input \
192
+ --json
193
+ ```
194
+
195
+ Or request specific channels:
196
+
197
+ ```bash
198
+ factucat invoice stamp \
199
+ --draft-id dft_123 \
200
+ --send-customer-email \
201
+ --send-customer-whatsapp \
202
+ --no-input \
203
+ --json
204
+ ```
205
+
206
+ ## Current draft helpers
207
+
208
+ Select an existing draft as your current one:
209
+
210
+ ```bash
211
+ factucat invoice use dft_123
212
+ ```
213
+
214
+ Check which draft is currently selected:
215
+
216
+ ```bash
217
+ factucat invoice current
218
+ ```
219
+
220
+ Discard the current draft:
221
+
222
+ ```bash
223
+ factucat invoice discard
224
+ ```
225
+
226
+ ## Customer commands
227
+
228
+ Search customers:
229
+
230
+ ```bash
231
+ factucat customer search "Donde nacen"
232
+ ```
233
+
234
+ List customers:
235
+
236
+ ```bash
237
+ factucat customer list --limit 20
238
+ ```
239
+
240
+ Create a customer:
241
+
242
+ ```bash
243
+ factucat customer create \
244
+ --legal-name "Donde nacen las ideas" \
245
+ --rfc DNI240101AB1 \
246
+ --postal-code 45116 \
247
+ --tax-regime 601 \
248
+ --email hola@ejemplo.com
249
+ ```
250
+
251
+ ## Review and artifact download
252
+
253
+ List issued invoices:
254
+
255
+ ```bash
256
+ factucat invoice list
257
+ ```
258
+
259
+ Get a stamped invoice by UUID or folio:
260
+
261
+ ```bash
262
+ factucat invoice get 019d231a-779b-771b-a666-ecefc6803fd2
263
+ factucat invoice get MIAU-00036
264
+ ```
265
+
266
+ Download XML:
267
+
268
+ ```bash
269
+ factucat invoice download xml MIAU-00036
270
+ factucat invoice download xml MIAU-00036 --output ./facturas/
271
+ ```
272
+
273
+ Download PDF:
274
+
275
+ ```bash
276
+ factucat invoice download pdf MIAU-00036
277
+ factucat invoice download pdf MIAU-00036 --output ./facturas/factura-marzo.pdf
278
+ ```
279
+
280
+ If you do not pass `--output`, the file is saved in the current working directory.
281
+
282
+ ## Notes about inference
283
+
284
+ FactuCat automatically infers several values when possible:
285
+
286
+ - `invoice add-item` can infer SAT product code, SAT unit code, IVA, and retained ISR
287
+ - `invoice set-meta --currency USD` can infer the official DOF exchange rate if you omit `--exchange-rate`
288
+
289
+ This mirrors the behavior of FactuCat's guided product flows and keeps the CLI aligned with the rest of the platform.
290
+
291
+ ## Troubleshooting
292
+
293
+ ### `API key inválida o revocada`
294
+
295
+ The configured API key is wrong, expired, or has been revoked. Save a valid key again:
296
+
297
+ ```bash
298
+ factucat auth api-key set
299
+ factucat auth status
300
+ ```
301
+
302
+ ### `No hay borrador activo`
303
+
304
+ You tried to mutate a draft without selecting one first. Either create a draft or point to one explicitly:
305
+
306
+ ```bash
307
+ factucat invoice create
308
+ factucat invoice use dft_123
309
+ ```
310
+
311
+ ### Customer lookup is ambiguous
312
+
313
+ If `invoice create --customer "..."` matches multiple customers, search first and then pass the exact customer id:
314
+
315
+ ```bash
316
+ factucat customer search "Donde nacen"
317
+ factucat invoice create --customer-id cus_123
318
+ ```
319
+
320
+ ### Stamping fails
321
+
322
+ Review the draft before retrying:
323
+
324
+ ```bash
325
+ factucat invoice show
326
+ ```
327
+
328
+ Common causes are incomplete CFDI data, missing receiver information, or invalid concepts.
329
+
330
+ ### Downloaded artifact location
331
+
332
+ If you are unsure where a file was saved, use `--output` explicitly to control the destination path.
333
+
334
+ ## Learn more
335
+
336
+ - FactuCat: [https://factucat.com](https://factucat.com)
337
+ - Help page in npm package format: this README
package/package.json CHANGED
@@ -1,8 +1,28 @@
1
1
  {
2
2
  "name": "@factucat/cli",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
+ "description": "CLI for Mexican CFDI 4.0 invoicing with FactuCat Cloud",
5
6
  "type": "module",
7
+ "keywords": [
8
+ "factucat",
9
+ "cli",
10
+ "cfdi",
11
+ "cfdi-4.0",
12
+ "mexico",
13
+ "sat",
14
+ "facturacion",
15
+ "invoicing"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/ocruzv/factucat.git",
20
+ "directory": "packages/cli"
21
+ },
22
+ "homepage": "https://github.com/ocruzv/factucat/tree/main/packages/cli",
23
+ "bugs": {
24
+ "url": "https://github.com/ocruzv/factucat/issues"
25
+ },
6
26
  "publishConfig": {
7
27
  "access": "public"
8
28
  },