bonbox 0.3.0 → 0.5.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 +32 -4
- package/dist/cli.js +557 -51
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { defineCommand as
|
|
4
|
+
import { defineCommand as defineCommand7, runCommand, showUsage } from "citty";
|
|
5
5
|
|
|
6
6
|
// src/commands/account.ts
|
|
7
7
|
import { defineCommand } from "citty";
|
|
@@ -40,6 +40,9 @@ var en_default = {
|
|
|
40
40
|
cli_cmd_customers_ls: "List your customers",
|
|
41
41
|
cli_cmd_customers_create: "Create a customer",
|
|
42
42
|
cli_cmd_customers_update: "Update a customer",
|
|
43
|
+
cli_cmd_customers_archive: "Archive a customer (hidden from lists, stays on its invoices)",
|
|
44
|
+
cli_cmd_customers_unarchive: "Restore an archived customer",
|
|
45
|
+
cli_cmd_customers_delete: "Delete a customer that nothing uses",
|
|
43
46
|
cli_cmd_invoices: "Work with your invoices and quotes",
|
|
44
47
|
cli_cmd_invoices_ls: "List invoices and quotes",
|
|
45
48
|
cli_cmd_invoices_create: "Create an invoice or a quote",
|
|
@@ -50,6 +53,7 @@ var en_default = {
|
|
|
50
53
|
cli_cmd_receipts: "Work with your receipts",
|
|
51
54
|
cli_cmd_receipts_ls: "List your receipts",
|
|
52
55
|
cli_cmd_receipts_add: "Add a receipt by hand",
|
|
56
|
+
cli_cmd_receipts_edit: "Change a receipt",
|
|
53
57
|
cli_cmd_receipts_scan: "Upload a receipt and let bonbox read it",
|
|
54
58
|
cli_flag_json: "Print the raw API response as JSON",
|
|
55
59
|
cli_flag_lang: "Output language (en, de, fr, it)",
|
|
@@ -59,11 +63,15 @@ var en_default = {
|
|
|
59
63
|
cli_flag_customer_ref: "Customer name or ID",
|
|
60
64
|
cli_flag_name: "Customer name",
|
|
61
65
|
cli_flag_department: "Department",
|
|
66
|
+
cli_flag_extra_line: "Additional line under the address (e.g. PSP element)",
|
|
62
67
|
cli_flag_address: "Street address",
|
|
63
68
|
cli_flag_postal_code: "Postal code",
|
|
64
69
|
cli_flag_city: "City",
|
|
65
70
|
cli_flag_country: "Country code, for example CH",
|
|
66
71
|
cli_flag_item: "Line item as description:quantity:unitPrice[:discount%], can be repeated",
|
|
72
|
+
cli_flag_receipt: "Expense receipt id to bill on the invoice (expenses), can be repeated",
|
|
73
|
+
cli_flag_combine: "Bill all --receipt receipts as one position (Expenses)",
|
|
74
|
+
cli_flag_attach_receipts: "Attach the receipts' files to the PDF",
|
|
67
75
|
cli_flag_quote: "Create a quote instead of an invoice",
|
|
68
76
|
cli_flag_invoice_date: "Invoice date (YYYY-MM-DD), today by default",
|
|
69
77
|
cli_flag_invoice_date_update: "Invoice date (YYYY-MM-DD)",
|
|
@@ -85,12 +93,16 @@ var en_default = {
|
|
|
85
93
|
cli_flag_seller: "Seller, or the customer for income",
|
|
86
94
|
cli_flag_price: "Amount, for example 23.50",
|
|
87
95
|
cli_flag_receipt_date: "Receipt date (YYYY-MM-DD), today by default",
|
|
88
|
-
|
|
96
|
+
cli_flag_edit_date: "Receipt date (YYYY-MM-DD)",
|
|
97
|
+
cli_flag_exchange_rate: "Exchange rate to your default currency, e.g. 1.02 for EUR 10.00 = CHF 10.20",
|
|
98
|
+
cli_flag_category: "Category (subcategory or own category): name, account number or ID",
|
|
89
99
|
cli_flag_tax_category: "Tax category",
|
|
100
|
+
cli_flag_correction: "Book as a correction entry (expense reduction)",
|
|
90
101
|
cli_flag_booking_text: "Booking text",
|
|
91
102
|
cli_arg_invoice_ref: "Invoice number or ID",
|
|
92
103
|
cli_arg_customer_ref: "Customer name or ID",
|
|
93
104
|
cli_arg_scan_files: "Image or PDF files, all pages of one receipt",
|
|
105
|
+
cli_arg_receipt_id: "Receipt ID",
|
|
94
106
|
cli_error_unauthorized: "You are not signed in. Run: bonbox login",
|
|
95
107
|
cli_error_pro_required: "This needs bonbox Pro. You can upgrade at %1$s",
|
|
96
108
|
cli_error_quota: "You have reached the limit of your plan. You can upgrade at %1$s",
|
|
@@ -98,7 +110,8 @@ var en_default = {
|
|
|
98
110
|
cli_error_unexpected_response: "Unexpected answer from bonbox (HTTP %1$s)",
|
|
99
111
|
cli_error_item_format: 'Invalid item "%1$s". Expected description:quantity:unitPrice[:discount%]',
|
|
100
112
|
cli_error_item_number: 'Invalid number in item "%1$s"',
|
|
101
|
-
cli_error_items_required: "Add at least one line item with --item",
|
|
113
|
+
cli_error_items_required: "Add at least one line item with --item or --receipt",
|
|
114
|
+
cli_error_receipt_id: "Not a receipt id: %1$s",
|
|
102
115
|
cli_error_customer_required: "Name a customer with --customer",
|
|
103
116
|
cli_error_name_required: "Give a name with --name",
|
|
104
117
|
cli_error_address_required: "Give an address with --address",
|
|
@@ -108,10 +121,15 @@ var en_default = {
|
|
|
108
121
|
cli_error_price_required: "Give an amount with --price",
|
|
109
122
|
cli_error_seller_required: "Give a seller with --seller",
|
|
110
123
|
cli_error_price_invalid: "Invalid amount: %1$s",
|
|
124
|
+
cli_error_receipt_nothing_to_change: "Nothing to change: pass at least one field, e.g. --seller",
|
|
125
|
+
cli_error_exchange_rate_invalid: "Invalid exchange rate: %1$s",
|
|
111
126
|
cli_error_date_invalid: "Invalid date: %1$s. Expected YYYY-MM-DD",
|
|
112
127
|
cli_error_month_invalid: "Invalid month: %1$s. Expected YYYY-MM",
|
|
113
128
|
cli_error_customer_not_found: 'No customer matches "%1$s"',
|
|
114
129
|
cli_error_customer_ambiguous: '"%1$s" matches several customers:',
|
|
130
|
+
cli_error_customer_in_use: '%1$s is still used by invoices, receipts or projects. Archive it instead: bonbox customers archive "%1$s"',
|
|
131
|
+
cli_error_category_not_found: 'No category matches "%1$s"',
|
|
132
|
+
cli_error_category_ambiguous: '"%1$s" matches several categories, add --tax-category:',
|
|
115
133
|
cli_error_files_required: "Name at least one file to scan",
|
|
116
134
|
cli_error_file_missing: "File not found: %1$s",
|
|
117
135
|
cli_login_opening: "Opening the bonbox sign-in page in your browser ...",
|
|
@@ -156,6 +174,9 @@ var en_default = {
|
|
|
156
174
|
cli_empty_receipts: "No receipts found.",
|
|
157
175
|
cli_customer_created: "Customer %1$s created.",
|
|
158
176
|
cli_customer_updated: "Customer %1$s updated.",
|
|
177
|
+
cli_customer_archived: "Customer %1$s archived.",
|
|
178
|
+
cli_customer_unarchived: "Customer %1$s restored.",
|
|
179
|
+
cli_customer_deleted: "Customer %1$s deleted.",
|
|
159
180
|
cli_invoice_created: "Invoice %1$s created, %2$s",
|
|
160
181
|
cli_quote_created: "Quote %1$s created, %2$s",
|
|
161
182
|
cli_pdf_saved: "Saved to %1$s",
|
|
@@ -164,8 +185,34 @@ var en_default = {
|
|
|
164
185
|
cli_invoice_paid: "%1$s marked as paid.",
|
|
165
186
|
cli_invoice_unpaid: "%1$s marked as unpaid.",
|
|
166
187
|
cli_receipt_added: "Receipt saved: %1$s, %2$s",
|
|
188
|
+
cli_receipt_updated: "Receipt updated: %1$s, %2$s",
|
|
167
189
|
cli_scan_uploading: "Uploading %1$s file(s) ...",
|
|
168
|
-
cli_receipt_scanned: "Receipt saved: %1$s, %2$s (extracted automatically)"
|
|
190
|
+
cli_receipt_scanned: "Receipt saved: %1$s, %2$s (extracted automatically)",
|
|
191
|
+
cli_cmd_vat: "Show your VAT (MWST) setting and filed returns",
|
|
192
|
+
cli_flag_receipt_vat_rate: "Swiss VAT rate included in the amount, e.g. 8.1 (0 = no Swiss VAT)",
|
|
193
|
+
cli_error_vat_rate_invalid: "Invalid VAT rate: %1$s. Allowed: %2$s",
|
|
194
|
+
cli_label_vat_method: "VAT",
|
|
195
|
+
cli_label_vat_since: "Since",
|
|
196
|
+
cli_label_vat_period: "Return",
|
|
197
|
+
cli_label_vat_basis: "Basis",
|
|
198
|
+
cli_label_vat_rates: "Net tax rates",
|
|
199
|
+
cli_vat_method_sss: "Net tax rate",
|
|
200
|
+
cli_vat_method_effective: "Effective method",
|
|
201
|
+
cli_vat_period_monthly: "Monthly",
|
|
202
|
+
cli_vat_period_quarterly: "Quarterly",
|
|
203
|
+
cli_vat_period_half_yearly: "Half-yearly",
|
|
204
|
+
cli_vat_period_yearly: "Yearly",
|
|
205
|
+
cli_vat_basis_agreed: "Agreed",
|
|
206
|
+
cli_vat_basis_received: "Received",
|
|
207
|
+
cli_vat_not_set: "VAT is off. Switch it on in the bonbox app under Profile \u2192 Accounting \u2192 VAT.",
|
|
208
|
+
cli_vat_returns_heading: "Filed returns",
|
|
209
|
+
cli_empty_vat_returns: "No filed returns yet.",
|
|
210
|
+
cli_col_period: "Period",
|
|
211
|
+
cli_col_method: "Method",
|
|
212
|
+
cli_col_vat_balance: "To pay",
|
|
213
|
+
cli_col_filed: "Filed",
|
|
214
|
+
cli_col_vat: "VAT",
|
|
215
|
+
cli_vat_reverse_charge: "acquisition tax"
|
|
169
216
|
};
|
|
170
217
|
|
|
171
218
|
// src/i18n/de.json
|
|
@@ -178,6 +225,9 @@ var de_default = {
|
|
|
178
225
|
cli_cmd_customers_ls: "Kunden auflisten",
|
|
179
226
|
cli_cmd_customers_create: "Kunde erstellen",
|
|
180
227
|
cli_cmd_customers_update: "Kunde aktualisieren",
|
|
228
|
+
cli_cmd_customers_archive: "Kunde archivieren (aus Listen ausgeblendet, bleibt auf seinen Rechnungen)",
|
|
229
|
+
cli_cmd_customers_unarchive: "Archivierten Kunden wiederherstellen",
|
|
230
|
+
cli_cmd_customers_delete: "Kunden l\xF6schen, den nichts verwendet",
|
|
181
231
|
cli_cmd_invoices: "Rechnungen und Offerten verwalten",
|
|
182
232
|
cli_cmd_invoices_ls: "Rechnungen und Offerten auflisten",
|
|
183
233
|
cli_cmd_invoices_create: "Rechnung oder Offerte erstellen",
|
|
@@ -188,6 +238,7 @@ var de_default = {
|
|
|
188
238
|
cli_cmd_receipts: "Belege verwalten",
|
|
189
239
|
cli_cmd_receipts_ls: "Belege auflisten",
|
|
190
240
|
cli_cmd_receipts_add: "Beleg von Hand erfassen",
|
|
241
|
+
cli_cmd_receipts_edit: "Beleg \xE4ndern",
|
|
191
242
|
cli_cmd_receipts_scan: "Beleg hochladen und von bonbox auslesen lassen",
|
|
192
243
|
cli_flag_json: "Antwort der API als reines JSON ausgeben",
|
|
193
244
|
cli_flag_lang: "Sprache der Ausgabe (en, de, fr, it)",
|
|
@@ -197,11 +248,15 @@ var de_default = {
|
|
|
197
248
|
cli_flag_customer_ref: "Kundenname oder Kunden-ID",
|
|
198
249
|
cli_flag_name: "Kundenname",
|
|
199
250
|
cli_flag_department: "Abteilung",
|
|
251
|
+
cli_flag_extra_line: "Zusatzzeile unter der Adresse (z.B. PSP-Element)",
|
|
200
252
|
cli_flag_address: "Strasse und Hausnummer",
|
|
201
253
|
cli_flag_postal_code: "Postleitzahl",
|
|
202
254
|
cli_flag_city: "Ort",
|
|
203
255
|
cli_flag_country: "L\xE4ndercode, zum Beispiel CH",
|
|
204
256
|
cli_flag_item: "Position als Beschreibung:Menge:Einzelpreis[:Rabatt%], mehrfach m\xF6glich",
|
|
257
|
+
cli_flag_receipt: "Beleg-ID einer Ausgabe, die weiterverrechnet wird (Spesen), mehrfach m\xF6glich",
|
|
258
|
+
cli_flag_combine: "Alle --receipt-Belege als eine Position verrechnen (Spesen)",
|
|
259
|
+
cli_flag_attach_receipts: "Die Dateien der Belege an das PDF anh\xE4ngen",
|
|
205
260
|
cli_flag_quote: "Offerte statt Rechnung erstellen",
|
|
206
261
|
cli_flag_invoice_date: "Rechnungsdatum (JJJJ-MM-TT), standardm\xE4ssig heute",
|
|
207
262
|
cli_flag_invoice_date_update: "Rechnungsdatum (JJJJ-MM-TT)",
|
|
@@ -223,12 +278,16 @@ var de_default = {
|
|
|
223
278
|
cli_flag_seller: "Anbieter, bei Einnahmen der Kunde",
|
|
224
279
|
cli_flag_price: "Betrag, zum Beispiel 23.50",
|
|
225
280
|
cli_flag_receipt_date: "Belegdatum (JJJJ-MM-TT), standardm\xE4ssig heute",
|
|
226
|
-
|
|
281
|
+
cli_flag_edit_date: "Belegdatum (JJJJ-MM-TT)",
|
|
282
|
+
cli_flag_exchange_rate: "Wechselkurs zur Standardw\xE4hrung, z. B. 1.02 f\xFCr EUR 10.00 = CHF 10.20",
|
|
283
|
+
cli_flag_category: "Kategorie (Unterkategorie oder eigene Kategorie): Name, Kontonummer oder ID",
|
|
227
284
|
cli_flag_tax_category: "Steuerkategorie",
|
|
285
|
+
cli_flag_correction: "Als Korrekturbuchung erfassen (Aufwandminderung)",
|
|
228
286
|
cli_flag_booking_text: "Buchungstext",
|
|
229
287
|
cli_arg_invoice_ref: "Rechnungsnummer oder ID",
|
|
230
288
|
cli_arg_customer_ref: "Kundenname oder ID",
|
|
231
289
|
cli_arg_scan_files: "Bild- oder PDF-Dateien, alle Seiten eines Belegs",
|
|
290
|
+
cli_arg_receipt_id: "Beleg-ID",
|
|
232
291
|
cli_error_unauthorized: "Sie sind nicht angemeldet. F\xFChren Sie aus: bonbox login",
|
|
233
292
|
cli_error_pro_required: "Daf\xFCr wird bonbox Pro ben\xF6tigt. Upgrade unter %1$s",
|
|
234
293
|
cli_error_quota: "Das Limit Ihres Abos ist erreicht. Upgrade unter %1$s",
|
|
@@ -236,7 +295,8 @@ var de_default = {
|
|
|
236
295
|
cli_error_unexpected_response: "Unerwartete Antwort von bonbox (HTTP %1$s)",
|
|
237
296
|
cli_error_item_format: 'Ung\xFCltige Position "%1$s". Erwartet: Beschreibung:Menge:Einzelpreis[:Rabatt%]',
|
|
238
297
|
cli_error_item_number: 'Ung\xFCltige Zahl in Position "%1$s"',
|
|
239
|
-
cli_error_items_required: "Erfassen Sie mindestens eine Position mit --item",
|
|
298
|
+
cli_error_items_required: "Erfassen Sie mindestens eine Position mit --item oder --receipt",
|
|
299
|
+
cli_error_receipt_id: "Keine Beleg-ID: %1$s",
|
|
240
300
|
cli_error_customer_required: "Geben Sie einen Kunden mit --customer an",
|
|
241
301
|
cli_error_name_required: "Geben Sie einen Namen mit --name an",
|
|
242
302
|
cli_error_address_required: "Geben Sie eine Adresse mit --address an",
|
|
@@ -246,10 +306,15 @@ var de_default = {
|
|
|
246
306
|
cli_error_price_required: "Geben Sie einen Betrag mit --price an",
|
|
247
307
|
cli_error_seller_required: "Geben Sie einen Anbieter mit --seller an",
|
|
248
308
|
cli_error_price_invalid: "Ung\xFCltiger Betrag: %1$s",
|
|
309
|
+
cli_error_receipt_nothing_to_change: "Nichts zu \xE4ndern: mindestens ein Feld angeben, z. B. --seller",
|
|
310
|
+
cli_error_exchange_rate_invalid: "Ung\xFCltiger Wechselkurs: %1$s",
|
|
249
311
|
cli_error_date_invalid: "Ung\xFCltiges Datum: %1$s. Erwartet: JJJJ-MM-TT",
|
|
250
312
|
cli_error_month_invalid: "Ung\xFCltiger Monat: %1$s. Erwartet: JJJJ-MM",
|
|
251
313
|
cli_error_customer_not_found: 'Kein Kunde passt zu "%1$s"',
|
|
252
314
|
cli_error_customer_ambiguous: '"%1$s" passt auf mehrere Kunden:',
|
|
315
|
+
cli_error_customer_in_use: '%1$s wird noch von Rechnungen, Belegen oder Projekten verwendet. Archiviere den Kunden stattdessen: bonbox customers archive "%1$s"',
|
|
316
|
+
cli_error_category_not_found: 'Keine Kategorie passt zu "%1$s"',
|
|
317
|
+
cli_error_category_ambiguous: '"%1$s" passt auf mehrere Kategorien, erg\xE4nzen Sie --tax-category:',
|
|
253
318
|
cli_error_files_required: "Geben Sie mindestens eine Datei zum Scannen an",
|
|
254
319
|
cli_error_file_missing: "Datei nicht gefunden: %1$s",
|
|
255
320
|
cli_login_opening: "Die bonbox-Anmeldeseite wird im Browser ge\xF6ffnet ...",
|
|
@@ -294,6 +359,9 @@ var de_default = {
|
|
|
294
359
|
cli_empty_receipts: "Keine Belege gefunden.",
|
|
295
360
|
cli_customer_created: "Kunde %1$s erstellt.",
|
|
296
361
|
cli_customer_updated: "Kunde %1$s aktualisiert.",
|
|
362
|
+
cli_customer_archived: "Kunde %1$s archiviert.",
|
|
363
|
+
cli_customer_unarchived: "Kunde %1$s wiederhergestellt.",
|
|
364
|
+
cli_customer_deleted: "Kunde %1$s gel\xF6scht.",
|
|
297
365
|
cli_invoice_created: "Rechnung %1$s erstellt, %2$s",
|
|
298
366
|
cli_quote_created: "Offerte %1$s erstellt, %2$s",
|
|
299
367
|
cli_pdf_saved: "Gespeichert unter %1$s",
|
|
@@ -302,8 +370,34 @@ var de_default = {
|
|
|
302
370
|
cli_invoice_paid: "%1$s als bezahlt markiert.",
|
|
303
371
|
cli_invoice_unpaid: "%1$s als offen markiert.",
|
|
304
372
|
cli_receipt_added: "Beleg gespeichert: %1$s, %2$s",
|
|
373
|
+
cli_receipt_updated: "Beleg aktualisiert: %1$s, %2$s",
|
|
305
374
|
cli_scan_uploading: "%1$s Datei(en) werden hochgeladen ...",
|
|
306
|
-
cli_receipt_scanned: "Beleg gespeichert: %1$s, %2$s (automatisch erkannt)"
|
|
375
|
+
cli_receipt_scanned: "Beleg gespeichert: %1$s, %2$s (automatisch erkannt)",
|
|
376
|
+
cli_cmd_vat: "MWST-Einstellung und eingereichte Abrechnungen anzeigen",
|
|
377
|
+
cli_flag_receipt_vat_rate: "Schweizer MWST-Satz im Betrag, z. B. 8.1 (0 = keine Schweizer MWST)",
|
|
378
|
+
cli_error_vat_rate_invalid: "Ung\xFCltiger MWST-Satz: %1$s. Erlaubt: %2$s",
|
|
379
|
+
cli_label_vat_method: "MWST",
|
|
380
|
+
cli_label_vat_since: "G\xFCltig ab",
|
|
381
|
+
cli_label_vat_period: "Abrechnung",
|
|
382
|
+
cli_label_vat_basis: "Basis",
|
|
383
|
+
cli_label_vat_rates: "Saldosteuers\xE4tze",
|
|
384
|
+
cli_vat_method_sss: "Saldosteuersatz",
|
|
385
|
+
cli_vat_method_effective: "Effektive Methode",
|
|
386
|
+
cli_vat_period_monthly: "Monatlich",
|
|
387
|
+
cli_vat_period_quarterly: "Quartalsweise",
|
|
388
|
+
cli_vat_period_half_yearly: "Halbj\xE4hrlich",
|
|
389
|
+
cli_vat_period_yearly: "J\xE4hrlich",
|
|
390
|
+
cli_vat_basis_agreed: "Vereinbart",
|
|
391
|
+
cli_vat_basis_received: "Vereinnahmt",
|
|
392
|
+
cli_vat_not_set: "MWST ist ausgeschaltet. Einschalten in der bonbox-App unter Profil \u2192 Buchhaltung \u2192 Mehrwertsteuer.",
|
|
393
|
+
cli_vat_returns_heading: "Eingereichte Abrechnungen",
|
|
394
|
+
cli_empty_vat_returns: "Noch keine eingereichten Abrechnungen.",
|
|
395
|
+
cli_col_period: "Periode",
|
|
396
|
+
cli_col_method: "Methode",
|
|
397
|
+
cli_col_vat_balance: "Zu zahlen",
|
|
398
|
+
cli_col_filed: "Eingereicht",
|
|
399
|
+
cli_col_vat: "MWST",
|
|
400
|
+
cli_vat_reverse_charge: "Bezugsteuer"
|
|
307
401
|
};
|
|
308
402
|
|
|
309
403
|
// src/i18n/fr.json
|
|
@@ -316,6 +410,9 @@ var fr_default = {
|
|
|
316
410
|
cli_cmd_customers_ls: "Lister vos clients",
|
|
317
411
|
cli_cmd_customers_create: "Cr\xE9er un client",
|
|
318
412
|
cli_cmd_customers_update: "Mettre \xE0 jour un client",
|
|
413
|
+
cli_cmd_customers_archive: "Archiver un client (masqu\xE9 des listes, reste sur ses factures)",
|
|
414
|
+
cli_cmd_customers_unarchive: "Restaurer un client archiv\xE9",
|
|
415
|
+
cli_cmd_customers_delete: "Supprimer un client qui n'est utilis\xE9 nulle part",
|
|
319
416
|
cli_cmd_invoices: "G\xE9rer vos factures et devis",
|
|
320
417
|
cli_cmd_invoices_ls: "Lister les factures et devis",
|
|
321
418
|
cli_cmd_invoices_create: "Cr\xE9er une facture ou un devis",
|
|
@@ -326,6 +423,7 @@ var fr_default = {
|
|
|
326
423
|
cli_cmd_receipts: "G\xE9rer vos justificatifs",
|
|
327
424
|
cli_cmd_receipts_ls: "Lister vos justificatifs",
|
|
328
425
|
cli_cmd_receipts_add: "Saisir un justificatif manuellement",
|
|
426
|
+
cli_cmd_receipts_edit: "Modifier un justificatif",
|
|
329
427
|
cli_cmd_receipts_scan: "Envoyer un justificatif et le faire lire par bonbox",
|
|
330
428
|
cli_flag_json: "Afficher la r\xE9ponse brute de l'API en JSON",
|
|
331
429
|
cli_flag_lang: "Langue de l'affichage (en, de, fr, it)",
|
|
@@ -335,11 +433,15 @@ var fr_default = {
|
|
|
335
433
|
cli_flag_customer_ref: "Nom ou identifiant du client",
|
|
336
434
|
cli_flag_name: "Nom du client",
|
|
337
435
|
cli_flag_department: "Service",
|
|
436
|
+
cli_flag_extra_line: "Ligne suppl\xE9mentaire sous l'adresse (p. ex. \xE9l\xE9ment PSP)",
|
|
338
437
|
cli_flag_address: "Adresse",
|
|
339
438
|
cli_flag_postal_code: "Code postal",
|
|
340
439
|
cli_flag_city: "Ville",
|
|
341
440
|
cli_flag_country: "Code pays, par exemple CH",
|
|
342
441
|
cli_flag_item: "Poste au format description:quantit\xE9:prix unitaire[:remise%], r\xE9p\xE9table",
|
|
442
|
+
cli_flag_receipt: "ID d'un justificatif de d\xE9pense \xE0 refacturer (frais), r\xE9p\xE9table",
|
|
443
|
+
cli_flag_combine: "Facturer tous les justificatifs --receipt en un seul poste (Frais)",
|
|
444
|
+
cli_flag_attach_receipts: "Joindre les fichiers des justificatifs au PDF",
|
|
343
445
|
cli_flag_quote: "Cr\xE9er un devis au lieu d'une facture",
|
|
344
446
|
cli_flag_invoice_date: "Date de la facture (AAAA-MM-JJ), aujourd'hui par d\xE9faut",
|
|
345
447
|
cli_flag_invoice_date_update: "Date de la facture (AAAA-MM-JJ)",
|
|
@@ -361,12 +463,16 @@ var fr_default = {
|
|
|
361
463
|
cli_flag_seller: "Fournisseur, ou le client pour une recette",
|
|
362
464
|
cli_flag_price: "Montant, par exemple 23.50",
|
|
363
465
|
cli_flag_receipt_date: "Date du justificatif (AAAA-MM-JJ), aujourd'hui par d\xE9faut",
|
|
364
|
-
|
|
466
|
+
cli_flag_edit_date: "Date du justificatif (AAAA-MM-JJ)",
|
|
467
|
+
cli_flag_exchange_rate: "Taux de change vers votre devise par d\xE9faut, p. ex. 1.02 pour EUR 10.00 = CHF 10.20",
|
|
468
|
+
cli_flag_category: "Cat\xE9gorie (sous-cat\xE9gorie ou cat\xE9gorie propre) : nom, num\xE9ro de compte ou ID",
|
|
365
469
|
cli_flag_tax_category: "Cat\xE9gorie fiscale",
|
|
470
|
+
cli_flag_correction: "Enregistrer comme correction (r\xE9duction de charges)",
|
|
366
471
|
cli_flag_booking_text: "Libell\xE9 comptable",
|
|
367
472
|
cli_arg_invoice_ref: "Num\xE9ro de facture ou identifiant",
|
|
368
473
|
cli_arg_customer_ref: "Nom ou identifiant du client",
|
|
369
474
|
cli_arg_scan_files: "Fichiers image ou PDF, toutes les pages d'un justificatif",
|
|
475
|
+
cli_arg_receipt_id: "Identifiant du justificatif",
|
|
370
476
|
cli_error_unauthorized: "Vous n'\xEAtes pas connect\xE9. Ex\xE9cutez : bonbox login",
|
|
371
477
|
cli_error_pro_required: "Cette action n\xE9cessite bonbox Pro. Passez \xE0 Pro sur %1$s",
|
|
372
478
|
cli_error_quota: "Vous avez atteint la limite de votre abonnement. Passez \xE0 Pro sur %1$s",
|
|
@@ -374,7 +480,8 @@ var fr_default = {
|
|
|
374
480
|
cli_error_unexpected_response: "R\xE9ponse inattendue de bonbox (HTTP %1$s)",
|
|
375
481
|
cli_error_item_format: 'Poste invalide "%1$s". Attendu : description:quantit\xE9:prix unitaire[:remise%]',
|
|
376
482
|
cli_error_item_number: 'Nombre invalide dans le poste "%1$s"',
|
|
377
|
-
cli_error_items_required: "Ajoutez au moins un poste avec --item",
|
|
483
|
+
cli_error_items_required: "Ajoutez au moins un poste avec --item ou --receipt",
|
|
484
|
+
cli_error_receipt_id: "Pas un ID de justificatif : %1$s",
|
|
378
485
|
cli_error_customer_required: "Indiquez un client avec --customer",
|
|
379
486
|
cli_error_name_required: "Indiquez un nom avec --name",
|
|
380
487
|
cli_error_address_required: "Indiquez une adresse avec --address",
|
|
@@ -384,10 +491,15 @@ var fr_default = {
|
|
|
384
491
|
cli_error_price_required: "Indiquez un montant avec --price",
|
|
385
492
|
cli_error_seller_required: "Indiquez un fournisseur avec --seller",
|
|
386
493
|
cli_error_price_invalid: "Montant invalide : %1$s",
|
|
494
|
+
cli_error_receipt_nothing_to_change: "Rien \xE0 modifier : indiquez au moins un champ, p. ex. --seller",
|
|
495
|
+
cli_error_exchange_rate_invalid: "Taux de change invalide : %1$s",
|
|
387
496
|
cli_error_date_invalid: "Date invalide : %1$s. Attendu : AAAA-MM-JJ",
|
|
388
497
|
cli_error_month_invalid: "Mois invalide : %1$s. Attendu : AAAA-MM",
|
|
389
498
|
cli_error_customer_not_found: 'Aucun client ne correspond \xE0 "%1$s"',
|
|
390
499
|
cli_error_customer_ambiguous: '"%1$s" correspond \xE0 plusieurs clients :',
|
|
500
|
+
cli_error_customer_in_use: '%1$s est encore utilis\xE9 par des factures, des justificatifs ou des projets. Archivez-le plut\xF4t : bonbox customers archive "%1$s"',
|
|
501
|
+
cli_error_category_not_found: 'Aucune cat\xE9gorie ne correspond \xE0 "%1$s"',
|
|
502
|
+
cli_error_category_ambiguous: '"%1$s" correspond \xE0 plusieurs cat\xE9gories, ajoutez --tax-category :',
|
|
391
503
|
cli_error_files_required: "Indiquez au moins un fichier \xE0 traiter",
|
|
392
504
|
cli_error_file_missing: "Fichier introuvable : %1$s",
|
|
393
505
|
cli_login_opening: "Ouverture de la page de connexion bonbox dans votre navigateur ...",
|
|
@@ -432,6 +544,9 @@ var fr_default = {
|
|
|
432
544
|
cli_empty_receipts: "Aucun justificatif trouv\xE9.",
|
|
433
545
|
cli_customer_created: "Client %1$s cr\xE9\xE9.",
|
|
434
546
|
cli_customer_updated: "Client %1$s mis \xE0 jour.",
|
|
547
|
+
cli_customer_archived: "Client %1$s archiv\xE9.",
|
|
548
|
+
cli_customer_unarchived: "Client %1$s restaur\xE9.",
|
|
549
|
+
cli_customer_deleted: "Client %1$s supprim\xE9.",
|
|
435
550
|
cli_invoice_created: "Facture %1$s cr\xE9\xE9e, %2$s",
|
|
436
551
|
cli_quote_created: "Devis %1$s cr\xE9\xE9, %2$s",
|
|
437
552
|
cli_pdf_saved: "Enregistr\xE9 sous %1$s",
|
|
@@ -440,8 +555,34 @@ var fr_default = {
|
|
|
440
555
|
cli_invoice_paid: "%1$s marqu\xE9e comme pay\xE9e.",
|
|
441
556
|
cli_invoice_unpaid: "%1$s remise en attente de paiement.",
|
|
442
557
|
cli_receipt_added: "Justificatif enregistr\xE9 : %1$s, %2$s",
|
|
558
|
+
cli_receipt_updated: "Justificatif mis \xE0 jour : %1$s, %2$s",
|
|
443
559
|
cli_scan_uploading: "Envoi de %1$s fichier(s) ...",
|
|
444
|
-
cli_receipt_scanned: "Justificatif enregistr\xE9 : %1$s, %2$s (reconnu automatiquement)"
|
|
560
|
+
cli_receipt_scanned: "Justificatif enregistr\xE9 : %1$s, %2$s (reconnu automatiquement)",
|
|
561
|
+
cli_cmd_vat: "Afficher le r\xE9glage TVA et les d\xE9comptes d\xE9pos\xE9s",
|
|
562
|
+
cli_flag_receipt_vat_rate: "Taux de TVA suisse compris dans le montant, p. ex. 8.1 (0 = sans TVA suisse)",
|
|
563
|
+
cli_error_vat_rate_invalid: "Taux de TVA invalide : %1$s. Autoris\xE9s : %2$s",
|
|
564
|
+
cli_label_vat_method: "TVA",
|
|
565
|
+
cli_label_vat_since: "D\xE8s le",
|
|
566
|
+
cli_label_vat_period: "D\xE9compte",
|
|
567
|
+
cli_label_vat_basis: "Base",
|
|
568
|
+
cli_label_vat_rates: "Taux de la dette fiscale nette",
|
|
569
|
+
cli_vat_method_sss: "Taux de la dette fiscale nette",
|
|
570
|
+
cli_vat_method_effective: "M\xE9thode effective",
|
|
571
|
+
cli_vat_period_monthly: "Mensuel",
|
|
572
|
+
cli_vat_period_quarterly: "Trimestriel",
|
|
573
|
+
cli_vat_period_half_yearly: "Semestriel",
|
|
574
|
+
cli_vat_period_yearly: "Annuel",
|
|
575
|
+
cli_vat_basis_agreed: "Convenues",
|
|
576
|
+
cli_vat_basis_received: "Re\xE7ues",
|
|
577
|
+
cli_vat_not_set: "La TVA est d\xE9sactiv\xE9e. Active-la dans l'app bonbox sous Profil \u2192 Comptabilit\xE9 \u2192 TVA.",
|
|
578
|
+
cli_vat_returns_heading: "D\xE9comptes d\xE9pos\xE9s",
|
|
579
|
+
cli_empty_vat_returns: "Aucun d\xE9compte d\xE9pos\xE9 pour l'instant.",
|
|
580
|
+
cli_col_period: "P\xE9riode",
|
|
581
|
+
cli_col_method: "M\xE9thode",
|
|
582
|
+
cli_col_vat_balance: "\xC0 payer",
|
|
583
|
+
cli_col_filed: "D\xE9pos\xE9",
|
|
584
|
+
cli_col_vat: "TVA",
|
|
585
|
+
cli_vat_reverse_charge: "imp\xF4t sur les acquisitions"
|
|
445
586
|
};
|
|
446
587
|
|
|
447
588
|
// src/i18n/it.json
|
|
@@ -454,6 +595,9 @@ var it_default = {
|
|
|
454
595
|
cli_cmd_customers_ls: "Elenca i tuoi clienti",
|
|
455
596
|
cli_cmd_customers_create: "Crea un cliente",
|
|
456
597
|
cli_cmd_customers_update: "Aggiorna un cliente",
|
|
598
|
+
cli_cmd_customers_archive: "Archivia un cliente (nascosto dagli elenchi, resta sulle sue fatture)",
|
|
599
|
+
cli_cmd_customers_unarchive: "Ripristina un cliente archiviato",
|
|
600
|
+
cli_cmd_customers_delete: "Elimina un cliente che nulla usa",
|
|
457
601
|
cli_cmd_invoices: "Gestisci fatture e preventivi",
|
|
458
602
|
cli_cmd_invoices_ls: "Elenca fatture e preventivi",
|
|
459
603
|
cli_cmd_invoices_create: "Crea una fattura o un preventivo",
|
|
@@ -464,6 +608,7 @@ var it_default = {
|
|
|
464
608
|
cli_cmd_receipts: "Gestisci i tuoi giustificativi",
|
|
465
609
|
cli_cmd_receipts_ls: "Elenca i tuoi giustificativi",
|
|
466
610
|
cli_cmd_receipts_add: "Inserisci un giustificativo manualmente",
|
|
611
|
+
cli_cmd_receipts_edit: "Modifica un giustificativo",
|
|
467
612
|
cli_cmd_receipts_scan: "Carica un giustificativo e lascia che bonbox lo legga",
|
|
468
613
|
cli_flag_json: "Stampa la risposta dell'API come JSON grezzo",
|
|
469
614
|
cli_flag_lang: "Lingua dell'output (en, de, fr, it)",
|
|
@@ -473,11 +618,15 @@ var it_default = {
|
|
|
473
618
|
cli_flag_customer_ref: "Nome o ID del cliente",
|
|
474
619
|
cli_flag_name: "Nome del cliente",
|
|
475
620
|
cli_flag_department: "Reparto",
|
|
621
|
+
cli_flag_extra_line: "Riga aggiuntiva sotto l'indirizzo (es. elemento PSP)",
|
|
476
622
|
cli_flag_address: "Indirizzo",
|
|
477
623
|
cli_flag_postal_code: "Codice postale",
|
|
478
624
|
cli_flag_city: "Citt\xE0",
|
|
479
625
|
cli_flag_country: "Codice paese, ad esempio CH",
|
|
480
626
|
cli_flag_item: "Voce nel formato descrizione:quantit\xE0:prezzo unitario[:sconto%], ripetibile",
|
|
627
|
+
cli_flag_receipt: "ID di una ricevuta di spesa da rifatturare (spese), ripetibile",
|
|
628
|
+
cli_flag_combine: "Fattura tutte le ricevute --receipt in un'unica voce (Spese)",
|
|
629
|
+
cli_flag_attach_receipts: "Allega i file delle ricevute al PDF",
|
|
481
630
|
cli_flag_quote: "Crea un preventivo invece di una fattura",
|
|
482
631
|
cli_flag_invoice_date: "Data della fattura (AAAA-MM-GG), per impostazione predefinita oggi",
|
|
483
632
|
cli_flag_invoice_date_update: "Data della fattura (AAAA-MM-GG)",
|
|
@@ -499,12 +648,16 @@ var it_default = {
|
|
|
499
648
|
cli_flag_seller: "Fornitore, oppure il cliente per le entrate",
|
|
500
649
|
cli_flag_price: "Importo, ad esempio 23.50",
|
|
501
650
|
cli_flag_receipt_date: "Data del giustificativo (AAAA-MM-GG), per impostazione predefinita oggi",
|
|
502
|
-
|
|
651
|
+
cli_flag_edit_date: "Data del giustificativo (AAAA-MM-GG)",
|
|
652
|
+
cli_flag_exchange_rate: "Tasso di cambio verso la valuta predefinita, ad es. 1.02 per EUR 10.00 = CHF 10.20",
|
|
653
|
+
cli_flag_category: "Categoria (sottocategoria o categoria propria): nome, numero di conto o ID",
|
|
503
654
|
cli_flag_tax_category: "Categoria fiscale",
|
|
655
|
+
cli_flag_correction: "Registra come rettifica (riduzione dei costi)",
|
|
504
656
|
cli_flag_booking_text: "Testo di registrazione",
|
|
505
657
|
cli_arg_invoice_ref: "Numero della fattura o ID",
|
|
506
658
|
cli_arg_customer_ref: "Nome o ID del cliente",
|
|
507
659
|
cli_arg_scan_files: "File immagine o PDF, tutte le pagine di un giustificativo",
|
|
660
|
+
cli_arg_receipt_id: "ID del giustificativo",
|
|
508
661
|
cli_error_unauthorized: "Non hai effettuato l'accesso. Esegui: bonbox login",
|
|
509
662
|
cli_error_pro_required: "Serve bonbox Pro. Puoi passare a Pro qui: %1$s",
|
|
510
663
|
cli_error_quota: "Hai raggiunto il limite del tuo abbonamento. Puoi passare a Pro qui: %1$s",
|
|
@@ -512,7 +665,8 @@ var it_default = {
|
|
|
512
665
|
cli_error_unexpected_response: "Risposta inattesa da bonbox (HTTP %1$s)",
|
|
513
666
|
cli_error_item_format: 'Voce non valida "%1$s". Formato atteso: descrizione:quantit\xE0:prezzo unitario[:sconto%]',
|
|
514
667
|
cli_error_item_number: 'Numero non valido nella voce "%1$s"',
|
|
515
|
-
cli_error_items_required: "Aggiungi almeno una voce con --item",
|
|
668
|
+
cli_error_items_required: "Aggiungi almeno una voce con --item o --receipt",
|
|
669
|
+
cli_error_receipt_id: "Non \xE8 un ID di ricevuta: %1$s",
|
|
516
670
|
cli_error_customer_required: "Indica un cliente con --customer",
|
|
517
671
|
cli_error_name_required: "Indica un nome con --name",
|
|
518
672
|
cli_error_address_required: "Indica un indirizzo con --address",
|
|
@@ -522,10 +676,15 @@ var it_default = {
|
|
|
522
676
|
cli_error_price_required: "Indica un importo con --price",
|
|
523
677
|
cli_error_seller_required: "Indica un fornitore con --seller",
|
|
524
678
|
cli_error_price_invalid: "Importo non valido: %1$s",
|
|
679
|
+
cli_error_receipt_nothing_to_change: "Niente da modificare: indicare almeno un campo, ad es. --seller",
|
|
680
|
+
cli_error_exchange_rate_invalid: "Tasso di cambio non valido: %1$s",
|
|
525
681
|
cli_error_date_invalid: "Data non valida: %1$s. Formato atteso: AAAA-MM-GG",
|
|
526
682
|
cli_error_month_invalid: "Mese non valido: %1$s. Formato atteso: AAAA-MM",
|
|
527
683
|
cli_error_customer_not_found: 'Nessun cliente corrisponde a "%1$s"',
|
|
528
684
|
cli_error_customer_ambiguous: '"%1$s" corrisponde a pi\xF9 clienti:',
|
|
685
|
+
cli_error_customer_in_use: '%1$s \xE8 ancora usato da fatture, giustificativi o progetti. Archivialo invece: bonbox customers archive "%1$s"',
|
|
686
|
+
cli_error_category_not_found: 'Nessuna categoria corrisponde a "%1$s"',
|
|
687
|
+
cli_error_category_ambiguous: '"%1$s" corrisponde a pi\xF9 categorie, aggiungi --tax-category:',
|
|
529
688
|
cli_error_files_required: "Indica almeno un file da elaborare",
|
|
530
689
|
cli_error_file_missing: "File non trovato: %1$s",
|
|
531
690
|
cli_login_opening: "Apertura della pagina di accesso bonbox nel browser ...",
|
|
@@ -570,6 +729,9 @@ var it_default = {
|
|
|
570
729
|
cli_empty_receipts: "Nessun giustificativo trovato.",
|
|
571
730
|
cli_customer_created: "Cliente %1$s creato.",
|
|
572
731
|
cli_customer_updated: "Cliente %1$s aggiornato.",
|
|
732
|
+
cli_customer_archived: "Cliente %1$s archiviato.",
|
|
733
|
+
cli_customer_unarchived: "Cliente %1$s ripristinato.",
|
|
734
|
+
cli_customer_deleted: "Cliente %1$s eliminato.",
|
|
573
735
|
cli_invoice_created: "Fattura %1$s creata, %2$s",
|
|
574
736
|
cli_quote_created: "Preventivo %1$s creato, %2$s",
|
|
575
737
|
cli_pdf_saved: "Salvato in %1$s",
|
|
@@ -578,8 +740,34 @@ var it_default = {
|
|
|
578
740
|
cli_invoice_paid: "%1$s segnata come pagata.",
|
|
579
741
|
cli_invoice_unpaid: "%1$s riportata fra quelle aperte.",
|
|
580
742
|
cli_receipt_added: "Giustificativo salvato: %1$s, %2$s",
|
|
743
|
+
cli_receipt_updated: "Giustificativo aggiornato: %1$s, %2$s",
|
|
581
744
|
cli_scan_uploading: "Caricamento di %1$s file ...",
|
|
582
|
-
cli_receipt_scanned: "Giustificativo salvato: %1$s, %2$s (riconosciuto automaticamente)"
|
|
745
|
+
cli_receipt_scanned: "Giustificativo salvato: %1$s, %2$s (riconosciuto automaticamente)",
|
|
746
|
+
cli_cmd_vat: "Mostrare l'impostazione IVA e i rendiconti inoltrati",
|
|
747
|
+
cli_flag_receipt_vat_rate: "Aliquota IVA svizzera inclusa nell'importo, ad es. 8.1 (0 = senza IVA svizzera)",
|
|
748
|
+
cli_error_vat_rate_invalid: "Aliquota IVA non valida: %1$s. Consentite: %2$s",
|
|
749
|
+
cli_label_vat_method: "IVA",
|
|
750
|
+
cli_label_vat_since: "Dal",
|
|
751
|
+
cli_label_vat_period: "Rendiconto",
|
|
752
|
+
cli_label_vat_basis: "Base",
|
|
753
|
+
cli_label_vat_rates: "Aliquote saldo",
|
|
754
|
+
cli_vat_method_sss: "Aliquota saldo",
|
|
755
|
+
cli_vat_method_effective: "Metodo effettivo",
|
|
756
|
+
cli_vat_period_monthly: "Mensile",
|
|
757
|
+
cli_vat_period_quarterly: "Trimestrale",
|
|
758
|
+
cli_vat_period_half_yearly: "Semestrale",
|
|
759
|
+
cli_vat_period_yearly: "Annuale",
|
|
760
|
+
cli_vat_basis_agreed: "Convenute",
|
|
761
|
+
cli_vat_basis_received: "Ricevute",
|
|
762
|
+
cli_vat_not_set: "L'IVA \xE8 disattivata. Attivala nell'app bonbox sotto Profilo \u2192 Contabilit\xE0 \u2192 IVA.",
|
|
763
|
+
cli_vat_returns_heading: "Rendiconti inoltrati",
|
|
764
|
+
cli_empty_vat_returns: "Nessun rendiconto inoltrato finora.",
|
|
765
|
+
cli_col_period: "Periodo",
|
|
766
|
+
cli_col_method: "Metodo",
|
|
767
|
+
cli_col_vat_balance: "Da pagare",
|
|
768
|
+
cli_col_filed: "Inoltrato",
|
|
769
|
+
cli_col_vat: "IVA",
|
|
770
|
+
cli_vat_reverse_charge: "imposta sull'acquisto"
|
|
583
771
|
};
|
|
584
772
|
|
|
585
773
|
// src/i18n/index.ts
|
|
@@ -629,6 +817,14 @@ var UsageError = class extends CliError {
|
|
|
629
817
|
this.name = "UsageError";
|
|
630
818
|
}
|
|
631
819
|
};
|
|
820
|
+
var ApiRequestError = class extends CliError {
|
|
821
|
+
constructor(message, status) {
|
|
822
|
+
super(message);
|
|
823
|
+
this.status = status;
|
|
824
|
+
this.name = "ApiRequestError";
|
|
825
|
+
}
|
|
826
|
+
status;
|
|
827
|
+
};
|
|
632
828
|
function envelopeMessage(body) {
|
|
633
829
|
const message = body?.error?.message;
|
|
634
830
|
return typeof message === "string" && message.length > 0 ? message : void 0;
|
|
@@ -636,14 +832,15 @@ function envelopeMessage(body) {
|
|
|
636
832
|
function mapApiError(status, body) {
|
|
637
833
|
switch (status) {
|
|
638
834
|
case 401:
|
|
639
|
-
return new
|
|
835
|
+
return new ApiRequestError(t("cli_error_unauthorized"), status);
|
|
640
836
|
case 402:
|
|
641
|
-
return new
|
|
837
|
+
return new ApiRequestError(t("cli_error_pro_required", APP_URL), status);
|
|
642
838
|
case 429:
|
|
643
|
-
return new
|
|
839
|
+
return new ApiRequestError(t("cli_error_quota", APP_URL), status);
|
|
644
840
|
default:
|
|
645
|
-
return new
|
|
646
|
-
envelopeMessage(body) ?? t("cli_error_unexpected_response", status)
|
|
841
|
+
return new ApiRequestError(
|
|
842
|
+
envelopeMessage(body) ?? t("cli_error_unexpected_response", status),
|
|
843
|
+
status
|
|
647
844
|
);
|
|
648
845
|
}
|
|
649
846
|
}
|
|
@@ -784,6 +981,10 @@ var ApiClient = class {
|
|
|
784
981
|
});
|
|
785
982
|
return await this.parseJson(response);
|
|
786
983
|
}
|
|
984
|
+
async delete(path) {
|
|
985
|
+
const response = await this.send(path, { method: "DELETE" });
|
|
986
|
+
return await this.parseJson(response);
|
|
987
|
+
}
|
|
787
988
|
async postMultipart(path, form) {
|
|
788
989
|
const response = await this.send(path, { method: "POST", body: form });
|
|
789
990
|
return await this.parseJson(response);
|
|
@@ -943,6 +1144,24 @@ function requireNumber(value, messageKey) {
|
|
|
943
1144
|
if (!Number.isFinite(parsed)) throw new UsageError(t(messageKey, value));
|
|
944
1145
|
return parsed;
|
|
945
1146
|
}
|
|
1147
|
+
var VAT_RATES = [8.1, 2.6, 3.8, 7.7, 2.5, 3.7];
|
|
1148
|
+
function requireVatRate(value) {
|
|
1149
|
+
if (value === void 0) return void 0;
|
|
1150
|
+
const parsed = Number(value.replace(",", "."));
|
|
1151
|
+
if (parsed !== 0 && !VAT_RATES.includes(parsed)) {
|
|
1152
|
+
throw new UsageError(t("cli_error_vat_rate_invalid", value, ["0", ...VAT_RATES].join(", ")));
|
|
1153
|
+
}
|
|
1154
|
+
return parsed;
|
|
1155
|
+
}
|
|
1156
|
+
function round2(value) {
|
|
1157
|
+
const rounded = Math.floor(Math.abs(value) * 100 + 0.5 + 1e-9) / 100;
|
|
1158
|
+
return rounded === 0 ? 0 : value < 0 ? -rounded : rounded;
|
|
1159
|
+
}
|
|
1160
|
+
function vatLinesFor(amount, rate) {
|
|
1161
|
+
if (rate === 0) return [];
|
|
1162
|
+
const base = round2(Math.abs(amount));
|
|
1163
|
+
return [{ rate, base, vat: round2(base * rate / (100 + rate)) }];
|
|
1164
|
+
}
|
|
946
1165
|
function monthRange(month) {
|
|
947
1166
|
const match = /^(\d{4})-(\d{2})$/.exec(month);
|
|
948
1167
|
const year = Number(match?.[1]);
|
|
@@ -994,7 +1213,8 @@ function customerFieldArgs() {
|
|
|
994
1213
|
address: { type: "string", description: t("cli_flag_address") },
|
|
995
1214
|
"postal-code": { type: "string", description: t("cli_flag_postal_code") },
|
|
996
1215
|
city: { type: "string", description: t("cli_flag_city") },
|
|
997
|
-
country: { type: "string", description: t("cli_flag_country") }
|
|
1216
|
+
country: { type: "string", description: t("cli_flag_country") },
|
|
1217
|
+
"extra-line": { type: "string", description: t("cli_flag_extra_line") }
|
|
998
1218
|
};
|
|
999
1219
|
}
|
|
1000
1220
|
function listCommand() {
|
|
@@ -1047,7 +1267,8 @@ function buildCreateBody(fields) {
|
|
|
1047
1267
|
postalCode,
|
|
1048
1268
|
city,
|
|
1049
1269
|
country: optional(fields.country),
|
|
1050
|
-
department: optional(fields.department)
|
|
1270
|
+
department: optional(fields.department),
|
|
1271
|
+
extraLine: optional(fields["extra-line"])
|
|
1051
1272
|
};
|
|
1052
1273
|
}
|
|
1053
1274
|
function createCommand() {
|
|
@@ -1072,12 +1293,14 @@ function updatePayload(fields) {
|
|
|
1072
1293
|
const city = providedValue(fields.city);
|
|
1073
1294
|
const country = providedValue(fields.country);
|
|
1074
1295
|
const department = providedValue(fields.department);
|
|
1296
|
+
const extraLine = providedValue(fields["extra-line"]);
|
|
1075
1297
|
if (name !== void 0) payload.name = name;
|
|
1076
1298
|
if (address !== void 0) payload.address = address;
|
|
1077
1299
|
if (postalCode !== void 0) payload.postalCode = postalCode;
|
|
1078
1300
|
if (city !== void 0) payload.city = city;
|
|
1079
1301
|
if (country !== void 0) payload.country = country;
|
|
1080
1302
|
if (department !== void 0) payload.department = department;
|
|
1303
|
+
if (extraLine !== void 0) payload.extraLine = extraLine;
|
|
1081
1304
|
return payload;
|
|
1082
1305
|
}
|
|
1083
1306
|
function ensureUpdatePayload(fields) {
|
|
@@ -1087,6 +1310,13 @@ function ensureUpdatePayload(fields) {
|
|
|
1087
1310
|
}
|
|
1088
1311
|
return payload;
|
|
1089
1312
|
}
|
|
1313
|
+
async function findCustomer(api, ref, includeArchived) {
|
|
1314
|
+
if (isUuid(ref)) return { id: ref, name: ref };
|
|
1315
|
+
const customers = await api.getAllPages("/customers", {
|
|
1316
|
+
includeArchived: includeArchived ? "true" : void 0
|
|
1317
|
+
});
|
|
1318
|
+
return resolveCustomer(ref, customers);
|
|
1319
|
+
}
|
|
1090
1320
|
function updateCommand() {
|
|
1091
1321
|
return defineCommand2({
|
|
1092
1322
|
meta: { name: "update", description: t("cli_cmd_customers_update") },
|
|
@@ -1097,19 +1327,65 @@ function updateCommand() {
|
|
|
1097
1327
|
},
|
|
1098
1328
|
async run({ args }) {
|
|
1099
1329
|
const payload = ensureUpdatePayload(args);
|
|
1100
|
-
const ref = String(args.customer);
|
|
1101
1330
|
const api = client();
|
|
1102
|
-
const
|
|
1103
|
-
const customer = await api.patch(`/customers/${
|
|
1331
|
+
const { id } = await findCustomer(api, String(args.customer), false);
|
|
1332
|
+
const customer = await api.patch(`/customers/${id}`, payload);
|
|
1104
1333
|
if (args.json) printJson(customer);
|
|
1105
1334
|
else out(t("cli_customer_updated", customer.name));
|
|
1106
1335
|
}
|
|
1107
1336
|
});
|
|
1108
1337
|
}
|
|
1338
|
+
function archiveCommand(archived) {
|
|
1339
|
+
return defineCommand2({
|
|
1340
|
+
meta: {
|
|
1341
|
+
name: archived ? "archive" : "unarchive",
|
|
1342
|
+
description: t(archived ? "cli_cmd_customers_archive" : "cli_cmd_customers_unarchive")
|
|
1343
|
+
},
|
|
1344
|
+
args: {
|
|
1345
|
+
customer: { type: "positional", description: t("cli_arg_customer_ref"), required: true },
|
|
1346
|
+
...commonArgs()
|
|
1347
|
+
},
|
|
1348
|
+
async run({ args }) {
|
|
1349
|
+
const api = client();
|
|
1350
|
+
const { id } = await findCustomer(api, String(args.customer), !archived);
|
|
1351
|
+
const customer = await api.patch(`/customers/${id}`, { archived });
|
|
1352
|
+
if (args.json) printJson(customer);
|
|
1353
|
+
else out(t(archived ? "cli_customer_archived" : "cli_customer_unarchived", customer.name));
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
function deleteCommand() {
|
|
1358
|
+
return defineCommand2({
|
|
1359
|
+
meta: { name: "delete", description: t("cli_cmd_customers_delete") },
|
|
1360
|
+
args: {
|
|
1361
|
+
customer: { type: "positional", description: t("cli_arg_customer_ref"), required: true },
|
|
1362
|
+
...commonArgs()
|
|
1363
|
+
},
|
|
1364
|
+
async run({ args }) {
|
|
1365
|
+
const api = client();
|
|
1366
|
+
const { id, name } = await findCustomer(api, String(args.customer), true);
|
|
1367
|
+
const result = await api.delete(`/customers/${id}`).catch((error) => {
|
|
1368
|
+
if (error instanceof ApiRequestError && error.status === 409) {
|
|
1369
|
+
throw new CliError(t("cli_error_customer_in_use", name));
|
|
1370
|
+
}
|
|
1371
|
+
throw error;
|
|
1372
|
+
});
|
|
1373
|
+
if (args.json) printJson(result);
|
|
1374
|
+
else out(t("cli_customer_deleted", name));
|
|
1375
|
+
}
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1109
1378
|
function customersCommand() {
|
|
1110
1379
|
return defineCommand2({
|
|
1111
1380
|
meta: { name: "customers", description: t("cli_cmd_customers") },
|
|
1112
|
-
subCommands: {
|
|
1381
|
+
subCommands: {
|
|
1382
|
+
ls: listCommand(),
|
|
1383
|
+
create: createCommand(),
|
|
1384
|
+
update: updateCommand(),
|
|
1385
|
+
archive: archiveCommand(true),
|
|
1386
|
+
unarchive: archiveCommand(false),
|
|
1387
|
+
delete: deleteCommand()
|
|
1388
|
+
}
|
|
1113
1389
|
});
|
|
1114
1390
|
}
|
|
1115
1391
|
|
|
@@ -1144,9 +1420,21 @@ function parseItem(raw) {
|
|
|
1144
1420
|
if (!description) throw new UsageError(t("cli_error_item_format", raw));
|
|
1145
1421
|
return discountPercent === void 0 ? { description, quantity, unitPrice } : { description, quantity, unitPrice, discountPercent };
|
|
1146
1422
|
}
|
|
1147
|
-
function
|
|
1148
|
-
|
|
1149
|
-
|
|
1423
|
+
function receiptItems(ids, combine) {
|
|
1424
|
+
const invalid = ids.find((id) => !isUuid(id.trim()));
|
|
1425
|
+
if (invalid !== void 0) throw new UsageError(t("cli_error_receipt_id", invalid));
|
|
1426
|
+
const unique = [...new Set(ids.map((id) => id.trim()))];
|
|
1427
|
+
if (unique.length === 0) return [];
|
|
1428
|
+
return combine ? [{ receiptIds: unique }] : unique.map((id) => ({ receiptIds: [id] }));
|
|
1429
|
+
}
|
|
1430
|
+
function keptItem(item) {
|
|
1431
|
+
return {
|
|
1432
|
+
description: item.description,
|
|
1433
|
+
quantity: item.quantity,
|
|
1434
|
+
unitPrice: item.unitPrice,
|
|
1435
|
+
...item.discountPercent != null ? { discountPercent: item.discountPercent } : {},
|
|
1436
|
+
...item.receiptIds?.length ? { receiptIds: item.receiptIds } : {}
|
|
1437
|
+
};
|
|
1150
1438
|
}
|
|
1151
1439
|
|
|
1152
1440
|
// src/commands/invoices.ts
|
|
@@ -1216,6 +1504,9 @@ function createCommand2() {
|
|
|
1216
1504
|
...commonArgs(),
|
|
1217
1505
|
customer: { type: "string", description: t("cli_flag_customer_ref") },
|
|
1218
1506
|
item: { type: "string", description: t("cli_flag_item") },
|
|
1507
|
+
receipt: { type: "string", description: t("cli_flag_receipt") },
|
|
1508
|
+
combine: { type: "boolean", description: t("cli_flag_combine"), default: false },
|
|
1509
|
+
"attach-receipts": { type: "boolean", description: t("cli_flag_attach_receipts"), default: false },
|
|
1219
1510
|
quote: { type: "boolean", description: t("cli_flag_quote"), default: false },
|
|
1220
1511
|
date: { type: "string", description: t("cli_flag_invoice_date") },
|
|
1221
1512
|
"payment-days": { type: "string", description: t("cli_flag_payment_days") },
|
|
@@ -1228,7 +1519,11 @@ function createCommand2() {
|
|
|
1228
1519
|
async run({ args }) {
|
|
1229
1520
|
const customerRef = optional(args.customer);
|
|
1230
1521
|
if (!customerRef) throw new UsageError(t("cli_error_customer_required"));
|
|
1231
|
-
const items =
|
|
1522
|
+
const items = [
|
|
1523
|
+
...toArray(args.item).map(parseItem),
|
|
1524
|
+
...receiptItems(toArray(args.receipt), Boolean(args.combine))
|
|
1525
|
+
];
|
|
1526
|
+
if (items.length === 0) throw new UsageError(t("cli_error_items_required"));
|
|
1232
1527
|
const api = client();
|
|
1233
1528
|
const customers = await api.getAllPages("/customers");
|
|
1234
1529
|
const customer = resolveCustomer(customerRef, customers);
|
|
@@ -1241,7 +1536,8 @@ function createCommand2() {
|
|
|
1241
1536
|
currency: optional(args.currency),
|
|
1242
1537
|
language: optional(args.language),
|
|
1243
1538
|
subtitle: optional(args.subtitle),
|
|
1244
|
-
reference: optional(args.reference)
|
|
1539
|
+
reference: optional(args.reference),
|
|
1540
|
+
attachReceipts: Boolean(args["attach-receipts"])
|
|
1245
1541
|
});
|
|
1246
1542
|
const pdfTarget = optional(args.pdf);
|
|
1247
1543
|
const savedTo = pdfTarget ? await savePdf(api, invoice.id, pdfTarget) : null;
|
|
@@ -1265,6 +1561,9 @@ function updateCommand2() {
|
|
|
1265
1561
|
...commonArgs(),
|
|
1266
1562
|
customer: { type: "string", description: t("cli_flag_customer_ref") },
|
|
1267
1563
|
item: { type: "string", description: t("cli_flag_item") },
|
|
1564
|
+
receipt: { type: "string", description: t("cli_flag_receipt") },
|
|
1565
|
+
combine: { type: "boolean", description: t("cli_flag_combine"), default: false },
|
|
1566
|
+
"attach-receipts": { type: "boolean", description: t("cli_flag_attach_receipts") },
|
|
1268
1567
|
date: { type: "string", description: t("cli_flag_invoice_date_update") },
|
|
1269
1568
|
"payment-days": { type: "string", description: t("cli_flag_payment_days") },
|
|
1270
1569
|
currency: { type: "string", description: t("cli_flag_currency") },
|
|
@@ -1277,12 +1576,16 @@ function updateCommand2() {
|
|
|
1277
1576
|
async run({ args }) {
|
|
1278
1577
|
const customerRef = optional(args.customer);
|
|
1279
1578
|
const rawItems = toArray(args.item);
|
|
1280
|
-
const
|
|
1579
|
+
const added = receiptItems(toArray(args.receipt), Boolean(args.combine));
|
|
1281
1580
|
const api = client();
|
|
1581
|
+
const invoiceRef = String(args.invoice);
|
|
1582
|
+
const base = rawItems.length > 0 ? rawItems.map(parseItem) : added.length > 0 ? (await api.get(`/invoices/${encodeURIComponent(invoiceRef)}`)).items.map(keptItem) : [];
|
|
1583
|
+
const items = rawItems.length > 0 || added.length > 0 ? [...base, ...added] : void 0;
|
|
1282
1584
|
const customerId = customerRef ? resolveCustomer(customerRef, await api.getAllPages("/customers")).id : void 0;
|
|
1283
1585
|
const payload = {};
|
|
1284
1586
|
if (customerId !== void 0) payload.customerId = customerId;
|
|
1285
1587
|
if (items !== void 0) payload.items = items;
|
|
1588
|
+
if (args["attach-receipts"] !== void 0) payload.attachReceipts = Boolean(args["attach-receipts"]);
|
|
1286
1589
|
const date = requireDate(optional(args.date));
|
|
1287
1590
|
if (date !== void 0) payload.date = date;
|
|
1288
1591
|
const paymentDays = requireNumber(optional(args["payment-days"]), "cli_error_price_invalid");
|
|
@@ -1300,7 +1603,7 @@ function updateCommand2() {
|
|
|
1300
1603
|
const vatRateRaw = providedValue(args["vat-rate"]);
|
|
1301
1604
|
if (vatRateRaw === "") payload.vatRate = "";
|
|
1302
1605
|
else if (vatRateRaw !== void 0) {
|
|
1303
|
-
payload.vatRate =
|
|
1606
|
+
payload.vatRate = requireVatRate(vatRateRaw);
|
|
1304
1607
|
}
|
|
1305
1608
|
if (Object.keys(payload).length === 0) {
|
|
1306
1609
|
throw new UsageError(t("cli_error_update_fields_required"));
|
|
@@ -1498,10 +1801,115 @@ function loginCommand() {
|
|
|
1498
1801
|
}
|
|
1499
1802
|
|
|
1500
1803
|
// src/commands/receipts.ts
|
|
1501
|
-
import { defineCommand as
|
|
1804
|
+
import { defineCommand as defineCommand6 } from "citty";
|
|
1502
1805
|
import { existsSync as existsSync2 } from "fs";
|
|
1503
1806
|
import { readFile } from "fs/promises";
|
|
1504
1807
|
import { basename, extname } from "path";
|
|
1808
|
+
|
|
1809
|
+
// src/lib/categories.ts
|
|
1810
|
+
function isOwnCategory(category) {
|
|
1811
|
+
return category.taxCategory == null;
|
|
1812
|
+
}
|
|
1813
|
+
function categoryName(category) {
|
|
1814
|
+
return [category.accountNumber?.trim(), category.name].filter(Boolean).join(" ");
|
|
1815
|
+
}
|
|
1816
|
+
function resolveCategory(reference, categories, taxCategory) {
|
|
1817
|
+
const needle = reference.trim().toLowerCase();
|
|
1818
|
+
const candidates = taxCategory ? categories.filter((category) => category.taxCategory === taxCategory) : categories;
|
|
1819
|
+
const byId = candidates.find((category) => category.id.toLowerCase() === needle);
|
|
1820
|
+
if (byId) return byId;
|
|
1821
|
+
const matches = needle ? candidates.filter(
|
|
1822
|
+
(category) => [category.name, category.accountNumber, categoryName(category)].some(
|
|
1823
|
+
(value) => value?.trim().toLowerCase() === needle
|
|
1824
|
+
)
|
|
1825
|
+
) : [];
|
|
1826
|
+
if (matches.length === 1) return matches[0];
|
|
1827
|
+
if (matches.length > 1) {
|
|
1828
|
+
const list = matches.map((category) => ` ${categoryName(category)} (${category.taxCategory ?? category.kind}) ${category.id}`).join("\n");
|
|
1829
|
+
throw new UsageError(`${t("cli_error_category_ambiguous", reference)}
|
|
1830
|
+
${list}`);
|
|
1831
|
+
}
|
|
1832
|
+
throw new UsageError(t("cli_error_category_not_found", reference));
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
// src/commands/vat.ts
|
|
1836
|
+
import { defineCommand as defineCommand5 } from "citty";
|
|
1837
|
+
function isVatOn(me) {
|
|
1838
|
+
return me?.vat?.method === "sss" || me?.vat?.method === "effective";
|
|
1839
|
+
}
|
|
1840
|
+
function vatProfileRows(profile) {
|
|
1841
|
+
const rows = [
|
|
1842
|
+
[t("cli_label_vat_method"), t(`cli_vat_method_${profile.method}`)],
|
|
1843
|
+
[t("cli_label_vat_since"), formatDate(profile.validFrom)]
|
|
1844
|
+
];
|
|
1845
|
+
if (profile.period) rows.push([t("cli_label_vat_period"), t(`cli_vat_period_${profile.period}`)]);
|
|
1846
|
+
rows.push([t("cli_label_vat_basis"), t(`cli_vat_basis_${profile.basis}`)]);
|
|
1847
|
+
if (profile.method === "sss" && profile.sssRates.length > 0) {
|
|
1848
|
+
const rates = profile.sssRates.map((r) => `${r.rate} %${r.activity ? ` (${r.activity})` : ""}`);
|
|
1849
|
+
rows.push([t("cli_label_vat_rates"), rates.join(", ")]);
|
|
1850
|
+
}
|
|
1851
|
+
return rows;
|
|
1852
|
+
}
|
|
1853
|
+
function vatBalance(snapshot) {
|
|
1854
|
+
if (snapshot["510"] != null && snapshot["510"] !== 0) return -snapshot["510"];
|
|
1855
|
+
return snapshot["500"] ?? 0;
|
|
1856
|
+
}
|
|
1857
|
+
function vatReturnsTable(returns) {
|
|
1858
|
+
const columns = [
|
|
1859
|
+
{ header: t("cli_col_period") },
|
|
1860
|
+
{ header: t("cli_col_method") },
|
|
1861
|
+
{ header: t("cli_col_vat_balance"), align: "right" },
|
|
1862
|
+
{ header: t("cli_col_filed") }
|
|
1863
|
+
];
|
|
1864
|
+
const rows = returns.map((r) => [
|
|
1865
|
+
`${formatDate(r.periodStart)} \u2013 ${formatDate(r.periodEnd)}`,
|
|
1866
|
+
t(`cli_vat_method_${r.method}`),
|
|
1867
|
+
formatMoney(vatBalance(r.snapshot), "CHF"),
|
|
1868
|
+
formatDate(r.filedAt)
|
|
1869
|
+
]);
|
|
1870
|
+
return table(columns, rows);
|
|
1871
|
+
}
|
|
1872
|
+
function vatCell(lines, isForeignService) {
|
|
1873
|
+
if (isForeignService) return t("cli_vat_reverse_charge");
|
|
1874
|
+
if (!lines || lines.length === 0) return "";
|
|
1875
|
+
const vat = lines.reduce((sum, line) => sum + line.vat, 0);
|
|
1876
|
+
return `${formatMoney(vat, null)} (${lines.map((l) => l.rate).join("/")} %)`;
|
|
1877
|
+
}
|
|
1878
|
+
function vatCommand() {
|
|
1879
|
+
return defineCommand5({
|
|
1880
|
+
meta: { name: "vat", description: t("cli_cmd_vat") },
|
|
1881
|
+
args: commonArgs(),
|
|
1882
|
+
async run({ args }) {
|
|
1883
|
+
const api = client();
|
|
1884
|
+
const [me, returns] = await Promise.all([
|
|
1885
|
+
api.get("/me"),
|
|
1886
|
+
api.getAllPages("/vat-returns")
|
|
1887
|
+
]);
|
|
1888
|
+
const profile = isVatOn(me) ? me.vat ?? null : null;
|
|
1889
|
+
if (args.json) {
|
|
1890
|
+
printJson({ profile, returns });
|
|
1891
|
+
return;
|
|
1892
|
+
}
|
|
1893
|
+
if (!profile) {
|
|
1894
|
+
out(t("cli_vat_not_set"));
|
|
1895
|
+
} else {
|
|
1896
|
+
const rows = vatProfileRows(profile);
|
|
1897
|
+
const width = Math.max(...rows.map(([label]) => label.length));
|
|
1898
|
+
for (const [label, value] of rows) out(`${label.padEnd(width)} ${value}`);
|
|
1899
|
+
}
|
|
1900
|
+
if (returns.length === 0) {
|
|
1901
|
+
if (profile) out(`
|
|
1902
|
+
${t("cli_empty_vat_returns")}`);
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
1905
|
+
out(`
|
|
1906
|
+
${t("cli_vat_returns_heading")}`);
|
|
1907
|
+
out(vatReturnsTable(returns));
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1912
|
+
// src/commands/receipts.ts
|
|
1505
1913
|
var MIME_TYPES = {
|
|
1506
1914
|
".jpg": "image/jpeg",
|
|
1507
1915
|
".jpeg": "image/jpeg",
|
|
@@ -1509,19 +1917,30 @@ var MIME_TYPES = {
|
|
|
1509
1917
|
".webp": "image/webp",
|
|
1510
1918
|
".pdf": "application/pdf"
|
|
1511
1919
|
};
|
|
1512
|
-
function
|
|
1920
|
+
function fetchCategories() {
|
|
1921
|
+
return client().getAllPages("/custom-categories", { includeArchived: true });
|
|
1922
|
+
}
|
|
1923
|
+
function categoryLabel(receipt, categories) {
|
|
1924
|
+
const category = categories.find((candidate) => candidate.id === receipt.customCategoryId);
|
|
1925
|
+
if (category && isOwnCategory(category)) return categoryName(category);
|
|
1926
|
+
return [receipt.taxCategory, category?.name].filter(Boolean).join(" \xB7 ");
|
|
1927
|
+
}
|
|
1928
|
+
function receiptTable(receipts, categories, showVat) {
|
|
1513
1929
|
const columns = [
|
|
1514
1930
|
{ header: t("cli_col_date") },
|
|
1515
1931
|
{ header: t("cli_col_seller") },
|
|
1516
1932
|
{ header: t("cli_col_amount"), align: "right" },
|
|
1933
|
+
...showVat ? [{ header: t("cli_col_vat") }] : [],
|
|
1517
1934
|
{ header: t("cli_col_category") },
|
|
1518
1935
|
{ header: t("cli_col_id") }
|
|
1519
1936
|
];
|
|
1520
1937
|
const rows = receipts.map((receipt) => [
|
|
1521
1938
|
formatDate(receipt.date),
|
|
1522
1939
|
receipt.seller ?? "",
|
|
1523
|
-
|
|
1524
|
-
receipt.
|
|
1940
|
+
// A correction is stored positive but lowers its category, so mark it as a reduction.
|
|
1941
|
+
formatMoney(receipt.price, receipt.currency) + (receipt.isCorrection ? " \u2193" : ""),
|
|
1942
|
+
...showVat ? [vatCell(receipt.vatLines, receipt.isForeignService)] : [],
|
|
1943
|
+
categoryLabel(receipt, categories),
|
|
1525
1944
|
receipt.id
|
|
1526
1945
|
]);
|
|
1527
1946
|
return table(columns, rows);
|
|
@@ -1533,23 +1952,34 @@ function summarize(receipt) {
|
|
|
1533
1952
|
);
|
|
1534
1953
|
}
|
|
1535
1954
|
function listCommand3() {
|
|
1536
|
-
return
|
|
1955
|
+
return defineCommand6({
|
|
1537
1956
|
meta: { name: "ls", description: t("cli_cmd_receipts_ls") },
|
|
1538
1957
|
args: {
|
|
1539
1958
|
...commonArgs(),
|
|
1540
1959
|
month: { type: "string", description: t("cli_flag_month") },
|
|
1541
1960
|
from: { type: "string", description: t("cli_flag_from") },
|
|
1542
1961
|
to: { type: "string", description: t("cli_flag_to") },
|
|
1543
|
-
project: { type: "string", description: t("cli_flag_project") }
|
|
1962
|
+
project: { type: "string", description: t("cli_flag_project") },
|
|
1963
|
+
category: { type: "string", description: t("cli_flag_category") }
|
|
1544
1964
|
},
|
|
1545
1965
|
async run({ args }) {
|
|
1546
1966
|
const month = optional(args.month);
|
|
1547
1967
|
const range = month ? monthRange(month) : void 0;
|
|
1548
|
-
const
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1968
|
+
const categoryRef = optional(args.category);
|
|
1969
|
+
const from = range?.from ?? requireDate(optional(args.from));
|
|
1970
|
+
const to = range?.to ?? requireDate(optional(args.to));
|
|
1971
|
+
const categories = categoryRef || !args.json ? await fetchCategories() : [];
|
|
1972
|
+
const customCategoryId = categoryRef ? resolveCategory(categoryRef, categories).id : void 0;
|
|
1973
|
+
const api = client();
|
|
1974
|
+
const [items, me] = await Promise.all([
|
|
1975
|
+
api.getAllPages("/receipts", {
|
|
1976
|
+
from,
|
|
1977
|
+
to,
|
|
1978
|
+
projectId: optional(args.project),
|
|
1979
|
+
customCategoryId
|
|
1980
|
+
}),
|
|
1981
|
+
args.json ? void 0 : api.get("/me")
|
|
1982
|
+
]);
|
|
1553
1983
|
if (args.json) {
|
|
1554
1984
|
printJson({ items });
|
|
1555
1985
|
return;
|
|
@@ -1558,12 +1988,12 @@ function listCommand3() {
|
|
|
1558
1988
|
out(t("cli_empty_receipts"));
|
|
1559
1989
|
return;
|
|
1560
1990
|
}
|
|
1561
|
-
out(receiptTable(items));
|
|
1991
|
+
out(receiptTable(items, categories, isVatOn(me)));
|
|
1562
1992
|
}
|
|
1563
1993
|
});
|
|
1564
1994
|
}
|
|
1565
1995
|
function addCommand() {
|
|
1566
|
-
return
|
|
1996
|
+
return defineCommand6({
|
|
1567
1997
|
meta: { name: "add", description: t("cli_cmd_receipts_add") },
|
|
1568
1998
|
args: {
|
|
1569
1999
|
...commonArgs(),
|
|
@@ -1573,6 +2003,8 @@ function addCommand() {
|
|
|
1573
2003
|
currency: { type: "string", description: t("cli_flag_currency") },
|
|
1574
2004
|
category: { type: "string", description: t("cli_flag_category") },
|
|
1575
2005
|
"tax-category": { type: "string", description: t("cli_flag_tax_category") },
|
|
2006
|
+
correction: { type: "boolean", description: t("cli_flag_correction") },
|
|
2007
|
+
"vat-rate": { type: "string", description: t("cli_flag_receipt_vat_rate") },
|
|
1576
2008
|
"booking-text": { type: "string", description: t("cli_flag_booking_text") },
|
|
1577
2009
|
project: { type: "string", description: t("cli_flag_project") },
|
|
1578
2010
|
customer: { type: "string", description: t("cli_flag_customer_ref") }
|
|
@@ -1583,6 +2015,7 @@ function addCommand() {
|
|
|
1583
2015
|
if (!seller) throw new UsageError(t("cli_error_seller_required"));
|
|
1584
2016
|
if (!rawPrice) throw new UsageError(t("cli_error_price_required"));
|
|
1585
2017
|
const price = requireNumber(rawPrice, "cli_error_price_invalid");
|
|
2018
|
+
const vatRate = requireVatRate(optional(args["vat-rate"]));
|
|
1586
2019
|
const api = client();
|
|
1587
2020
|
const customerRef = optional(args.customer);
|
|
1588
2021
|
let customerId;
|
|
@@ -1590,13 +2023,23 @@ function addCommand() {
|
|
|
1590
2023
|
const customers = await api.getAllPages("/customers");
|
|
1591
2024
|
customerId = resolveCustomer(customerRef, customers).id;
|
|
1592
2025
|
}
|
|
2026
|
+
let taxCategory = optional(args["tax-category"]);
|
|
2027
|
+
const categoryRef = optional(args.category);
|
|
2028
|
+
let customCategoryId;
|
|
2029
|
+
if (categoryRef) {
|
|
2030
|
+
const category = resolveCategory(categoryRef, await fetchCategories(), taxCategory);
|
|
2031
|
+
customCategoryId = category.id;
|
|
2032
|
+
taxCategory = category.taxCategory ?? void 0;
|
|
2033
|
+
}
|
|
1593
2034
|
const receipt = await api.post("/receipts", {
|
|
1594
2035
|
seller,
|
|
1595
2036
|
price,
|
|
1596
2037
|
date: requireDate(optional(args.date)),
|
|
1597
2038
|
currency: optional(args.currency),
|
|
1598
|
-
|
|
1599
|
-
|
|
2039
|
+
taxCategory,
|
|
2040
|
+
customCategoryId,
|
|
2041
|
+
isCorrection: args.correction ? true : void 0,
|
|
2042
|
+
vatLines: vatRate === void 0 || price === void 0 ? void 0 : vatLinesFor(price, vatRate),
|
|
1600
2043
|
bookingText: optional(args["booking-text"]),
|
|
1601
2044
|
projectId: optional(args.project),
|
|
1602
2045
|
customerId
|
|
@@ -1606,8 +2049,69 @@ function addCommand() {
|
|
|
1606
2049
|
}
|
|
1607
2050
|
});
|
|
1608
2051
|
}
|
|
2052
|
+
function receiptUpdatePayload(args) {
|
|
2053
|
+
const payload = {};
|
|
2054
|
+
const date = requireDate(optional(args.date));
|
|
2055
|
+
if (date) payload.date = date;
|
|
2056
|
+
const price = requireNumber(optional(args.price), "cli_error_price_invalid");
|
|
2057
|
+
if (price !== void 0) payload.price = price;
|
|
2058
|
+
const exchangeRate = requireNumber(optional(args["exchange-rate"]), "cli_error_exchange_rate_invalid");
|
|
2059
|
+
if (exchangeRate !== void 0) {
|
|
2060
|
+
if (exchangeRate <= 0) throw new UsageError(t("cli_error_exchange_rate_invalid", String(exchangeRate)));
|
|
2061
|
+
payload.exchangeRate = exchangeRate;
|
|
2062
|
+
}
|
|
2063
|
+
const seller = providedValue(args.seller);
|
|
2064
|
+
if (seller !== void 0) payload.seller = seller || null;
|
|
2065
|
+
const bookingText = providedValue(args["booking-text"]);
|
|
2066
|
+
if (bookingText !== void 0) payload.bookingText = bookingText || null;
|
|
2067
|
+
const project = providedValue(args.project);
|
|
2068
|
+
if (project !== void 0) payload.projectId = project || null;
|
|
2069
|
+
const vatRate = requireVatRate(optional(args["vat-rate"]));
|
|
2070
|
+
if (vatRate !== void 0) {
|
|
2071
|
+
if (vatRate === 0) payload.vatLines = [];
|
|
2072
|
+
else if (price !== void 0) payload.vatLines = vatLinesFor(price, vatRate);
|
|
2073
|
+
}
|
|
2074
|
+
if (Object.keys(payload).length === 0 && providedValue(args.customer) === void 0 && vatRate === void 0) {
|
|
2075
|
+
throw new UsageError(t("cli_error_receipt_nothing_to_change"));
|
|
2076
|
+
}
|
|
2077
|
+
return payload;
|
|
2078
|
+
}
|
|
2079
|
+
function editCommand() {
|
|
2080
|
+
return defineCommand6({
|
|
2081
|
+
meta: { name: "edit", description: t("cli_cmd_receipts_edit") },
|
|
2082
|
+
args: {
|
|
2083
|
+
receipt: { type: "positional", description: t("cli_arg_receipt_id"), required: true },
|
|
2084
|
+
...commonArgs(),
|
|
2085
|
+
seller: { type: "string", description: t("cli_flag_seller") },
|
|
2086
|
+
price: { type: "string", description: t("cli_flag_price") },
|
|
2087
|
+
date: { type: "string", description: t("cli_flag_edit_date") },
|
|
2088
|
+
"vat-rate": { type: "string", description: t("cli_flag_receipt_vat_rate") },
|
|
2089
|
+
"booking-text": { type: "string", description: t("cli_flag_booking_text") },
|
|
2090
|
+
"exchange-rate": { type: "string", description: t("cli_flag_exchange_rate") },
|
|
2091
|
+
project: { type: "string", description: t("cli_flag_project") },
|
|
2092
|
+
customer: { type: "string", description: t("cli_flag_customer_ref") }
|
|
2093
|
+
},
|
|
2094
|
+
async run({ args }) {
|
|
2095
|
+
const payload = receiptUpdatePayload(args);
|
|
2096
|
+
const api = client();
|
|
2097
|
+
const id = encodeURIComponent(String(args.receipt));
|
|
2098
|
+
const vatRate = requireVatRate(optional(args["vat-rate"]));
|
|
2099
|
+
if (vatRate !== void 0 && vatRate !== 0 && payload.vatLines === void 0) {
|
|
2100
|
+
const existing = await api.get(`/receipts/${id}`);
|
|
2101
|
+
payload.vatLines = vatLinesFor(existing.price, vatRate);
|
|
2102
|
+
}
|
|
2103
|
+
const customerRef = providedValue(args.customer);
|
|
2104
|
+
if (customerRef !== void 0) {
|
|
2105
|
+
payload.customerId = customerRef === "" || isUuid(customerRef) ? customerRef || null : resolveCustomer(customerRef, await api.getAllPages("/customers")).id;
|
|
2106
|
+
}
|
|
2107
|
+
const receipt = await api.patch(`/receipts/${id}`, payload);
|
|
2108
|
+
if (args.json) printJson(receipt);
|
|
2109
|
+
else out(t("cli_receipt_updated", formatDate(receipt.date), summarize(receipt)));
|
|
2110
|
+
}
|
|
2111
|
+
});
|
|
2112
|
+
}
|
|
1609
2113
|
function scanCommand() {
|
|
1610
|
-
return
|
|
2114
|
+
return defineCommand6({
|
|
1611
2115
|
meta: { name: "scan", description: t("cli_cmd_receipts_scan") },
|
|
1612
2116
|
args: {
|
|
1613
2117
|
files: { type: "positional", description: t("cli_arg_scan_files"), required: false },
|
|
@@ -1634,18 +2138,19 @@ function scanCommand() {
|
|
|
1634
2138
|
});
|
|
1635
2139
|
}
|
|
1636
2140
|
function receiptsCommand() {
|
|
1637
|
-
return
|
|
2141
|
+
return defineCommand6({
|
|
1638
2142
|
meta: { name: "receipts", description: t("cli_cmd_receipts") },
|
|
1639
2143
|
subCommands: {
|
|
1640
2144
|
ls: listCommand3(),
|
|
1641
2145
|
add: addCommand(),
|
|
2146
|
+
edit: editCommand(),
|
|
1642
2147
|
scan: scanCommand()
|
|
1643
2148
|
}
|
|
1644
2149
|
});
|
|
1645
2150
|
}
|
|
1646
2151
|
|
|
1647
2152
|
// src/cli.ts
|
|
1648
|
-
var VERSION = "0.
|
|
2153
|
+
var VERSION = "0.5.0";
|
|
1649
2154
|
var argv = process.argv.slice(2);
|
|
1650
2155
|
setLocale(resolveLocale(langFromArgv(argv)));
|
|
1651
2156
|
function withoutLangFlag(rawArgs) {
|
|
@@ -1662,7 +2167,7 @@ function withoutLangFlag(rawArgs) {
|
|
|
1662
2167
|
return kept;
|
|
1663
2168
|
}
|
|
1664
2169
|
var cliArgs = withoutLangFlag(argv);
|
|
1665
|
-
var main =
|
|
2170
|
+
var main = defineCommand7({
|
|
1666
2171
|
meta: { name: "bonbox", version: VERSION, description: t("cli_app_description") },
|
|
1667
2172
|
subCommands: {
|
|
1668
2173
|
login: loginCommand(),
|
|
@@ -1670,7 +2175,8 @@ var main = defineCommand6({
|
|
|
1670
2175
|
whoami: whoamiCommand(),
|
|
1671
2176
|
customers: customersCommand(),
|
|
1672
2177
|
invoices: invoicesCommand(),
|
|
1673
|
-
receipts: receiptsCommand()
|
|
2178
|
+
receipts: receiptsCommand(),
|
|
2179
|
+
vat: vatCommand()
|
|
1674
2180
|
}
|
|
1675
2181
|
});
|
|
1676
2182
|
async function resolveSubCommand(command, rawArgs, parent) {
|