noxctl 0.6.1 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +45 -19
  2. package/dist/auth.d.ts +21 -2
  3. package/dist/auth.d.ts.map +1 -1
  4. package/dist/auth.js +68 -13
  5. package/dist/auth.js.map +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +181 -24
  8. package/dist/cli.js.map +1 -1
  9. package/dist/credentials-store.d.ts.map +1 -1
  10. package/dist/credentials-store.js +11 -1
  11. package/dist/credentials-store.js.map +1 -1
  12. package/dist/formatter.d.ts +2 -1
  13. package/dist/formatter.d.ts.map +1 -1
  14. package/dist/formatter.js +4 -2
  15. package/dist/formatter.js.map +1 -1
  16. package/dist/fortnox-client.d.ts +9 -0
  17. package/dist/fortnox-client.d.ts.map +1 -1
  18. package/dist/fortnox-client.js +26 -6
  19. package/dist/fortnox-client.js.map +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/operations/financial-reports.d.ts.map +1 -1
  24. package/dist/operations/financial-reports.js +29 -8
  25. package/dist/operations/financial-reports.js.map +1 -1
  26. package/dist/operations/recurrings.d.ts +28 -0
  27. package/dist/operations/recurrings.d.ts.map +1 -0
  28. package/dist/operations/recurrings.js +77 -0
  29. package/dist/operations/recurrings.js.map +1 -0
  30. package/dist/scope-probes.d.ts +12 -0
  31. package/dist/scope-probes.d.ts.map +1 -0
  32. package/dist/scope-probes.js +30 -0
  33. package/dist/scope-probes.js.map +1 -0
  34. package/dist/tools/bookkeeping.d.ts.map +1 -1
  35. package/dist/tools/bookkeeping.js +22 -2
  36. package/dist/tools/bookkeeping.js.map +1 -1
  37. package/dist/tools/recurrings.d.ts +3 -0
  38. package/dist/tools/recurrings.d.ts.map +1 -0
  39. package/dist/tools/recurrings.js +146 -0
  40. package/dist/tools/recurrings.js.map +1 -0
  41. package/dist/tools/status.d.ts.map +1 -1
  42. package/dist/tools/status.js +10 -17
  43. package/dist/tools/status.js.map +1 -1
  44. package/dist/tools/suppliers.d.ts.map +1 -1
  45. package/dist/tools/suppliers.js +52 -19
  46. package/dist/tools/suppliers.js.map +1 -1
  47. package/dist/views.d.ts +4 -0
  48. package/dist/views.d.ts.map +1 -1
  49. package/dist/views.js +36 -1
  50. package/dist/views.js.map +1 -1
  51. package/package.json +8 -6
package/README.md CHANGED
@@ -49,24 +49,46 @@ So you control the credentials, the scopes, and which company is connected end t
49
49
  - Copy your **Client ID** and **Client Secret**
50
50
  4. On the **Integration** tab, enable these scopes under **Behörigheter** / **Permissions**:
51
51
 
