bonbox 0.2.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 +58 -3
- package/dist/cli.js +844 -92
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
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";
|
|
@@ -38,15 +38,22 @@ var en_default = {
|
|
|
38
38
|
cli_cmd_whoami: "Show the account you are signed in with",
|
|
39
39
|
cli_cmd_customers: "Work with your customers",
|
|
40
40
|
cli_cmd_customers_ls: "List your customers",
|
|
41
|
+
cli_cmd_customers_create: "Create a customer",
|
|
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",
|
|
41
46
|
cli_cmd_invoices: "Work with your invoices and quotes",
|
|
42
47
|
cli_cmd_invoices_ls: "List invoices and quotes",
|
|
43
48
|
cli_cmd_invoices_create: "Create an invoice or a quote",
|
|
49
|
+
cli_cmd_invoices_update: "Update an invoice or quote",
|
|
44
50
|
cli_cmd_invoices_pdf: "Download the PDF of an invoice or quote",
|
|
45
51
|
cli_cmd_invoices_paid: "Mark an invoice as paid",
|
|
46
52
|
cli_cmd_invoices_unpaid: "Mark an invoice as unpaid again",
|
|
47
53
|
cli_cmd_receipts: "Work with your receipts",
|
|
48
54
|
cli_cmd_receipts_ls: "List your receipts",
|
|
49
55
|
cli_cmd_receipts_add: "Add a receipt by hand",
|
|
56
|
+
cli_cmd_receipts_edit: "Change a receipt",
|
|
50
57
|
cli_cmd_receipts_scan: "Upload a receipt and let bonbox read it",
|
|
51
58
|
cli_flag_json: "Print the raw API response as JSON",
|
|
52
59
|
cli_flag_lang: "Output language (en, de, fr, it)",
|
|
@@ -54,14 +61,27 @@ var en_default = {
|
|
|
54
61
|
cli_flag_status: "Filter by status: created or paid",
|
|
55
62
|
cli_flag_quotes: "Show quotes instead of invoices",
|
|
56
63
|
cli_flag_customer_ref: "Customer name or ID",
|
|
64
|
+
cli_flag_name: "Customer name",
|
|
65
|
+
cli_flag_department: "Department",
|
|
66
|
+
cli_flag_extra_line: "Additional line under the address (e.g. PSP element)",
|
|
67
|
+
cli_flag_address: "Street address",
|
|
68
|
+
cli_flag_postal_code: "Postal code",
|
|
69
|
+
cli_flag_city: "City",
|
|
70
|
+
cli_flag_country: "Country code, for example CH",
|
|
57
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",
|
|
58
75
|
cli_flag_quote: "Create a quote instead of an invoice",
|
|
59
76
|
cli_flag_invoice_date: "Invoice date (YYYY-MM-DD), today by default",
|
|
77
|
+
cli_flag_invoice_date_update: "Invoice date (YYYY-MM-DD)",
|
|
60
78
|
cli_flag_payment_days: "Payment term in days",
|
|
61
79
|
cli_flag_currency: "Currency code, for example CHF",
|
|
62
80
|
cli_flag_language: "Document language: de, en, fr or it",
|
|
63
81
|
cli_flag_subtitle: "Subtitle shown on the document",
|
|
64
82
|
cli_flag_reference: "Your reference for this document",
|
|
83
|
+
cli_flag_vat_rate: "VAT rate in percent, for example 8.1",
|
|
84
|
+
cli_flag_custom_notes: "Custom notes shown on the document",
|
|
65
85
|
cli_flag_pdf: "Also save the PDF to this file",
|
|
66
86
|
cli_flag_output: "Save the PDF to this file",
|
|
67
87
|
cli_flag_paid_date: "Payment date (YYYY-MM-DD), today by default",
|
|
@@ -73,11 +93,16 @@ var en_default = {
|
|
|
73
93
|
cli_flag_seller: "Seller, or the customer for income",
|
|
74
94
|
cli_flag_price: "Amount, for example 23.50",
|
|
75
95
|
cli_flag_receipt_date: "Receipt date (YYYY-MM-DD), today by default",
|
|
76
|
-
|
|
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",
|
|
77
99
|
cli_flag_tax_category: "Tax category",
|
|
100
|
+
cli_flag_correction: "Book as a correction entry (expense reduction)",
|
|
78
101
|
cli_flag_booking_text: "Booking text",
|
|
79
102
|
cli_arg_invoice_ref: "Invoice number or ID",
|
|
103
|
+
cli_arg_customer_ref: "Customer name or ID",
|
|
80
104
|
cli_arg_scan_files: "Image or PDF files, all pages of one receipt",
|
|
105
|
+
cli_arg_receipt_id: "Receipt ID",
|
|
81
106
|
cli_error_unauthorized: "You are not signed in. Run: bonbox login",
|
|
82
107
|
cli_error_pro_required: "This needs bonbox Pro. You can upgrade at %1$s",
|
|
83
108
|
cli_error_quota: "You have reached the limit of your plan. You can upgrade at %1$s",
|
|
@@ -85,15 +110,26 @@ var en_default = {
|
|
|
85
110
|
cli_error_unexpected_response: "Unexpected answer from bonbox (HTTP %1$s)",
|
|
86
111
|
cli_error_item_format: 'Invalid item "%1$s". Expected description:quantity:unitPrice[:discount%]',
|
|
87
112
|
cli_error_item_number: 'Invalid number in item "%1$s"',
|
|
88
|
-
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",
|
|
89
115
|
cli_error_customer_required: "Name a customer with --customer",
|
|
116
|
+
cli_error_name_required: "Give a name with --name",
|
|
117
|
+
cli_error_address_required: "Give an address with --address",
|
|
118
|
+
cli_error_postal_code_required: "Give a postal code with --postal-code",
|
|
119
|
+
cli_error_city_required: "Give a city with --city",
|
|
120
|
+
cli_error_update_fields_required: "Give at least one field to update",
|
|
90
121
|
cli_error_price_required: "Give an amount with --price",
|
|
91
122
|
cli_error_seller_required: "Give a seller with --seller",
|
|
92
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",
|
|
93
126
|
cli_error_date_invalid: "Invalid date: %1$s. Expected YYYY-MM-DD",
|
|
94
127
|
cli_error_month_invalid: "Invalid month: %1$s. Expected YYYY-MM",
|
|
95
128
|
cli_error_customer_not_found: 'No customer matches "%1$s"',
|
|
96
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:',
|
|
97
133
|
cli_error_files_required: "Name at least one file to scan",
|
|
98
134
|
cli_error_file_missing: "File not found: %1$s",
|
|
99
135
|
cli_login_opening: "Opening the bonbox sign-in page in your browser ...",
|
|
@@ -136,14 +172,47 @@ var en_default = {
|
|
|
136
172
|
cli_empty_invoices: "No invoices yet.",
|
|
137
173
|
cli_empty_quotes: "No quotes yet.",
|
|
138
174
|
cli_empty_receipts: "No receipts found.",
|
|
175
|
+
cli_customer_created: "Customer %1$s created.",
|
|
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.",
|
|
139
180
|
cli_invoice_created: "Invoice %1$s created, %2$s",
|
|
140
181
|
cli_quote_created: "Quote %1$s created, %2$s",
|
|
141
182
|
cli_pdf_saved: "Saved to %1$s",
|
|
183
|
+
cli_invoice_updated: "Invoice %1$s updated.",
|
|
184
|
+
cli_quote_updated: "Quote %1$s updated.",
|
|
142
185
|
cli_invoice_paid: "%1$s marked as paid.",
|
|
143
186
|
cli_invoice_unpaid: "%1$s marked as unpaid.",
|
|
144
187
|
cli_receipt_added: "Receipt saved: %1$s, %2$s",
|
|
188
|
+
cli_receipt_updated: "Receipt updated: %1$s, %2$s",
|
|
145
189
|
cli_scan_uploading: "Uploading %1$s file(s) ...",
|
|
146
|
-
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"
|
|
147
216
|
};
|
|
148
217
|
|
|
149
218
|
// src/i18n/de.json
|
|
@@ -154,15 +223,22 @@ var de_default = {
|
|
|
154
223
|
cli_cmd_whoami: "Zeigt das angemeldete Konto",
|
|
155
224
|
cli_cmd_customers: "Kunden verwalten",
|
|
156
225
|
cli_cmd_customers_ls: "Kunden auflisten",
|
|
226
|
+
cli_cmd_customers_create: "Kunde erstellen",
|
|
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",
|
|
157
231
|
cli_cmd_invoices: "Rechnungen und Offerten verwalten",
|
|
158
232
|
cli_cmd_invoices_ls: "Rechnungen und Offerten auflisten",
|
|
159
233
|
cli_cmd_invoices_create: "Rechnung oder Offerte erstellen",
|
|
234
|
+
cli_cmd_invoices_update: "Rechnung oder Offerte aktualisieren",
|
|
160
235
|
cli_cmd_invoices_pdf: "PDF einer Rechnung oder Offerte herunterladen",
|
|
161
236
|
cli_cmd_invoices_paid: "Rechnung als bezahlt markieren",
|
|
162
237
|
cli_cmd_invoices_unpaid: "Rechnung wieder als offen markieren",
|
|
163
238
|
cli_cmd_receipts: "Belege verwalten",
|
|
164
239
|
cli_cmd_receipts_ls: "Belege auflisten",
|
|
165
240
|
cli_cmd_receipts_add: "Beleg von Hand erfassen",
|
|
241
|
+
cli_cmd_receipts_edit: "Beleg \xE4ndern",
|
|
166
242
|
cli_cmd_receipts_scan: "Beleg hochladen und von bonbox auslesen lassen",
|
|
167
243
|
cli_flag_json: "Antwort der API als reines JSON ausgeben",
|
|
168
244
|
cli_flag_lang: "Sprache der Ausgabe (en, de, fr, it)",
|
|
@@ -170,14 +246,27 @@ var de_default = {
|
|
|
170
246
|
cli_flag_status: "Nach Status filtern: created oder paid",
|
|
171
247
|
cli_flag_quotes: "Offerten statt Rechnungen anzeigen",
|
|
172
248
|
cli_flag_customer_ref: "Kundenname oder Kunden-ID",
|
|
249
|
+
cli_flag_name: "Kundenname",
|
|
250
|
+
cli_flag_department: "Abteilung",
|
|
251
|
+
cli_flag_extra_line: "Zusatzzeile unter der Adresse (z.B. PSP-Element)",
|
|
252
|
+
cli_flag_address: "Strasse und Hausnummer",
|
|
253
|
+
cli_flag_postal_code: "Postleitzahl",
|
|
254
|
+
cli_flag_city: "Ort",
|
|
255
|
+
cli_flag_country: "L\xE4ndercode, zum Beispiel CH",
|
|
173
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",
|
|
174
260
|
cli_flag_quote: "Offerte statt Rechnung erstellen",
|
|
175
261
|
cli_flag_invoice_date: "Rechnungsdatum (JJJJ-MM-TT), standardm\xE4ssig heute",
|
|
262
|
+
cli_flag_invoice_date_update: "Rechnungsdatum (JJJJ-MM-TT)",
|
|
176
263
|
cli_flag_payment_days: "Zahlungsfrist in Tagen",
|
|
177
264
|
cli_flag_currency: "W\xE4hrung, zum Beispiel CHF",
|
|
178
265
|
cli_flag_language: "Sprache des Dokuments: de, en, fr oder it",
|
|
179
266
|
cli_flag_subtitle: "Untertitel auf dem Dokument",
|
|
180
267
|
cli_flag_reference: "Ihre Referenz f\xFCr dieses Dokument",
|
|
268
|
+
cli_flag_vat_rate: "Mehrwertsteuersatz in Prozent, zum Beispiel 8.1",
|
|
269
|
+
cli_flag_custom_notes: "Eigene Notizen auf dem Dokument",
|
|
181
270
|
cli_flag_pdf: "PDF zus\xE4tzlich in diese Datei speichern",
|
|
182
271
|
cli_flag_output: "PDF in diese Datei speichern",
|
|
183
272
|
cli_flag_paid_date: "Zahlungsdatum (JJJJ-MM-TT), standardm\xE4ssig heute",
|
|
@@ -189,11 +278,16 @@ var de_default = {
|
|
|
189
278
|
cli_flag_seller: "Anbieter, bei Einnahmen der Kunde",
|
|
190
279
|
cli_flag_price: "Betrag, zum Beispiel 23.50",
|
|
191
280
|
cli_flag_receipt_date: "Belegdatum (JJJJ-MM-TT), standardm\xE4ssig heute",
|
|
192
|
-
|
|
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",
|
|
193
284
|
cli_flag_tax_category: "Steuerkategorie",
|
|
285
|
+
cli_flag_correction: "Als Korrekturbuchung erfassen (Aufwandminderung)",
|
|
194
286
|
cli_flag_booking_text: "Buchungstext",
|
|
195
287
|
cli_arg_invoice_ref: "Rechnungsnummer oder ID",
|
|
288
|
+
cli_arg_customer_ref: "Kundenname oder ID",
|
|
196
289
|
cli_arg_scan_files: "Bild- oder PDF-Dateien, alle Seiten eines Belegs",
|
|
290
|
+
cli_arg_receipt_id: "Beleg-ID",
|
|
197
291
|
cli_error_unauthorized: "Sie sind nicht angemeldet. F\xFChren Sie aus: bonbox login",
|
|
198
292
|
cli_error_pro_required: "Daf\xFCr wird bonbox Pro ben\xF6tigt. Upgrade unter %1$s",
|
|
199
293
|
cli_error_quota: "Das Limit Ihres Abos ist erreicht. Upgrade unter %1$s",
|
|
@@ -201,15 +295,26 @@ var de_default = {
|
|
|
201
295
|
cli_error_unexpected_response: "Unerwartete Antwort von bonbox (HTTP %1$s)",
|
|
202
296
|
cli_error_item_format: 'Ung\xFCltige Position "%1$s". Erwartet: Beschreibung:Menge:Einzelpreis[:Rabatt%]',
|
|
203
297
|
cli_error_item_number: 'Ung\xFCltige Zahl in Position "%1$s"',
|
|
204
|
-
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",
|
|
205
300
|
cli_error_customer_required: "Geben Sie einen Kunden mit --customer an",
|
|
301
|
+
cli_error_name_required: "Geben Sie einen Namen mit --name an",
|
|
302
|
+
cli_error_address_required: "Geben Sie eine Adresse mit --address an",
|
|
303
|
+
cli_error_postal_code_required: "Geben Sie eine Postleitzahl mit --postal-code an",
|
|
304
|
+
cli_error_city_required: "Geben Sie einen Ort mit --city an",
|
|
305
|
+
cli_error_update_fields_required: "Geben Sie mindestens ein zu \xE4nderndes Feld an",
|
|
206
306
|
cli_error_price_required: "Geben Sie einen Betrag mit --price an",
|
|
207
307
|
cli_error_seller_required: "Geben Sie einen Anbieter mit --seller an",
|
|
208
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",
|
|
209
311
|
cli_error_date_invalid: "Ung\xFCltiges Datum: %1$s. Erwartet: JJJJ-MM-TT",
|
|
210
312
|
cli_error_month_invalid: "Ung\xFCltiger Monat: %1$s. Erwartet: JJJJ-MM",
|
|
211
313
|
cli_error_customer_not_found: 'Kein Kunde passt zu "%1$s"',
|
|
212
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:',
|
|
213
318
|
cli_error_files_required: "Geben Sie mindestens eine Datei zum Scannen an",
|
|
214
319
|
cli_error_file_missing: "Datei nicht gefunden: %1$s",
|
|
215
320
|
cli_login_opening: "Die bonbox-Anmeldeseite wird im Browser ge\xF6ffnet ...",
|
|
@@ -252,14 +357,47 @@ var de_default = {
|
|
|
252
357
|
cli_empty_invoices: "Noch keine Rechnungen.",
|
|
253
358
|
cli_empty_quotes: "Noch keine Offerten.",
|
|
254
359
|
cli_empty_receipts: "Keine Belege gefunden.",
|
|
360
|
+
cli_customer_created: "Kunde %1$s erstellt.",
|
|
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.",
|
|
255
365
|
cli_invoice_created: "Rechnung %1$s erstellt, %2$s",
|
|
256
366
|
cli_quote_created: "Offerte %1$s erstellt, %2$s",
|
|
257
367
|
cli_pdf_saved: "Gespeichert unter %1$s",
|
|
368
|
+
cli_invoice_updated: "Rechnung %1$s aktualisiert.",
|
|
369
|
+
cli_quote_updated: "Offerte %1$s aktualisiert.",
|
|
258
370
|
cli_invoice_paid: "%1$s als bezahlt markiert.",
|
|
259
371
|
cli_invoice_unpaid: "%1$s als offen markiert.",
|
|
260
372
|
cli_receipt_added: "Beleg gespeichert: %1$s, %2$s",
|
|
373
|
+
cli_receipt_updated: "Beleg aktualisiert: %1$s, %2$s",
|
|
261
374
|
cli_scan_uploading: "%1$s Datei(en) werden hochgeladen ...",
|
|
262
|
-
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"
|
|
263
401
|
};
|
|
264
402
|
|
|
265
403
|
// src/i18n/fr.json
|
|
@@ -270,15 +408,22 @@ var fr_default = {
|
|
|
270
408
|
cli_cmd_whoami: "Afficher le compte connect\xE9",
|
|
271
409
|
cli_cmd_customers: "G\xE9rer vos clients",
|
|
272
410
|
cli_cmd_customers_ls: "Lister vos clients",
|
|
411
|
+
cli_cmd_customers_create: "Cr\xE9er un client",
|
|
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",
|
|
273
416
|
cli_cmd_invoices: "G\xE9rer vos factures et devis",
|
|
274
417
|
cli_cmd_invoices_ls: "Lister les factures et devis",
|
|
275
418
|
cli_cmd_invoices_create: "Cr\xE9er une facture ou un devis",
|
|
419
|
+
cli_cmd_invoices_update: "Mettre \xE0 jour une facture ou un devis",
|
|
276
420
|
cli_cmd_invoices_pdf: "T\xE9l\xE9charger le PDF d'une facture ou d'un devis",
|
|
277
421
|
cli_cmd_invoices_paid: "Marquer une facture comme pay\xE9e",
|
|
278
422
|
cli_cmd_invoices_unpaid: "Remettre une facture en attente de paiement",
|
|
279
423
|
cli_cmd_receipts: "G\xE9rer vos justificatifs",
|
|
280
424
|
cli_cmd_receipts_ls: "Lister vos justificatifs",
|
|
281
425
|
cli_cmd_receipts_add: "Saisir un justificatif manuellement",
|
|
426
|
+
cli_cmd_receipts_edit: "Modifier un justificatif",
|
|
282
427
|
cli_cmd_receipts_scan: "Envoyer un justificatif et le faire lire par bonbox",
|
|
283
428
|
cli_flag_json: "Afficher la r\xE9ponse brute de l'API en JSON",
|
|
284
429
|
cli_flag_lang: "Langue de l'affichage (en, de, fr, it)",
|
|
@@ -286,14 +431,27 @@ var fr_default = {
|
|
|
286
431
|
cli_flag_status: "Filtrer par statut : created ou paid",
|
|
287
432
|
cli_flag_quotes: "Afficher les devis au lieu des factures",
|
|
288
433
|
cli_flag_customer_ref: "Nom ou identifiant du client",
|
|
434
|
+
cli_flag_name: "Nom du client",
|
|
435
|
+
cli_flag_department: "Service",
|
|
436
|
+
cli_flag_extra_line: "Ligne suppl\xE9mentaire sous l'adresse (p. ex. \xE9l\xE9ment PSP)",
|
|
437
|
+
cli_flag_address: "Adresse",
|
|
438
|
+
cli_flag_postal_code: "Code postal",
|
|
439
|
+
cli_flag_city: "Ville",
|
|
440
|
+
cli_flag_country: "Code pays, par exemple CH",
|
|
289
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",
|
|
290
445
|
cli_flag_quote: "Cr\xE9er un devis au lieu d'une facture",
|
|
291
446
|
cli_flag_invoice_date: "Date de la facture (AAAA-MM-JJ), aujourd'hui par d\xE9faut",
|
|
447
|
+
cli_flag_invoice_date_update: "Date de la facture (AAAA-MM-JJ)",
|
|
292
448
|
cli_flag_payment_days: "D\xE9lai de paiement en jours",
|
|
293
449
|
cli_flag_currency: "Monnaie, par exemple CHF",
|
|
294
450
|
cli_flag_language: "Langue du document : de, en, fr ou it",
|
|
295
451
|
cli_flag_subtitle: "Sous-titre affich\xE9 sur le document",
|
|
296
452
|
cli_flag_reference: "Votre r\xE9f\xE9rence pour ce document",
|
|
453
|
+
cli_flag_vat_rate: "Taux de TVA en pourcent, par exemple 8.1",
|
|
454
|
+
cli_flag_custom_notes: "Notes personnalis\xE9es affich\xE9es sur le document",
|
|
297
455
|
cli_flag_pdf: "Enregistrer aussi le PDF dans ce fichier",
|
|
298
456
|
cli_flag_output: "Enregistrer le PDF dans ce fichier",
|
|
299
457
|
cli_flag_paid_date: "Date du paiement (AAAA-MM-JJ), aujourd'hui par d\xE9faut",
|
|
@@ -305,11 +463,16 @@ var fr_default = {
|
|
|
305
463
|
cli_flag_seller: "Fournisseur, ou le client pour une recette",
|
|
306
464
|
cli_flag_price: "Montant, par exemple 23.50",
|
|
307
465
|
cli_flag_receipt_date: "Date du justificatif (AAAA-MM-JJ), aujourd'hui par d\xE9faut",
|
|
308
|
-
|
|
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",
|
|
309
469
|
cli_flag_tax_category: "Cat\xE9gorie fiscale",
|
|
470
|
+
cli_flag_correction: "Enregistrer comme correction (r\xE9duction de charges)",
|
|
310
471
|
cli_flag_booking_text: "Libell\xE9 comptable",
|
|
311
472
|
cli_arg_invoice_ref: "Num\xE9ro de facture ou identifiant",
|
|
473
|
+
cli_arg_customer_ref: "Nom ou identifiant du client",
|
|
312
474
|
cli_arg_scan_files: "Fichiers image ou PDF, toutes les pages d'un justificatif",
|
|
475
|
+
cli_arg_receipt_id: "Identifiant du justificatif",
|
|
313
476
|
cli_error_unauthorized: "Vous n'\xEAtes pas connect\xE9. Ex\xE9cutez : bonbox login",
|
|
314
477
|
cli_error_pro_required: "Cette action n\xE9cessite bonbox Pro. Passez \xE0 Pro sur %1$s",
|
|
315
478
|
cli_error_quota: "Vous avez atteint la limite de votre abonnement. Passez \xE0 Pro sur %1$s",
|
|
@@ -317,15 +480,26 @@ var fr_default = {
|
|
|
317
480
|
cli_error_unexpected_response: "R\xE9ponse inattendue de bonbox (HTTP %1$s)",
|
|
318
481
|
cli_error_item_format: 'Poste invalide "%1$s". Attendu : description:quantit\xE9:prix unitaire[:remise%]',
|
|
319
482
|
cli_error_item_number: 'Nombre invalide dans le poste "%1$s"',
|
|
320
|
-
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",
|
|
321
485
|
cli_error_customer_required: "Indiquez un client avec --customer",
|
|
486
|
+
cli_error_name_required: "Indiquez un nom avec --name",
|
|
487
|
+
cli_error_address_required: "Indiquez une adresse avec --address",
|
|
488
|
+
cli_error_postal_code_required: "Indiquez un code postal avec --postal-code",
|
|
489
|
+
cli_error_city_required: "Indiquez une ville avec --city",
|
|
490
|
+
cli_error_update_fields_required: "Indiquez au moins un champ \xE0 mettre \xE0 jour",
|
|
322
491
|
cli_error_price_required: "Indiquez un montant avec --price",
|
|
323
492
|
cli_error_seller_required: "Indiquez un fournisseur avec --seller",
|
|
324
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",
|
|
325
496
|
cli_error_date_invalid: "Date invalide : %1$s. Attendu : AAAA-MM-JJ",
|
|
326
497
|
cli_error_month_invalid: "Mois invalide : %1$s. Attendu : AAAA-MM",
|
|
327
498
|
cli_error_customer_not_found: 'Aucun client ne correspond \xE0 "%1$s"',
|
|
328
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 :',
|
|
329
503
|
cli_error_files_required: "Indiquez au moins un fichier \xE0 traiter",
|
|
330
504
|
cli_error_file_missing: "Fichier introuvable : %1$s",
|
|
331
505
|
cli_login_opening: "Ouverture de la page de connexion bonbox dans votre navigateur ...",
|
|
@@ -368,14 +542,47 @@ var fr_default = {
|
|
|
368
542
|
cli_empty_invoices: "Aucune facture pour l'instant.",
|
|
369
543
|
cli_empty_quotes: "Aucun devis pour l'instant.",
|
|
370
544
|
cli_empty_receipts: "Aucun justificatif trouv\xE9.",
|
|
545
|
+
cli_customer_created: "Client %1$s cr\xE9\xE9.",
|
|
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.",
|
|
371
550
|
cli_invoice_created: "Facture %1$s cr\xE9\xE9e, %2$s",
|
|
372
551
|
cli_quote_created: "Devis %1$s cr\xE9\xE9, %2$s",
|
|
373
552
|
cli_pdf_saved: "Enregistr\xE9 sous %1$s",
|
|
553
|
+
cli_invoice_updated: "Facture %1$s mise \xE0 jour.",
|
|
554
|
+
cli_quote_updated: "Devis %1$s mis \xE0 jour.",
|
|
374
555
|
cli_invoice_paid: "%1$s marqu\xE9e comme pay\xE9e.",
|
|
375
556
|
cli_invoice_unpaid: "%1$s remise en attente de paiement.",
|
|
376
557
|
cli_receipt_added: "Justificatif enregistr\xE9 : %1$s, %2$s",
|
|
558
|
+
cli_receipt_updated: "Justificatif mis \xE0 jour : %1$s, %2$s",
|
|
377
559
|
cli_scan_uploading: "Envoi de %1$s fichier(s) ...",
|
|
378
|
-
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"
|
|
379
586
|
};
|
|
380
587
|
|
|
381
588
|
// src/i18n/it.json
|
|
@@ -386,15 +593,22 @@ var it_default = {
|
|
|
386
593
|
cli_cmd_whoami: "Mostra l'account con cui hai effettuato l'accesso",
|
|
387
594
|
cli_cmd_customers: "Gestisci i tuoi clienti",
|
|
388
595
|
cli_cmd_customers_ls: "Elenca i tuoi clienti",
|
|
596
|
+
cli_cmd_customers_create: "Crea un cliente",
|
|
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",
|
|
389
601
|
cli_cmd_invoices: "Gestisci fatture e preventivi",
|
|
390
602
|
cli_cmd_invoices_ls: "Elenca fatture e preventivi",
|
|
391
603
|
cli_cmd_invoices_create: "Crea una fattura o un preventivo",
|
|
604
|
+
cli_cmd_invoices_update: "Aggiorna una fattura o un preventivo",
|
|
392
605
|
cli_cmd_invoices_pdf: "Scarica il PDF di una fattura o di un preventivo",
|
|
393
606
|
cli_cmd_invoices_paid: "Segna una fattura come pagata",
|
|
394
607
|
cli_cmd_invoices_unpaid: "Riporta una fattura fra quelle aperte",
|
|
395
608
|
cli_cmd_receipts: "Gestisci i tuoi giustificativi",
|
|
396
609
|
cli_cmd_receipts_ls: "Elenca i tuoi giustificativi",
|
|
397
610
|
cli_cmd_receipts_add: "Inserisci un giustificativo manualmente",
|
|
611
|
+
cli_cmd_receipts_edit: "Modifica un giustificativo",
|
|
398
612
|
cli_cmd_receipts_scan: "Carica un giustificativo e lascia che bonbox lo legga",
|
|
399
613
|
cli_flag_json: "Stampa la risposta dell'API come JSON grezzo",
|
|
400
614
|
cli_flag_lang: "Lingua dell'output (en, de, fr, it)",
|
|
@@ -402,14 +616,27 @@ var it_default = {
|
|
|
402
616
|
cli_flag_status: "Filtra per stato: created o paid",
|
|
403
617
|
cli_flag_quotes: "Mostra i preventivi invece delle fatture",
|
|
404
618
|
cli_flag_customer_ref: "Nome o ID del cliente",
|
|
619
|
+
cli_flag_name: "Nome del cliente",
|
|
620
|
+
cli_flag_department: "Reparto",
|
|
621
|
+
cli_flag_extra_line: "Riga aggiuntiva sotto l'indirizzo (es. elemento PSP)",
|
|
622
|
+
cli_flag_address: "Indirizzo",
|
|
623
|
+
cli_flag_postal_code: "Codice postale",
|
|
624
|
+
cli_flag_city: "Citt\xE0",
|
|
625
|
+
cli_flag_country: "Codice paese, ad esempio CH",
|
|
405
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",
|
|
406
630
|
cli_flag_quote: "Crea un preventivo invece di una fattura",
|
|
407
631
|
cli_flag_invoice_date: "Data della fattura (AAAA-MM-GG), per impostazione predefinita oggi",
|
|
632
|
+
cli_flag_invoice_date_update: "Data della fattura (AAAA-MM-GG)",
|
|
408
633
|
cli_flag_payment_days: "Termine di pagamento in giorni",
|
|
409
634
|
cli_flag_currency: "Valuta, ad esempio CHF",
|
|
410
635
|
cli_flag_language: "Lingua del documento: de, en, fr o it",
|
|
411
636
|
cli_flag_subtitle: "Sottotitolo mostrato sul documento",
|
|
412
637
|
cli_flag_reference: "Il tuo riferimento per questo documento",
|
|
638
|
+
cli_flag_vat_rate: "Aliquota IVA in percento, ad esempio 8.1",
|
|
639
|
+
cli_flag_custom_notes: "Note personalizzate mostrate sul documento",
|
|
413
640
|
cli_flag_pdf: "Salva anche il PDF in questo file",
|
|
414
641
|
cli_flag_output: "Salva il PDF in questo file",
|
|
415
642
|
cli_flag_paid_date: "Data del pagamento (AAAA-MM-GG), per impostazione predefinita oggi",
|
|
@@ -421,11 +648,16 @@ var it_default = {
|
|
|
421
648
|
cli_flag_seller: "Fornitore, oppure il cliente per le entrate",
|
|
422
649
|
cli_flag_price: "Importo, ad esempio 23.50",
|
|
423
650
|
cli_flag_receipt_date: "Data del giustificativo (AAAA-MM-GG), per impostazione predefinita oggi",
|
|
424
|
-
|
|
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",
|
|
425
654
|
cli_flag_tax_category: "Categoria fiscale",
|
|
655
|
+
cli_flag_correction: "Registra come rettifica (riduzione dei costi)",
|
|
426
656
|
cli_flag_booking_text: "Testo di registrazione",
|
|
427
657
|
cli_arg_invoice_ref: "Numero della fattura o ID",
|
|
658
|
+
cli_arg_customer_ref: "Nome o ID del cliente",
|
|
428
659
|
cli_arg_scan_files: "File immagine o PDF, tutte le pagine di un giustificativo",
|
|
660
|
+
cli_arg_receipt_id: "ID del giustificativo",
|
|
429
661
|
cli_error_unauthorized: "Non hai effettuato l'accesso. Esegui: bonbox login",
|
|
430
662
|
cli_error_pro_required: "Serve bonbox Pro. Puoi passare a Pro qui: %1$s",
|
|
431
663
|
cli_error_quota: "Hai raggiunto il limite del tuo abbonamento. Puoi passare a Pro qui: %1$s",
|
|
@@ -433,15 +665,26 @@ var it_default = {
|
|
|
433
665
|
cli_error_unexpected_response: "Risposta inattesa da bonbox (HTTP %1$s)",
|
|
434
666
|
cli_error_item_format: 'Voce non valida "%1$s". Formato atteso: descrizione:quantit\xE0:prezzo unitario[:sconto%]',
|
|
435
667
|
cli_error_item_number: 'Numero non valido nella voce "%1$s"',
|
|
436
|
-
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",
|
|
437
670
|
cli_error_customer_required: "Indica un cliente con --customer",
|
|
671
|
+
cli_error_name_required: "Indica un nome con --name",
|
|
672
|
+
cli_error_address_required: "Indica un indirizzo con --address",
|
|
673
|
+
cli_error_postal_code_required: "Indica un codice postale con --postal-code",
|
|
674
|
+
cli_error_city_required: "Indica una citt\xE0 con --city",
|
|
675
|
+
cli_error_update_fields_required: "Indica almeno un campo da aggiornare",
|
|
438
676
|
cli_error_price_required: "Indica un importo con --price",
|
|
439
677
|
cli_error_seller_required: "Indica un fornitore con --seller",
|
|
440
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",
|
|
441
681
|
cli_error_date_invalid: "Data non valida: %1$s. Formato atteso: AAAA-MM-GG",
|
|
442
682
|
cli_error_month_invalid: "Mese non valido: %1$s. Formato atteso: AAAA-MM",
|
|
443
683
|
cli_error_customer_not_found: 'Nessun cliente corrisponde a "%1$s"',
|
|
444
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:',
|
|
445
688
|
cli_error_files_required: "Indica almeno un file da elaborare",
|
|
446
689
|
cli_error_file_missing: "File non trovato: %1$s",
|
|
447
690
|
cli_login_opening: "Apertura della pagina di accesso bonbox nel browser ...",
|
|
@@ -484,14 +727,47 @@ var it_default = {
|
|
|
484
727
|
cli_empty_invoices: "Ancora nessuna fattura.",
|
|
485
728
|
cli_empty_quotes: "Ancora nessun preventivo.",
|
|
486
729
|
cli_empty_receipts: "Nessun giustificativo trovato.",
|
|
730
|
+
cli_customer_created: "Cliente %1$s creato.",
|
|
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.",
|
|
487
735
|
cli_invoice_created: "Fattura %1$s creata, %2$s",
|
|
488
736
|
cli_quote_created: "Preventivo %1$s creato, %2$s",
|
|
489
737
|
cli_pdf_saved: "Salvato in %1$s",
|
|
738
|
+
cli_invoice_updated: "Fattura %1$s aggiornata.",
|
|
739
|
+
cli_quote_updated: "Preventivo %1$s aggiornato.",
|
|
490
740
|
cli_invoice_paid: "%1$s segnata come pagata.",
|
|
491
741
|
cli_invoice_unpaid: "%1$s riportata fra quelle aperte.",
|
|
492
742
|
cli_receipt_added: "Giustificativo salvato: %1$s, %2$s",
|
|
743
|
+
cli_receipt_updated: "Giustificativo aggiornato: %1$s, %2$s",
|
|
493
744
|
cli_scan_uploading: "Caricamento di %1$s file ...",
|
|
494
|
-
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"
|
|
495
771
|
};
|
|
496
772
|
|
|
497
773
|
// src/i18n/index.ts
|
|
@@ -541,6 +817,14 @@ var UsageError = class extends CliError {
|
|
|
541
817
|
this.name = "UsageError";
|
|
542
818
|
}
|
|
543
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
|
+
};
|
|
544
828
|
function envelopeMessage(body) {
|
|
545
829
|
const message = body?.error?.message;
|
|
546
830
|
return typeof message === "string" && message.length > 0 ? message : void 0;
|
|
@@ -548,14 +832,15 @@ function envelopeMessage(body) {
|
|
|
548
832
|
function mapApiError(status, body) {
|
|
549
833
|
switch (status) {
|
|
550
834
|
case 401:
|
|
551
|
-
return new
|
|
835
|
+
return new ApiRequestError(t("cli_error_unauthorized"), status);
|
|
552
836
|
case 402:
|
|
553
|
-
return new
|
|
837
|
+
return new ApiRequestError(t("cli_error_pro_required", APP_URL), status);
|
|
554
838
|
case 429:
|
|
555
|
-
return new
|
|
839
|
+
return new ApiRequestError(t("cli_error_quota", APP_URL), status);
|
|
556
840
|
default:
|
|
557
|
-
return new
|
|
558
|
-
envelopeMessage(body) ?? t("cli_error_unexpected_response", status)
|
|
841
|
+
return new ApiRequestError(
|
|
842
|
+
envelopeMessage(body) ?? t("cli_error_unexpected_response", status),
|
|
843
|
+
status
|
|
559
844
|
);
|
|
560
845
|
}
|
|
561
846
|
}
|
|
@@ -688,6 +973,18 @@ var ApiClient = class {
|
|
|
688
973
|
});
|
|
689
974
|
return await this.parseJson(response);
|
|
690
975
|
}
|
|
976
|
+
async patch(path, body) {
|
|
977
|
+
const response = await this.send(path, {
|
|
978
|
+
method: "PATCH",
|
|
979
|
+
headers: { "Content-Type": "application/json" },
|
|
980
|
+
body: JSON.stringify(body ?? {})
|
|
981
|
+
});
|
|
982
|
+
return await this.parseJson(response);
|
|
983
|
+
}
|
|
984
|
+
async delete(path) {
|
|
985
|
+
const response = await this.send(path, { method: "DELETE" });
|
|
986
|
+
return await this.parseJson(response);
|
|
987
|
+
}
|
|
691
988
|
async postMultipart(path, form) {
|
|
692
989
|
const response = await this.send(path, { method: "POST", body: form });
|
|
693
990
|
return await this.parseJson(response);
|
|
@@ -818,53 +1115,6 @@ function table(columns, rows) {
|
|
|
818
1115
|
return [render(columns.map((column) => column.header)), ...rows.map(render)].join("\n");
|
|
819
1116
|
}
|
|
820
1117
|
|
|
821
|
-
// src/commands/customers.ts
|
|
822
|
-
function listCommand() {
|
|
823
|
-
return defineCommand2({
|
|
824
|
-
meta: { name: "ls", description: t("cli_cmd_customers_ls") },
|
|
825
|
-
args: {
|
|
826
|
-
...commonArgs(),
|
|
827
|
-
archived: { type: "boolean", description: t("cli_flag_archived"), default: false }
|
|
828
|
-
},
|
|
829
|
-
async run({ args }) {
|
|
830
|
-
const items = await client().getAllPages("/customers", {
|
|
831
|
-
includeArchived: args.archived ? "true" : void 0
|
|
832
|
-
});
|
|
833
|
-
if (args.json) {
|
|
834
|
-
printJson({ items });
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
if (items.length === 0) {
|
|
838
|
-
out(t("cli_empty_customers"));
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
const columns = [
|
|
842
|
-
{ header: t("cli_col_name") },
|
|
843
|
-
{ header: t("cli_col_city") },
|
|
844
|
-
...args.archived ? [{ header: t("cli_col_archived") }] : [],
|
|
845
|
-
{ header: t("cli_col_id") }
|
|
846
|
-
];
|
|
847
|
-
const rows = items.map((customer) => [
|
|
848
|
-
customer.name,
|
|
849
|
-
[customer.postalCode, customer.city].filter(Boolean).join(" "),
|
|
850
|
-
...args.archived ? [customer.archived ? t("cli_yes") : t("cli_no")] : [],
|
|
851
|
-
customer.id
|
|
852
|
-
]);
|
|
853
|
-
out(table(columns, rows));
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
function customersCommand() {
|
|
858
|
-
return defineCommand2({
|
|
859
|
-
meta: { name: "customers", description: t("cli_cmd_customers") },
|
|
860
|
-
subCommands: { ls: listCommand() }
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
// src/commands/invoices.ts
|
|
865
|
-
import { defineCommand as defineCommand3 } from "citty";
|
|
866
|
-
import { writeFile } from "fs/promises";
|
|
867
|
-
|
|
868
1118
|
// src/lib/args.ts
|
|
869
1119
|
function toArray(value) {
|
|
870
1120
|
if (value === void 0 || value === null || value === false) return [];
|
|
@@ -877,6 +1127,10 @@ function optional(value) {
|
|
|
877
1127
|
const text = String(value).trim();
|
|
878
1128
|
return text.length > 0 ? text : void 0;
|
|
879
1129
|
}
|
|
1130
|
+
function providedValue(value) {
|
|
1131
|
+
if (value === void 0 || value === null) return void 0;
|
|
1132
|
+
return String(value).trim();
|
|
1133
|
+
}
|
|
880
1134
|
function requireDate(value) {
|
|
881
1135
|
if (value === void 0) return void 0;
|
|
882
1136
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
@@ -890,6 +1144,24 @@ function requireNumber(value, messageKey) {
|
|
|
890
1144
|
if (!Number.isFinite(parsed)) throw new UsageError(t(messageKey, value));
|
|
891
1145
|
return parsed;
|
|
892
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
|
+
}
|
|
893
1165
|
function monthRange(month) {
|
|
894
1166
|
const match = /^(\d{4})-(\d{2})$/.exec(month);
|
|
895
1167
|
const year = Number(match?.[1]);
|
|
@@ -903,6 +1175,10 @@ function monthRange(month) {
|
|
|
903
1175
|
}
|
|
904
1176
|
|
|
905
1177
|
// src/lib/customers.ts
|
|
1178
|
+
var UUID_RE = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
1179
|
+
function isUuid(value) {
|
|
1180
|
+
return UUID_RE.test(value);
|
|
1181
|
+
}
|
|
906
1182
|
function matchCustomer(reference, customers) {
|
|
907
1183
|
const needle = reference.trim().toLowerCase();
|
|
908
1184
|
if (!needle) return { kind: "none" };
|
|
@@ -929,6 +1205,194 @@ ${list}`);
|
|
|
929
1205
|
throw new UsageError(t("cli_error_customer_not_found", reference));
|
|
930
1206
|
}
|
|
931
1207
|
|
|
1208
|
+
// src/commands/customers.ts
|
|
1209
|
+
function customerFieldArgs() {
|
|
1210
|
+
return {
|
|
1211
|
+
name: { type: "string", description: t("cli_flag_name") },
|
|
1212
|
+
department: { type: "string", description: t("cli_flag_department") },
|
|
1213
|
+
address: { type: "string", description: t("cli_flag_address") },
|
|
1214
|
+
"postal-code": { type: "string", description: t("cli_flag_postal_code") },
|
|
1215
|
+
city: { type: "string", description: t("cli_flag_city") },
|
|
1216
|
+
country: { type: "string", description: t("cli_flag_country") },
|
|
1217
|
+
"extra-line": { type: "string", description: t("cli_flag_extra_line") }
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
function listCommand() {
|
|
1221
|
+
return defineCommand2({
|
|
1222
|
+
meta: { name: "ls", description: t("cli_cmd_customers_ls") },
|
|
1223
|
+
args: {
|
|
1224
|
+
...commonArgs(),
|
|
1225
|
+
archived: { type: "boolean", description: t("cli_flag_archived"), default: false }
|
|
1226
|
+
},
|
|
1227
|
+
async run({ args }) {
|
|
1228
|
+
const items = await client().getAllPages("/customers", {
|
|
1229
|
+
includeArchived: args.archived ? "true" : void 0
|
|
1230
|
+
});
|
|
1231
|
+
if (args.json) {
|
|
1232
|
+
printJson({ items });
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (items.length === 0) {
|
|
1236
|
+
out(t("cli_empty_customers"));
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
const columns = [
|
|
1240
|
+
{ header: t("cli_col_name") },
|
|
1241
|
+
{ header: t("cli_col_city") },
|
|
1242
|
+
...args.archived ? [{ header: t("cli_col_archived") }] : [],
|
|
1243
|
+
{ header: t("cli_col_id") }
|
|
1244
|
+
];
|
|
1245
|
+
const rows = items.map((customer) => [
|
|
1246
|
+
customer.name,
|
|
1247
|
+
[customer.postalCode, customer.city].filter(Boolean).join(" "),
|
|
1248
|
+
...args.archived ? [customer.archived ? t("cli_yes") : t("cli_no")] : [],
|
|
1249
|
+
customer.id
|
|
1250
|
+
]);
|
|
1251
|
+
out(table(columns, rows));
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1255
|
+
function buildCreateBody(fields) {
|
|
1256
|
+
const name = optional(fields.name);
|
|
1257
|
+
const address = optional(fields.address);
|
|
1258
|
+
const postalCode = optional(fields["postal-code"]);
|
|
1259
|
+
const city = optional(fields.city);
|
|
1260
|
+
if (!name) throw new UsageError(t("cli_error_name_required"));
|
|
1261
|
+
if (!address) throw new UsageError(t("cli_error_address_required"));
|
|
1262
|
+
if (!postalCode) throw new UsageError(t("cli_error_postal_code_required"));
|
|
1263
|
+
if (!city) throw new UsageError(t("cli_error_city_required"));
|
|
1264
|
+
return {
|
|
1265
|
+
name,
|
|
1266
|
+
address,
|
|
1267
|
+
postalCode,
|
|
1268
|
+
city,
|
|
1269
|
+
country: optional(fields.country),
|
|
1270
|
+
department: optional(fields.department),
|
|
1271
|
+
extraLine: optional(fields["extra-line"])
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
function createCommand() {
|
|
1275
|
+
return defineCommand2({
|
|
1276
|
+
meta: { name: "create", description: t("cli_cmd_customers_create") },
|
|
1277
|
+
args: {
|
|
1278
|
+
...commonArgs(),
|
|
1279
|
+
...customerFieldArgs()
|
|
1280
|
+
},
|
|
1281
|
+
async run({ args }) {
|
|
1282
|
+
const customer = await client().post("/customers", buildCreateBody(args));
|
|
1283
|
+
if (args.json) printJson(customer);
|
|
1284
|
+
else out(t("cli_customer_created", customer.name));
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
function updatePayload(fields) {
|
|
1289
|
+
const payload = {};
|
|
1290
|
+
const name = providedValue(fields.name);
|
|
1291
|
+
const address = providedValue(fields.address);
|
|
1292
|
+
const postalCode = providedValue(fields["postal-code"]);
|
|
1293
|
+
const city = providedValue(fields.city);
|
|
1294
|
+
const country = providedValue(fields.country);
|
|
1295
|
+
const department = providedValue(fields.department);
|
|
1296
|
+
const extraLine = providedValue(fields["extra-line"]);
|
|
1297
|
+
if (name !== void 0) payload.name = name;
|
|
1298
|
+
if (address !== void 0) payload.address = address;
|
|
1299
|
+
if (postalCode !== void 0) payload.postalCode = postalCode;
|
|
1300
|
+
if (city !== void 0) payload.city = city;
|
|
1301
|
+
if (country !== void 0) payload.country = country;
|
|
1302
|
+
if (department !== void 0) payload.department = department;
|
|
1303
|
+
if (extraLine !== void 0) payload.extraLine = extraLine;
|
|
1304
|
+
return payload;
|
|
1305
|
+
}
|
|
1306
|
+
function ensureUpdatePayload(fields) {
|
|
1307
|
+
const payload = updatePayload(fields);
|
|
1308
|
+
if (Object.keys(payload).length === 0) {
|
|
1309
|
+
throw new UsageError(t("cli_error_update_fields_required"));
|
|
1310
|
+
}
|
|
1311
|
+
return payload;
|
|
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
|
+
}
|
|
1320
|
+
function updateCommand() {
|
|
1321
|
+
return defineCommand2({
|
|
1322
|
+
meta: { name: "update", description: t("cli_cmd_customers_update") },
|
|
1323
|
+
args: {
|
|
1324
|
+
customer: { type: "positional", description: t("cli_arg_customer_ref"), required: true },
|
|
1325
|
+
...commonArgs(),
|
|
1326
|
+
...customerFieldArgs()
|
|
1327
|
+
},
|
|
1328
|
+
async run({ args }) {
|
|
1329
|
+
const payload = ensureUpdatePayload(args);
|
|
1330
|
+
const api = client();
|
|
1331
|
+
const { id } = await findCustomer(api, String(args.customer), false);
|
|
1332
|
+
const customer = await api.patch(`/customers/${id}`, payload);
|
|
1333
|
+
if (args.json) printJson(customer);
|
|
1334
|
+
else out(t("cli_customer_updated", customer.name));
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
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
|
+
}
|
|
1378
|
+
function customersCommand() {
|
|
1379
|
+
return defineCommand2({
|
|
1380
|
+
meta: { name: "customers", description: t("cli_cmd_customers") },
|
|
1381
|
+
subCommands: {
|
|
1382
|
+
ls: listCommand(),
|
|
1383
|
+
create: createCommand(),
|
|
1384
|
+
update: updateCommand(),
|
|
1385
|
+
archive: archiveCommand(true),
|
|
1386
|
+
unarchive: archiveCommand(false),
|
|
1387
|
+
delete: deleteCommand()
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
// src/commands/invoices.ts
|
|
1393
|
+
import { defineCommand as defineCommand3 } from "citty";
|
|
1394
|
+
import { writeFile } from "fs/promises";
|
|
1395
|
+
|
|
932
1396
|
// src/lib/items.ts
|
|
933
1397
|
var NUMBER = /^-?\d+(?:[.,]\d+)?$/;
|
|
934
1398
|
function toNumber(raw) {
|
|
@@ -956,9 +1420,21 @@ function parseItem(raw) {
|
|
|
956
1420
|
if (!description) throw new UsageError(t("cli_error_item_format", raw));
|
|
957
1421
|
return discountPercent === void 0 ? { description, quantity, unitPrice } : { description, quantity, unitPrice, discountPercent };
|
|
958
1422
|
}
|
|
959
|
-
function
|
|
960
|
-
|
|
961
|
-
|
|
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
|
+
};
|
|
962
1438
|
}
|
|
963
1439
|
|
|
964
1440
|
// src/commands/invoices.ts
|
|
@@ -1021,13 +1497,16 @@ async function savePdf(api, reference, target) {
|
|
|
1021
1497
|
await writeFile(filename, pdf.data);
|
|
1022
1498
|
return filename;
|
|
1023
1499
|
}
|
|
1024
|
-
function
|
|
1500
|
+
function createCommand2() {
|
|
1025
1501
|
return defineCommand3({
|
|
1026
1502
|
meta: { name: "create", description: t("cli_cmd_invoices_create") },
|
|
1027
1503
|
args: {
|
|
1028
1504
|
...commonArgs(),
|
|
1029
1505
|
customer: { type: "string", description: t("cli_flag_customer_ref") },
|
|
1030
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 },
|
|
1031
1510
|
quote: { type: "boolean", description: t("cli_flag_quote"), default: false },
|
|
1032
1511
|
date: { type: "string", description: t("cli_flag_invoice_date") },
|
|
1033
1512
|
"payment-days": { type: "string", description: t("cli_flag_payment_days") },
|
|
@@ -1040,7 +1519,11 @@ function createCommand() {
|
|
|
1040
1519
|
async run({ args }) {
|
|
1041
1520
|
const customerRef = optional(args.customer);
|
|
1042
1521
|
if (!customerRef) throw new UsageError(t("cli_error_customer_required"));
|
|
1043
|
-
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"));
|
|
1044
1527
|
const api = client();
|
|
1045
1528
|
const customers = await api.getAllPages("/customers");
|
|
1046
1529
|
const customer = resolveCustomer(customerRef, customers);
|
|
@@ -1053,7 +1536,8 @@ function createCommand() {
|
|
|
1053
1536
|
currency: optional(args.currency),
|
|
1054
1537
|
language: optional(args.language),
|
|
1055
1538
|
subtitle: optional(args.subtitle),
|
|
1056
|
-
reference: optional(args.reference)
|
|
1539
|
+
reference: optional(args.reference),
|
|
1540
|
+
attachReceipts: Boolean(args["attach-receipts"])
|
|
1057
1541
|
});
|
|
1058
1542
|
const pdfTarget = optional(args.pdf);
|
|
1059
1543
|
const savedTo = pdfTarget ? await savePdf(api, invoice.id, pdfTarget) : null;
|
|
@@ -1069,6 +1553,70 @@ function createCommand() {
|
|
|
1069
1553
|
}
|
|
1070
1554
|
});
|
|
1071
1555
|
}
|
|
1556
|
+
function updateCommand2() {
|
|
1557
|
+
return defineCommand3({
|
|
1558
|
+
meta: { name: "update", description: t("cli_cmd_invoices_update") },
|
|
1559
|
+
args: {
|
|
1560
|
+
invoice: { type: "positional", description: t("cli_arg_invoice_ref"), required: true },
|
|
1561
|
+
...commonArgs(),
|
|
1562
|
+
customer: { type: "string", description: t("cli_flag_customer_ref") },
|
|
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") },
|
|
1567
|
+
date: { type: "string", description: t("cli_flag_invoice_date_update") },
|
|
1568
|
+
"payment-days": { type: "string", description: t("cli_flag_payment_days") },
|
|
1569
|
+
currency: { type: "string", description: t("cli_flag_currency") },
|
|
1570
|
+
language: { type: "string", description: t("cli_flag_language") },
|
|
1571
|
+
subtitle: { type: "string", description: t("cli_flag_subtitle") },
|
|
1572
|
+
reference: { type: "string", description: t("cli_flag_reference") },
|
|
1573
|
+
"vat-rate": { type: "string", description: t("cli_flag_vat_rate") },
|
|
1574
|
+
"custom-notes": { type: "string", description: t("cli_flag_custom_notes") }
|
|
1575
|
+
},
|
|
1576
|
+
async run({ args }) {
|
|
1577
|
+
const customerRef = optional(args.customer);
|
|
1578
|
+
const rawItems = toArray(args.item);
|
|
1579
|
+
const added = receiptItems(toArray(args.receipt), Boolean(args.combine));
|
|
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;
|
|
1584
|
+
const customerId = customerRef ? resolveCustomer(customerRef, await api.getAllPages("/customers")).id : void 0;
|
|
1585
|
+
const payload = {};
|
|
1586
|
+
if (customerId !== void 0) payload.customerId = customerId;
|
|
1587
|
+
if (items !== void 0) payload.items = items;
|
|
1588
|
+
if (args["attach-receipts"] !== void 0) payload.attachReceipts = Boolean(args["attach-receipts"]);
|
|
1589
|
+
const date = requireDate(optional(args.date));
|
|
1590
|
+
if (date !== void 0) payload.date = date;
|
|
1591
|
+
const paymentDays = requireNumber(optional(args["payment-days"]), "cli_error_price_invalid");
|
|
1592
|
+
if (paymentDays !== void 0) payload.paymentDays = paymentDays;
|
|
1593
|
+
const currency = optional(args.currency);
|
|
1594
|
+
if (currency !== void 0) payload.currency = currency;
|
|
1595
|
+
const language = optional(args.language);
|
|
1596
|
+
if (language !== void 0) payload.language = language;
|
|
1597
|
+
const subtitle = providedValue(args.subtitle);
|
|
1598
|
+
if (subtitle !== void 0) payload.subtitle = subtitle;
|
|
1599
|
+
const reference = providedValue(args.reference);
|
|
1600
|
+
if (reference !== void 0) payload.reference = reference;
|
|
1601
|
+
const customNotes = providedValue(args["custom-notes"]);
|
|
1602
|
+
if (customNotes !== void 0) payload.customNotes = customNotes;
|
|
1603
|
+
const vatRateRaw = providedValue(args["vat-rate"]);
|
|
1604
|
+
if (vatRateRaw === "") payload.vatRate = "";
|
|
1605
|
+
else if (vatRateRaw !== void 0) {
|
|
1606
|
+
payload.vatRate = requireVatRate(vatRateRaw);
|
|
1607
|
+
}
|
|
1608
|
+
if (Object.keys(payload).length === 0) {
|
|
1609
|
+
throw new UsageError(t("cli_error_update_fields_required"));
|
|
1610
|
+
}
|
|
1611
|
+
const invoice = await api.patch(
|
|
1612
|
+
`/invoices/${encodeURIComponent(String(args.invoice))}`,
|
|
1613
|
+
payload
|
|
1614
|
+
);
|
|
1615
|
+
if (args.json) printJson(invoice);
|
|
1616
|
+
else out(invoice.isQuote ? t("cli_quote_updated", invoice.invoiceNumber) : t("cli_invoice_updated", invoice.invoiceNumber));
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1072
1620
|
function pdfCommand() {
|
|
1073
1621
|
return defineCommand3({
|
|
1074
1622
|
meta: { name: "pdf", description: t("cli_cmd_invoices_pdf") },
|
|
@@ -1127,7 +1675,8 @@ function invoicesCommand() {
|
|
|
1127
1675
|
meta: { name: "invoices", description: t("cli_cmd_invoices") },
|
|
1128
1676
|
subCommands: {
|
|
1129
1677
|
ls: listCommand2(),
|
|
1130
|
-
create:
|
|
1678
|
+
create: createCommand2(),
|
|
1679
|
+
update: updateCommand2(),
|
|
1131
1680
|
pdf: pdfCommand(),
|
|
1132
1681
|
paid: paidCommand(),
|
|
1133
1682
|
unpaid: unpaidCommand()
|
|
@@ -1252,10 +1801,115 @@ function loginCommand() {
|
|
|
1252
1801
|
}
|
|
1253
1802
|
|
|
1254
1803
|
// src/commands/receipts.ts
|
|
1255
|
-
import { defineCommand as
|
|
1804
|
+
import { defineCommand as defineCommand6 } from "citty";
|
|
1256
1805
|
import { existsSync as existsSync2 } from "fs";
|
|
1257
1806
|
import { readFile } from "fs/promises";
|
|
1258
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
|
|
1259
1913
|
var MIME_TYPES = {
|
|
1260
1914
|
".jpg": "image/jpeg",
|
|
1261
1915
|
".jpeg": "image/jpeg",
|
|
@@ -1263,19 +1917,30 @@ var MIME_TYPES = {
|
|
|
1263
1917
|
".webp": "image/webp",
|
|
1264
1918
|
".pdf": "application/pdf"
|
|
1265
1919
|
};
|
|
1266
|
-
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) {
|
|
1267
1929
|
const columns = [
|
|
1268
1930
|
{ header: t("cli_col_date") },
|
|
1269
1931
|
{ header: t("cli_col_seller") },
|
|
1270
1932
|
{ header: t("cli_col_amount"), align: "right" },
|
|
1933
|
+
...showVat ? [{ header: t("cli_col_vat") }] : [],
|
|
1271
1934
|
{ header: t("cli_col_category") },
|
|
1272
1935
|
{ header: t("cli_col_id") }
|
|
1273
1936
|
];
|
|
1274
1937
|
const rows = receipts.map((receipt) => [
|
|
1275
1938
|
formatDate(receipt.date),
|
|
1276
1939
|
receipt.seller ?? "",
|
|
1277
|
-
|
|
1278
|
-
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),
|
|
1279
1944
|
receipt.id
|
|
1280
1945
|
]);
|
|
1281
1946
|
return table(columns, rows);
|
|
@@ -1287,23 +1952,34 @@ function summarize(receipt) {
|
|
|
1287
1952
|
);
|
|
1288
1953
|
}
|
|
1289
1954
|
function listCommand3() {
|
|
1290
|
-
return
|
|
1955
|
+
return defineCommand6({
|
|
1291
1956
|
meta: { name: "ls", description: t("cli_cmd_receipts_ls") },
|
|
1292
1957
|
args: {
|
|
1293
1958
|
...commonArgs(),
|
|
1294
1959
|
month: { type: "string", description: t("cli_flag_month") },
|
|
1295
1960
|
from: { type: "string", description: t("cli_flag_from") },
|
|
1296
1961
|
to: { type: "string", description: t("cli_flag_to") },
|
|
1297
|
-
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") }
|
|
1298
1964
|
},
|
|
1299
1965
|
async run({ args }) {
|
|
1300
1966
|
const month = optional(args.month);
|
|
1301
1967
|
const range = month ? monthRange(month) : void 0;
|
|
1302
|
-
const
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
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
|
+
]);
|
|
1307
1983
|
if (args.json) {
|
|
1308
1984
|
printJson({ items });
|
|
1309
1985
|
return;
|
|
@@ -1312,12 +1988,12 @@ function listCommand3() {
|
|
|
1312
1988
|
out(t("cli_empty_receipts"));
|
|
1313
1989
|
return;
|
|
1314
1990
|
}
|
|
1315
|
-
out(receiptTable(items));
|
|
1991
|
+
out(receiptTable(items, categories, isVatOn(me)));
|
|
1316
1992
|
}
|
|
1317
1993
|
});
|
|
1318
1994
|
}
|
|
1319
1995
|
function addCommand() {
|
|
1320
|
-
return
|
|
1996
|
+
return defineCommand6({
|
|
1321
1997
|
meta: { name: "add", description: t("cli_cmd_receipts_add") },
|
|
1322
1998
|
args: {
|
|
1323
1999
|
...commonArgs(),
|
|
@@ -1327,6 +2003,8 @@ function addCommand() {
|
|
|
1327
2003
|
currency: { type: "string", description: t("cli_flag_currency") },
|
|
1328
2004
|
category: { type: "string", description: t("cli_flag_category") },
|
|
1329
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") },
|
|
1330
2008
|
"booking-text": { type: "string", description: t("cli_flag_booking_text") },
|
|
1331
2009
|
project: { type: "string", description: t("cli_flag_project") },
|
|
1332
2010
|
customer: { type: "string", description: t("cli_flag_customer_ref") }
|
|
@@ -1337,6 +2015,7 @@ function addCommand() {
|
|
|
1337
2015
|
if (!seller) throw new UsageError(t("cli_error_seller_required"));
|
|
1338
2016
|
if (!rawPrice) throw new UsageError(t("cli_error_price_required"));
|
|
1339
2017
|
const price = requireNumber(rawPrice, "cli_error_price_invalid");
|
|
2018
|
+
const vatRate = requireVatRate(optional(args["vat-rate"]));
|
|
1340
2019
|
const api = client();
|
|
1341
2020
|
const customerRef = optional(args.customer);
|
|
1342
2021
|
let customerId;
|
|
@@ -1344,13 +2023,23 @@ function addCommand() {
|
|
|
1344
2023
|
const customers = await api.getAllPages("/customers");
|
|
1345
2024
|
customerId = resolveCustomer(customerRef, customers).id;
|
|
1346
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
|
+
}
|
|
1347
2034
|
const receipt = await api.post("/receipts", {
|
|
1348
2035
|
seller,
|
|
1349
2036
|
price,
|
|
1350
2037
|
date: requireDate(optional(args.date)),
|
|
1351
2038
|
currency: optional(args.currency),
|
|
1352
|
-
|
|
1353
|
-
|
|
2039
|
+
taxCategory,
|
|
2040
|
+
customCategoryId,
|
|
2041
|
+
isCorrection: args.correction ? true : void 0,
|
|
2042
|
+
vatLines: vatRate === void 0 || price === void 0 ? void 0 : vatLinesFor(price, vatRate),
|
|
1354
2043
|
bookingText: optional(args["booking-text"]),
|
|
1355
2044
|
projectId: optional(args.project),
|
|
1356
2045
|
customerId
|
|
@@ -1360,8 +2049,69 @@ function addCommand() {
|
|
|
1360
2049
|
}
|
|
1361
2050
|
});
|
|
1362
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
|
+
}
|
|
1363
2113
|
function scanCommand() {
|
|
1364
|
-
return
|
|
2114
|
+
return defineCommand6({
|
|
1365
2115
|
meta: { name: "scan", description: t("cli_cmd_receipts_scan") },
|
|
1366
2116
|
args: {
|
|
1367
2117
|
files: { type: "positional", description: t("cli_arg_scan_files"), required: false },
|
|
@@ -1388,18 +2138,19 @@ function scanCommand() {
|
|
|
1388
2138
|
});
|
|
1389
2139
|
}
|
|
1390
2140
|
function receiptsCommand() {
|
|
1391
|
-
return
|
|
2141
|
+
return defineCommand6({
|
|
1392
2142
|
meta: { name: "receipts", description: t("cli_cmd_receipts") },
|
|
1393
2143
|
subCommands: {
|
|
1394
2144
|
ls: listCommand3(),
|
|
1395
2145
|
add: addCommand(),
|
|
2146
|
+
edit: editCommand(),
|
|
1396
2147
|
scan: scanCommand()
|
|
1397
2148
|
}
|
|
1398
2149
|
});
|
|
1399
2150
|
}
|
|
1400
2151
|
|
|
1401
2152
|
// src/cli.ts
|
|
1402
|
-
var VERSION = "0.
|
|
2153
|
+
var VERSION = "0.5.0";
|
|
1403
2154
|
var argv = process.argv.slice(2);
|
|
1404
2155
|
setLocale(resolveLocale(langFromArgv(argv)));
|
|
1405
2156
|
function withoutLangFlag(rawArgs) {
|
|
@@ -1416,7 +2167,7 @@ function withoutLangFlag(rawArgs) {
|
|
|
1416
2167
|
return kept;
|
|
1417
2168
|
}
|
|
1418
2169
|
var cliArgs = withoutLangFlag(argv);
|
|
1419
|
-
var main =
|
|
2170
|
+
var main = defineCommand7({
|
|
1420
2171
|
meta: { name: "bonbox", version: VERSION, description: t("cli_app_description") },
|
|
1421
2172
|
subCommands: {
|
|
1422
2173
|
login: loginCommand(),
|
|
@@ -1424,7 +2175,8 @@ var main = defineCommand6({
|
|
|
1424
2175
|
whoami: whoamiCommand(),
|
|
1425
2176
|
customers: customersCommand(),
|
|
1426
2177
|
invoices: invoicesCommand(),
|
|
1427
|
-
receipts: receiptsCommand()
|
|
2178
|
+
receipts: receiptsCommand(),
|
|
2179
|
+
vat: vatCommand()
|
|
1428
2180
|
}
|
|
1429
2181
|
});
|
|
1430
2182
|
async function resolveSubCommand(command, rawArgs, parent) {
|