52
- | Swedish (SV) | English (EN) | Needed for |
53
- |----------------------|---------------------|------------------------------------------------|
54
- | Artikel | Article | Articles, prices, price lists |
55
- | Bokföring | Bookkeeping | Vouchers, accounts, financial reports |
56
- | Faktura | Invoice | Invoices, invoice payments, offers, orders, tax reductions |
57
- | Företagsinformation | Company Information | Company info |
58
- | Inställningar | Settings | Financial year, locked period |
59
- | Kund | Customer | Customers |
60
- | Leverantör | Supplier | Suppliers |
61
- | Leverantörsfaktura | Supplier Invoice | Supplier invoices, supplier invoice payments |
62
- | Projekt | Project | Projects |
63
- | Kostnadsställe | Cost Center | Cost centers |
64
- | Priser | Price | Price lists, prices |
65
- | Lön | Salary | Payroll: employees, salary/attendance/absence transactions, schedule times — **opt-in**, see below |
66
-
67
- Enable every scope for the resources you intend to use. Missing scopes surface as `403 Forbidden` with a hint pointing at the right one.
68
-
69
- **Payroll (Lön) is opt-in.** The `salary` scope is *not* requested by default, because requesting a scope your app hasn't been granted breaks authorization. To use the payroll commands, enable the **Lön** permission above, then authorize with `noxctl init --with-salary` (or set `FORTNOX_WITH_SALARY=1` for non-interactive setups). The granted scope set is remembered per profile, so token refreshes keep working.
52
+ | Scope | Swedish (SV) | English (EN) | Fortnox licence needed | Needed for |
53
+ |----------------------|----------------------|---------------------|-----------------------------|------------------------------------------------|
54
+ | `article` | Artikel | Article | Order or Kundfaktura | Articles |
55
+ | `bookkeeping` | Bokföring | Bookkeeping | Bokföring or Kundfaktura | Vouchers, accounts, financial reports, financial years |
56
+ | `companyinformation` | Företagsinformation | Company Information | Any | Company info |
57
+ | `connectfile` | — | File Connection | Bokföring/Anläggning/Arkivplats | Attaching uploaded files to vouchers |
58
+ | `costcenter` | Kostnadsställe | Cost Center | Bokföring, Order or Kundfaktura | Cost centers |
59
+ | `customer` | Kund | Customer | Kundfaktura or Order | Customers |
60
+ | `inbox` | | Inbox | Any | Uploading receipt/attachment files |
61
+ | `invoice` | Faktura | Invoice | Order or Kundfaktura | Invoices, tax reductions |
62
+ | `payment` | Betalning | Payment | Bokföring, Order or Kundfaktura | Invoice payments, supplier invoice payments |
63
+ | `price` | Priser | Price | Order or Kundfaktura | Price lists, prices |
64
+ | `project` | Projekt | Project | Bokföring, Order or Kundfaktura | Projects |
65
+ | `settings` | Inställningar | Settings | Any | Locked period |
66
+ | `supplier` | Leverantör | Supplier | Bokföring | Suppliers |
67
+ | `supplierinvoice` | Leverantörsfaktura | Supplier Invoice | Bokföring | Supplier invoices |
68
+ | `offer` | Offert | Offer | **Order** | Offers — **opt-in**, see below |
69
+ | `order` | Order | Order | **Order** | Orders **opt-in**, see below |
70
+ | `salary` | Lön | Salary | **Lön** | Payroll: employees, salary/attendance/absence transactions, schedule times — **opt-in**, see below |
71
+
72
+ Enable every non-opt-in scope. noxctl requests that exact set at authorize time, and
73
+ Fortnox rejects the whole authorization if the app has not been granted a scope that
74
+ is asked for — so a partially-enabled app fails at `noxctl init` rather than at first
75
+ use. `noxctl init` prints the same list.
76
+
77
+ Missing scopes surface as `403 Forbidden` with a hint naming the scope (e.g.
78
+ `Missing "payment" scope`); match that token against the **Scope** column above.
79
+
80
+ **Two scope groups are opt-in, because they depend on a Fortnox licence** the default
81
+ set does not require. Requesting a scope the *company* is not licensed for fails the
82
+ whole authorization, so asking for these unconditionally would lock out companies that
83
+ simply do not have the module:
84
+
85
+ - **Offers and orders (Order licence).** Enable **Offert** and **Order** on the app,
86
+ then authorize with `noxctl init --with-orders` (or `FORTNOX_WITH_ORDERS=1`).
87
+ - **Payroll (Lön licence).** Enable **Lön** on the app, then authorize with
88
+ `noxctl init --with-salary` (or `FORTNOX_WITH_SALARY=1`).
89
+
90
+ Both can be combined. The granted scope set is remembered per profile, so token
91
+ refreshes keep working.
70
92
 
71
93
  5. Save the integration
72
94
 
@@ -295,6 +317,8 @@ Every operation is available both as a CLI command and as an MCP tool. The CLI i
295
317
 
296
318
  ### Offers (offerter)
297
319
 
320
+ > **Requires the `offer` scope**, which is **opt-in** and needs the Fortnox **Order** licence. Run `noxctl init --with-orders` (or set `FORTNOX_WITH_ORDERS=1`), which requests `offer` and `order` together. Without it, these endpoints return `403 Forbidden`. See [Setup](#1-create-a-fortnox-app).
321
+
298
322
  | CLI | MCP tool | Description |
299
323
  |-----|----------|-------------|
300
324
  | `noxctl offers list [--filter <status>] [--customer <number>]` | `fortnox_list_offers` | List/filter offers. Filters: `cancelled`, `expired`, `ordercreated`, `invoicecreated` |
@@ -306,6 +330,8 @@ Every operation is available both as a CLI command and as an MCP tool. The CLI i
306
330
 
307
331
  ### Orders (ordrar)
308
332
 
333
+ > **Requires the `order` scope**, which is **opt-in** and needs the Fortnox **Order** licence. Run `noxctl init --with-orders` (or set `FORTNOX_WITH_ORDERS=1`), which requests `offer` and `order` together. Without it, these endpoints return `403 Forbidden`. See [Setup](#1-create-a-fortnox-app).
334
+
309
335
  | CLI | MCP tool | Description |
310
336
  |-----|----------|-------------|
311
337
  | `noxctl orders list [--filter <status>] [--customer <number>]` | `fortnox_list_orders` | List/filter orders. Filters: `cancelled`, `invoicecreated`, `invoicenotcreated` |
@@ -559,7 +585,7 @@ Another process is using the OAuth callback port. Close it or wait for a previou
559
585
  ## Development
560
586
 
561
587
  ```bash
562
- npm install
588
+ npm ci # reproducible install; does not rewrite package-lock.json
563
589
  npm run build # compile TypeScript
564
590
  npm test # run tests
565
591
  npm run test:watch # watch mode
package/dist/auth.d.ts CHANGED
@@ -1,6 +1,12 @@
1
- export declare const SCOPES = "article customer invoice payment supplier supplierinvoice bookkeeping companyinformation settings inbox connectfile";
1
+ export declare const SCOPES = "article customer invoice payment supplier supplierinvoice bookkeeping companyinformation settings project costcenter price inbox connectfile";
2
+ export declare const ORDER_SCOPES = "offer order";
3
+ export declare const LEGACY_SCOPES = "article customer invoice payment supplier supplierinvoice bookkeeping companyinformation settings inbox connectfile";
2
4
  export declare const SALARY_SCOPE = "salary";
3
- /** Effective scope string for a profile: the granted set if recorded, else the base SCOPES. */
5
+ /**
6
+ * Effective scope string for a profile: the granted set if recorded, else the
7
+ * frozen LEGACY_SCOPES — what a credential predating the `scopes` field was
8
+ * actually consented to. Re-running `noxctl init` records the current set.
9
+ */
4
10
  export declare function effectiveScopes(creds: Pick<FortnoxCredentials, 'scopes'> | null | undefined): string;
5
11
  export declare const CREDENTIAL_SCHEMA_VERSION = 2;
6
12
  export interface FortnoxCredentials {
@@ -35,6 +41,19 @@ export declare function refreshAccessToken(creds: FortnoxCredentials, profile?:
35
41
  export declare function getValidToken(profile?: string): Promise<string>;
36
42
  export declare function fetchTenantId(accessToken: string): Promise<string | undefined>;
37
43
  export declare function fetchCompanyNameSafe(accessToken: string): Promise<string | undefined>;
44
+ /**
45
+ * Command that opens `url` in the platform's default browser.
46
+ *
47
+ * Windows deliberately avoids `cmd /c start`: cmd.exe treats every unescaped
48
+ * `&` in the query string as a command separator, so Fortnox received an
49
+ * authorization URL truncated at the first parameter — no redirect_uri, scope,
50
+ * state, response_type or access_type — and rejected it (#95). PowerShell takes
51
+ * the URL as a single quoted argument instead.
52
+ */
53
+ export declare function browserOpenCommand(platform: NodeJS.Platform, url: string): {
54
+ file: string;
55
+ args: string[];
56
+ };
38
57
  export declare function escapeHtml(value: string): string;
39
58
  export declare function buildAuthorizationUrl(config: FortnoxAppConfig, redirectUri: string, state: string, scopes?: string): string;
40
59
  export declare function runOAuthSetup(config: FortnoxAppConfig, profile?: string, scopes?: string): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,MAAM,wHACoG,CAAC;AAQxH,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,+FAA+F;AAC/F,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,GAAG,IAAI,GAAG,SAAS,GAC3D,MAAM,CAER;AAED,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAMtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAmBD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAErD;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAGD,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAuBD,wBAAsB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA2B1F;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,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al.timeout(AUTH_REQUEST_TIMEOUT_MS),
16
16
  });
17
17
  }
18
- export const SCOPES = 'article customer invoice payment supplier supplierinvoice bookkeeping companyinformation settings inbox connectfile';
18
+ // Every endpoint family noxctl implements must appear here or in one of the
19
+ // opt-in sets below: Fortnox only grants what the authorize request asks for, so
20
+ // a missing token means `403 Har inte behörighet för scope` at call time even
21
+ // when the app has the permission enabled (#95). `payment`, `project`,
22
+ // `costcenter` and `price` are scopes of their own — they are not covered by
23
+ // `invoice`. Every scope here is satisfied by the Bokföring, Kundfaktura or
24
+ // Order licences the pre-existing defaults already required, so adding them
25
+ // cannot make authorization impossible for a company that could authorize before.
26
+ export const SCOPES = 'article customer invoice payment supplier supplierinvoice bookkeeping companyinformation settings project costcenter price inbox connectfile';
27
+ // Offers and orders. Opt-in for the same reason as salary: Fortnox's scope table
28
+ // requires the *Order* licence for both, which a Bokföring + Kundfaktura company
29
+ // does not have — requesting them unconditionally would make `noxctl init`
30
+ // impossible for those companies rather than merely degrading two features.
31
+ // `noxctl init --with-orders` (or FORTNOX_WITH_ORDERS=1) appends them.
32
+ export const ORDER_SCOPES = 'offer order';
33
+ // The scope set as it stood before offers/orders/projects/cost centers/prices
34
+ // were added — i.e. what noxctl 0.3.0–0.6.1 requested. Credentials written before
35
+ // the `scopes` field existed (pre-0.4.0) recorded no scope string, and renewing
36
+ // those against the current SCOPES would silently ask for scopes their Fortnox app
37
+ // was never granted. A rejected client-credentials renewal falls back to the
38
+ // refresh token, which service-account installs do not rotate and which Fortnox
39
+ // expires after 45 days — so widening the fallback can break an untouched
40
+ // installation. Never change this constant; it records history, not intent.
41
+ //
42
+ // Known gap: 0.2.0 predates `inbox`/`connectfile` too, so a credential that old is
43
+ // still widened by those two. That is unchanged behaviour — it has been true since
44
+ // 0.3.0 shipped — and is not worth a speculative rejection-and-retry path; such an
45
+ // installation should re-run `noxctl init`.
46
+ export const LEGACY_SCOPES = 'article customer invoice payment supplier supplierinvoice bookkeeping companyinformation settings inbox connectfile';
19
47
  // The "Lön" (salary/payroll) scope. Opt-in only: requesting it at authorize
20
48
  // time fails for users whose Fortnox app integration does not have the Lön
21
49
  // permission enabled, so it is never part of the default SCOPES. `noxctl init
@@ -23,9 +51,13 @@ export const SCOPES = 'article customer invoice payment supplier supplierinvoice
23
51
  // string is persisted per-profile (see FortnoxCredentials.scopes) so the
24
52
  // client-credentials refresh re-requests the same set.
25
53
  export const SALARY_SCOPE = 'salary';
26
- /** Effective scope string for a profile: the granted set if recorded, else the base SCOPES. */
54
+ /**
55
+ * Effective scope string for a profile: the granted set if recorded, else the
56
+ * frozen LEGACY_SCOPES — what a credential predating the `scopes` field was
57
+ * actually consented to. Re-running `noxctl init` records the current set.
58
+ */
27
59
  export function effectiveScopes(creds) {
28
- return creds?.scopes ?? SCOPES;
60
+ return creds?.scopes ?? LEGACY_SCOPES;
29
61
  }
30
62
  export const CREDENTIAL_SCHEMA_VERSION = 2;
31
63
  // Module-global resolved profile. This assumes a single-tenant process model
@@ -260,20 +292,40 @@ export async function fetchCompanyNameSafe(accessToken) {
260
292
  return undefined;
261
293
  }
262
294
  }
295
+ /**
296
+ * Command that opens `url` in the platform's default browser.
297
+ *
298
+ * Windows deliberately avoids `cmd /c start`: cmd.exe treats every unescaped
299
+ * `&` in the query string as a command separator, so Fortnox received an
300
+ * authorization URL truncated at the first parameter — no redirect_uri, scope,
301
+ * state, response_type or access_type — and rejected it (#95). PowerShell takes
302
+ * the URL as a single quoted argument instead.
303
+ */
304
+ export function browserOpenCommand(platform, url) {
305
+ if (platform === 'darwin')
306
+ return { file: 'open', args: [url] };
307
+ if (platform === 'win32') {
308
+ return {
309
+ file: 'powershell',
310
+ args: [
311
+ '-NoProfile',
312
+ '-NonInteractive',
313
+ '-Command',
314
+ `Start-Process '${url.replace(/'/g, "''")}'`,
315
+ ],
316
+ };
317
+ }
318
+ return { file: 'xdg-open', args: [url] };
319
+ }
263
320
  function openBrowser(url) {
321
+ const { file, args } = browserOpenCommand(process.platform, url);
264
322
  try {
265
- if (process.platform === 'darwin') {
266
- execFileSync('open', [url]);
267
- }
268
- else if (process.platform === 'win32') {
269
- execFileSync('cmd', ['/c', 'start', url]);
270
- }
271
- else {
272
- execFileSync('xdg-open', [url]);
273
- }
323
+ // stdio is discarded: a failed launcher otherwise scribbles over the
324
+ // manual-copy URL that the caller prints either way.
325
+ execFileSync(file, args, { stdio: 'ignore' });
274
326
  }
275
327
  catch {
276
- console.log(`\nOpen this URL in your browser:\n${url}\n`);
328
+ // Ignored — the caller always prints the URL for manual copy-paste.
277
329
  }
278
330
  }
279
331
  export function escapeHtml(value) {
@@ -403,6 +455,9 @@ export async function runOAuthSetup(config, profile = DEFAULT_PROFILE, scopes =
403
455
  const authUrl = buildAuthorizationUrl(config, REDIRECT_URI, oauthState, scopes);
404
456
  console.log('Opening Fortnox login in your browser...');
405
457
  openBrowser(authUrl);
458
+ // Printed unconditionally: if the browser does not open, the callback
459
+ // server may already have been torn down by the time a failure surfaces.
460
+ console.log(`\nIf it does not open, paste this URL into your browser:\n${authUrl}`);
406
461
  console.log(`\nWaiting for authentication on http://${CALLBACK_HOST}:${PORT}...`);
407
462
  });
408
463
  server.on('error', (err) => {
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAmB,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,e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ACL,CAAC"}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAcA,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAmIvB,wBAAgB,sBAAsB,IAAI,eAAe,CAExD"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAcA,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAuIvB,wBAAgB,sBAAsB,IAAI,eAAe,CAExD"}
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import { readActivePointer, readActivePointerOutcome, writeActivePointer, delete
7
7
  import { setResolvedProfile } from './auth.js';
8
8
  import { applyPeriod } from './date-periods.js';
9
9
  import { DEFAULT_PROFILE, InvalidProfileNameError } from './profile-name.js';
10
- import { invoiceListColumns, invoiceDetailColumns, invoiceConfirmColumns, customerListColumns, customerDetailColumns, voucherListColumns, voucherDetailColumns, voucherRowColumns, accountListColumns, companyDetailColumns, articleListColumns, articleDetailColumns, supplierListColumns, supplierDetailColumns, supplierInvoiceListColumns, supplierInvoiceDetailColumns, supplierInvoiceConfirmColumns, invoicePaymentListColumns, invoicePaymentDetailColumns, supplierInvoicePaymentListColumns, supplierInvoicePaymentDetailColumns, offerListColumns, offerDetailColumns, orderListColumns, orderDetailColumns, projectListColumns, projectDetailColumns, costCenterListColumns, costCenterDetailColumns, taxReductionListColumns, taxReductionDetailColumns, priceListListColumns, priceListDetailColumns, priceListColumns, priceDetailColumns, financialYearListColumns, financialYearDetailColumns, lockedPeriodDetailColumns, contractListColumns, contractDetailColumns, topCustomerColumns, monthlyRevenueColumns, voucherAttachmentColumns, employeeListColumns, employeeDetailColumns, salaryTransactionListColumns, salaryTransactionDetailColumns, attendanceTransactionListColumns, attendanceTransactionDetailColumns, absenceTransactionListColumns, absenceTransactionDetailColumns, scheduleTimeDetailColumns, } from './views.js';
10
+ import { invoiceListColumns, invoiceDetailColumns, invoiceConfirmColumns, customerListColumns, customerDetailColumns, voucherListColumns, voucherDetailColumns, voucherRowColumns, accountListColumns, companyDetailColumns, articleListColumns, articleDetailColumns, supplierListColumns, supplierDetailColumns, supplierInvoiceListColumns, supplierInvoiceDetailColumns, supplierInvoiceConfirmColumns, invoicePaymentListColumns, invoicePaymentDetailColumns, supplierInvoicePaymentListColumns, supplierInvoicePaymentDetailColumns, offerListColumns, offerDetailColumns, orderListColumns, orderDetailColumns, projectListColumns, projectDetailColumns, costCenterListColumns, costCenterDetailColumns, taxReductionListColumns, taxReductionDetailColumns, priceListListColumns, priceListDetailColumns, priceListColumns, priceDetailColumns, financialYearListColumns, financialYearDetailColumns, lockedPeriodDetailColumns, contractListColumns, contractDetailColumns, recurringListColumns, recurringDetailColumns, invoiceRequestListColumns, invoiceRequestDetailColumns, topCustomerColumns, monthlyRevenueColumns, voucherAttachmentColumns, employeeListColumns, employeeDetailColumns, salaryTransactionListColumns, salaryTransactionDetailColumns, attendanceTransactionListColumns, attendanceTransactionDetailColumns, absenceTransactionListColumns, absenceTransactionDetailColumns, scheduleTimeDetailColumns, } from './views.js';
11
11
  const program = new Command();
12
12
  // A closed downstream pipe (`noxctl ... | head`, or a reader that exits early)
13
13
  // makes stdout emit EPIPE. That is normal for a CLI, and without this listener
@@ -22,7 +22,7 @@ process.stdout.on('error', (err) => {
22
22
  program
23
23
  .name('noxctl')
24
24
  .description('CLI and MCP server for Fortnox accounting')
25
- .version('0.6.1')
25
+ .version('0.7.3')
26
26
  .addOption(new Option('-o, --output <format>', 'Output format (default: table on TTY, json when piped)')
27
27
  .choices(['json', 'table'])
28
28
  .default(undefined))
@@ -197,12 +197,18 @@ program
197
197
  .description('Interactive setup wizard — recommended onboarding path')
198
198
  .option('--profile <name>', 'Profile to create/re-auth (defaults to resolved profile or "default")')
199
199
  .option('--with-salary', 'Also request the Lön (salary/payroll) scope — requires the Lön permission enabled on your Fortnox app')
200
+ .option('--with-orders', 'Also request the offer/order scopes — requires the Order licence on the Fortnox company')
200
201
  .action(async (initOpts) => {
201
- const { loadCredentials, runOAuthSetup, SCOPES, SALARY_SCOPE } = await import('./auth.js');
202
+ const { loadCredentials, runOAuthSetup, SCOPES, SALARY_SCOPE, ORDER_SCOPES } = await import('./auth.js');
202
203
  const { validateProfileName } = await import('./profile-name.js');
203
- // Opt-in salary scope: flag for TTY, env var for non-interactive/CI runs.
204
+ // Opt-in scopes: flag for TTY, env var for non-interactive/CI runs. Both are
205
+ // licence-gated in Fortnox (Lön / Order), and asking for a scope the company
206
+ // is not licensed for fails the whole authorization — hence not defaults.
204
207
  const withSalary = Boolean(initOpts.withSalary) || process.env.FORTNOX_WITH_SALARY === '1';
205
- const scopes = withSalary ? `${SCOPES} ${SALARY_SCOPE}` : SCOPES;
208
+ const withOrders = Boolean(initOpts.withOrders) || process.env.FORTNOX_WITH_ORDERS === '1';
209
+ const scopes = [SCOPES, withOrders ? ORDER_SCOPES : '', withSalary ? SALARY_SCOPE : '']
210
+ .filter(Boolean)
211
+ .join(' ');
206
212
  let targetProfile;
207
213
  try {
208
214
  targetProfile = validateProfileName(initOpts.profile ?? resolvedProfileInfo.name);
@@ -251,9 +257,16 @@ program
251
257
  console.log('');
252
258
  console.log("You'll need a Fortnox app from developer.fortnox.se with:");
253
259
  console.log(' - Redirect URI: http://localhost:9876/callback');
254
- console.log(' - Scopes (Behörigheter): Artikel, Bokföring, Faktura, Företagsinformation, Inställningar, Kund, Leverantör, Leverantörsfaktura');
260
+ // Printed from the SCOPES constant itself. A hand-maintained list drifted
261
+ // from what noxctl actually requests, so following the docs produced an
262
+ // under-scoped Fortnox app and a confusing rejection at authorize time (#95).
263
+ console.log(' - Permissions (Behörigheter) for every one of these scopes:');
264
+ console.log(` ${scopes.split(' ').join(', ')}`);
265
+ if (withOrders) {
266
+ console.log(' (offer/order are included because you passed --with-orders)');
267
+ }
255
268
  if (withSalary) {
256
- console.log(' - Lön (krävs eftersom du kör med --with-salary)');
269
+ console.log(' (salary is included because you passed --with-salary)');
257
270
  }
258
271
  console.log(' - Service account enabled (recommended)');
259
272
  console.log('');
@@ -734,26 +747,18 @@ program
734
747
  // 8. Scope validation — probe each scope with a lightweight GET
735
748
  const { effectiveScopes } = await import('./auth.js');
736
749
  const { fortnoxRequest, FortnoxApiError } = await import('./fortnox-client.js');
737
- const scopeEndpoints = {
738
- article: 'articles?limit=1',
739
- customer: 'customers?limit=1',
740
- invoice: 'invoices?limit=1',
741
- payment: 'invoicepayments?limit=1',
742
- supplier: 'suppliers?limit=1',
743
- supplierinvoice: 'supplierinvoices?limit=1',
744
- bookkeeping: 'vouchers?limit=1',
745
- companyinformation: 'companyinformation',
746
- settings: 'settings/company',
747
- inbox: 'inbox',
748
- connectfile: 'voucherfileconnections?limit=1',
749
- salary: 'employees?limit=1',
750
- };
750
+ const { scopeProbeEndpoints } = await import('./scope-probes.js');
751
751
  const required = effectiveScopes(creds).split(' ');
752
752
  const missing = [];
753
+ const unchecked = [];
753
754
  for (const scope of required) {
754
- const endpoint = scopeEndpoints[scope];
755
- if (!endpoint)
755
+ const endpoint = scopeProbeEndpoints[scope];
756
+ // Report rather than skip: counting an unprobed scope as authorized is
757
+ // how doctor used to claim a clean bill of health it had not verified.
758
+ if (!endpoint) {
759
+ unchecked.push(scope);
756
760
  continue;
761
+ }
757
762
  try {
758
763
  await fortnoxRequest(endpoint);
759
764
  }
@@ -768,7 +773,10 @@ program
768
773
  }
769
774
  }
770
775
  if (missing.length === 0) {
771
- pass('Scopes', `all ${required.length} scopes authorized`);
776
+ const checked = required.length - unchecked.length;
777
+ pass('Scopes', unchecked.length === 0
778
+ ? `all ${checked} scopes authorized`
779
+ : `${checked} scopes authorized; not checked: ${unchecked.join(', ')}`);
772
780
  }
773
781
  else {
774
782
  fail('Scopes', `missing: ${missing.join(', ')}. Enable them in your Fortnox app at developer.fortnox.se`);
@@ -2897,6 +2905,155 @@ contracts
2897
2905
  const data = await increaseInvoiceCount(documentNumber);
2898
2906
  outputConfirmation(`Invoice count increased for contract ${documentNumber}.`, json(), data, contractDetailColumns, 'Contract');
2899
2907
  });
2908
+ // --- recurrings (new Recurring Billing API) ---
2909
+ const recurrings = program
2910
+ .command('recurrings')
2911
+ .description('Recurring Billing operations (nya API:t för återkommande fakturering)');
2912
+ const csvOption = (value) => value
2913
+ .split(',')
2914
+ .map((part) => part.trim())
2915
+ .filter(Boolean);
2916
+ const recurringResult = (result) => ({
2917
+ ...result.recurring,
2918
+ ...(result.etag ? { etag: result.etag } : {}),
2919
+ ...(result.lastModified ? { last_modified: result.lastModified } : {}),
2920
+ });
2921
+ recurrings
2922
+ .command('list')
2923
+ .description('List recurring billing contracts')
2924
+ .option('--customer-numbers <numbers>', 'Comma-separated customer numbers', csvOption)
2925
+ .option('--statuses <statuses>', 'Comma-separated statuses', csvOption)
2926
+ .option('--invoice-handlings <handlings>', 'Comma-separated invoice handling types', csvOption)
2927
+ .option('--error-status <status>', 'Filter by error status')
2928
+ .option('--offset <number>', 'Number of results to skip', parseInt)
2929
+ .option('--limit <number>', 'Results per page (1–100)', parseInt)
2930
+ .option('--sort-by <field>', 'Field to sort by')
2931
+ .option('--order <direction>', 'Sort direction: ASC or DESC')
2932
+ .action(async (opts) => {
2933
+ const { listRecurrings } = await import('./operations/recurrings.js');
2934
+ const data = await listRecurrings({
2935
+ customerNumbers: opts.customerNumbers,
2936
+ statuses: opts.statuses,
2937
+ invoiceHandlings: opts.invoiceHandlings,
2938
+ errorStatus: opts.errorStatus,
2939
+ offset: opts.offset,
2940
+ limit: opts.limit,
2941
+ sortBy: opts.sortBy,
2942
+ order: opts.order,
2943
+ });
2944
+ outputList(data, recurringListColumns, json(), data);
2945
+ });
2946
+ recurrings
2947
+ .command('get <recurringId>')
2948
+ .description('Get a recurring billing contract and its ETag')
2949
+ .action(async (recurringId) => {
2950
+ const { getRecurring } = await import('./operations/recurrings.js');
2951
+ const data = recurringResult(await getRecurring(recurringId));
2952
+ outputDetail(data, recurringDetailColumns, json(), 'Recurring');
2953
+ });
2954
+ recurrings
2955
+ .command('create')
2956
+ .description('Create a recurring billing contract')
2957
+ .requiredOption('--input <file>', 'Recurring JSON data (or - for stdin)')
2958
+ .option('-y, --yes', 'Skip confirmation prompt')
2959
+ .option('--dry-run', 'Preview the request without sending it')
2960
+ .action(async (opts) => {
2961
+ const { createRecurring } = await import('./operations/recurrings.js');
2962
+ const raw = opts.input === '-' ? readFileSync(0, 'utf-8') : readFileSync(opts.input, 'utf-8');
2963
+ const input = JSON.parse(raw);
2964
+ if (!(await confirmMutation('Create recurring billing contract', opts, input)))
2965
+ return;
2966
+ const data = recurringResult(await createRecurring(input));
2967
+ outputDetail(data, recurringDetailColumns, json(), 'Recurring');
2968
+ });
2969
+ recurrings
2970
+ .command('replace <recurringId>')
2971
+ .description('Replace a recurring billing contract (requires ETag)')
2972
+ .requiredOption('--etag <etag>', 'ETag returned by recurrings get')
2973
+ .requiredOption('--input <file>', 'Complete recurring JSON data (or - for stdin)')
2974
+ .option('--if-unmodified-since <value>', 'Optional Last-Modified value from recurrings get')
2975
+ .option('-y, --yes', 'Skip confirmation prompt')
2976
+ .option('--dry-run', 'Preview the request without sending it')
2977
+ .action(async (recurringId, opts) => {
2978
+ const { replaceRecurring } = await import('./operations/recurrings.js');
2979
+ const raw = opts.input === '-' ? readFileSync(0, 'utf-8') : readFileSync(opts.input, 'utf-8');
2980
+ const input = JSON.parse(raw);
2981
+ if (!(await confirmMutation(`Replace recurring ${recurringId}`, opts, input)))
2982
+ return;
2983
+ const data = recurringResult(await replaceRecurring(recurringId, opts.etag, input, opts.ifUnmodifiedSince));
2984
+ outputDetail(data, recurringDetailColumns, json(), 'Recurring');
2985
+ });
2986
+ recurrings
2987
+ .command('patch <recurringId>')
2988
+ .description('Update selected recurring fields with JSON Patch (requires ETag)')
2989
+ .requiredOption('--etag <etag>', 'ETag returned by recurrings get')
2990
+ .requiredOption('--input <file>', 'JSON Patch operations (or - for stdin)')
2991
+ .option('--if-unmodified-since <value>', 'Optional Last-Modified value from recurrings get')
2992
+ .option('-y, --yes', 'Skip confirmation prompt')
2993
+ .option('--dry-run', 'Preview the request without sending it')
2994
+ .action(async (recurringId, opts) => {
2995
+ const { patchRecurring } = await import('./operations/recurrings.js');
2996
+ const raw = opts.input === '-' ? readFileSync(0, 'utf-8') : readFileSync(opts.input, 'utf-8');
2997
+ const operations = JSON.parse(raw);
2998
+ if (!Array.isArray(operations))
2999
+ throw new Error('Recurring patch input must be a JSON array.');
3000
+ if (!(await confirmMutation(`Patch recurring ${recurringId}`, opts, operations)))
3001
+ return;
3002
+ const data = recurringResult(await patchRecurring(recurringId, opts.etag, operations, opts.ifUnmodifiedSince));
3003
+ outputDetail(data, recurringDetailColumns, json(), 'Recurring');
3004
+ });
3005
+ recurrings
3006
+ .command('list-deviations <recurringId>')
3007
+ .description('List deviations for a recurring billing contract')
3008
+ .action(async (recurringId) => {
3009
+ const { listRecurringDeviations } = await import('./operations/recurrings.js');
3010
+ const data = await listRecurringDeviations(recurringId);
3011
+ outputList(data, recurringListColumns, json(), data);
3012
+ });
3013
+ recurrings
3014
+ .command('get-deviation <recurringId> <deviationId>')
3015
+ .description('Get one recurring billing deviation')
3016
+ .action(async (recurringId, deviationId) => {
3017
+ const { getRecurringDeviation } = await import('./operations/recurrings.js');
3018
+ const data = await getRecurringDeviation(recurringId, deviationId);
3019
+ outputDetail(data, recurringDetailColumns, json(), 'Recurring deviation');
3020
+ });
3021
+ recurrings
3022
+ .command('list-invoice-requests')
3023
+ .description('List invoice-generation requests for recurring billing contracts')
3024
+ .requiredOption('--recurring-ids <ids>', 'Comma-separated recurring UUIDs', csvOption)
3025
+ .option('--statuses <statuses>', 'Comma-separated request statuses', csvOption)
3026
+ .action(async (opts) => {
3027
+ const { listInvoiceRequests } = await import('./operations/recurrings.js');
3028
+ const data = await listInvoiceRequests(opts.recurringIds, opts.statuses);
3029
+ outputList(data, invoiceRequestListColumns, json(), data);
3030
+ });
3031
+ recurrings
3032
+ .command('get-invoice-request <invoiceRequestId>')
3033
+ .description('Get a recurring invoice-generation request')
3034
+ .action(async (invoiceRequestId) => {
3035
+ const { getInvoiceRequest } = await import('./operations/recurrings.js');
3036
+ const data = await getInvoiceRequest(invoiceRequestId);
3037
+ outputDetail(data, invoiceRequestDetailColumns, json(), 'Recurring invoice request');
3038
+ });
3039
+ recurrings
3040
+ .command('create-invoice-request')
3041
+ .description('Create invoices for recurring billing contracts')
3042
+ .requiredOption('--recurring-ids <ids>', 'Comma-separated recurring UUIDs', csvOption)
3043
+ .option('--processing-mode <mode>', 'SYNC (default) or ASYNC', 'SYNC')
3044
+ .option('-y, --yes', 'Skip confirmation prompt')
3045
+ .option('--dry-run', 'Preview the request without sending it')
3046
+ .action(async (opts) => {
3047
+ const { createInvoiceRequest } = await import('./operations/recurrings.js');
3048
+ const mode = String(opts.processingMode).toUpperCase();
3049
+ if (mode !== 'SYNC' && mode !== 'ASYNC')
3050
+ throw new Error('processing-mode must be SYNC or ASYNC.');
3051
+ const payload = { recurring_ids: opts.recurringIds, processing_mode: mode };
3052
+ if (!(await confirmMutation('Create recurring invoice request', opts, payload)))
3053
+ return;
3054
+ const data = await createInvoiceRequest(opts.recurringIds, mode);
3055
+ outputConfirmation('Recurring invoice request created.', json(), data, invoiceRequestDetailColumns, 'Recurring invoice request');
3056
+ });
2900
3057
  // --- financial years ---
2901
3058
  const financialYears = program
2902
3059
  .command('financial-years')