rotacloud 2.2.1 → 2.2.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.
@@ -3,6 +3,7 @@ import { LogbookEntry, LogbookQueryParameters } from './interfaces/logbook.inter
3
3
  import { Message } from './interfaces/message.interface.js';
4
4
  import { AttendanceQueryParams, AvailabilityQueryParams, DailyBudgetsQueryParams, DailyRevenueQueryParams, DayNotesQueryParams, DaysOffQueryParams, DocumentsQueryParams, GroupsQueryParams, LeaveEmbargoesQueryParams, LeaveQueryParams, LeaveRequestsQueryParams, LocationsQueryParams, RolesQueryParams, SettingsQueryParams, ShiftsQueryParams, TerminalsQueryParams, ToilAccrualsQueryParams, ToilAllowanceQueryParams, UsersQueryParams } from './interfaces/query-params/index.js';
5
5
  import { RequirementsOf } from './utils.js';
6
+ import { Invoice, InvoiceQueryParameters } from './interfaces/invoice.interface.js';
6
7
  /** Endpoint versions supported by the API */
7
8
  export type EndpointVersion = 'v1' | 'v2';
8
9
  /** Associated types for a given API endpoint */
@@ -55,6 +56,7 @@ export interface EndpointEntityMap extends Record<EndpointVersion, Record<string
55
56
  /** Type mappings for v2 endpoints */
56
57
  v2: {
57
58
  logbook: Endpoint<LogbookEntry, LogbookQueryParameters, 'name' | 'description' | 'date' | 'userId'>;
59
+ invoices: Endpoint<Invoice, InvoiceQueryParameters>;
58
60
  dayNotes: Endpoint<DayNoteV2, DayNoteV2QueryParameters, 'title' | 'message' | 'startDate' | 'endDate' | 'locations' | 'visibleToEmployees'>;
59
61
  'logbook/categories': Endpoint<LogbookCategory, undefined, Pick<LogbookCategory, 'name'>>;
60
62
  };
@@ -0,0 +1,63 @@
1
+ export type InvoiceStatus = 'paid' | 'posted' | 'payment_due' | 'not_paid' | 'voided' | 'pending';
2
+ export type PricingModel = 'flat_fee' | 'per_unit' | 'tiered' | 'volume' | 'stairstep';
3
+ export interface Invoice {
4
+ id: string;
5
+ /** The status of the invoice */
6
+ status: InvoiceStatus;
7
+ /** The currency code of the invoice, e.g., GBP */
8
+ currencyCode: string;
9
+ /** The total amount of the invoice in subunits (pence, cents, etc.) */
10
+ total: number | null;
11
+ amountDue: number | null;
12
+ /** The date and time in ISO 8601 format when the invoice was issued */
13
+ date: string | null;
14
+ /** The date and time in ISO 8601 format when the invoice is due */
15
+ dueDate: string | null;
16
+ deleted: boolean;
17
+ /** The date and time in ISO 8601 format when the invoice was last updated */
18
+ updatedAt: string | null;
19
+ /** The purchase order number associated with this invoice */
20
+ poNumber: number | null;
21
+ recurring: boolean | null;
22
+ vatNumber: string | null;
23
+ priceType: string | null;
24
+ netTermDays: number | null;
25
+ amountPaid: number | null;
26
+ amountAdjusted: number | null;
27
+ writeOffAmount: number | null;
28
+ creditsApplied: number | null;
29
+ /** Date and time in ISO 8601 format */
30
+ paidAt: string | null;
31
+ dunningStatus: string | null;
32
+ /** Date and time in ISO 8601 format */
33
+ nextRetryAt: string | null;
34
+ /** Date and time in ISO 8601 format */
35
+ voidedAt: string | null;
36
+ subTotal: number | null;
37
+ tax: number | null;
38
+ lineItems: LineItem[] | null;
39
+ }
40
+ export interface InvoiceDownload {
41
+ downloadLink: string;
42
+ downloadLinkExpiresAt: string;
43
+ }
44
+ export interface LineItem {
45
+ unitAmount: number;
46
+ quantity?: number;
47
+ amount?: number;
48
+ pricingModel?: PricingModel;
49
+ description: string;
50
+ entityDescription?: string;
51
+ }
52
+ export interface InvoiceQueryParameters {
53
+ /** Invoice status to filter by */
54
+ status?: InvoiceStatus;
55
+ /** The date to filter from, e.g., 2025-01-01 */
56
+ dateFrom?: string;
57
+ /** The date to filter to, e.g., 2025-12-30 */
58
+ dateTo?: string;
59
+ /** The minimum total amount of the invoice */
60
+ minTotal?: number;
61
+ /** The maximum total amount of the invoice */
62
+ maxTotal?: number;
63
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/main.d.ts CHANGED
@@ -75,6 +75,14 @@ export declare const createRotaCloudClient: (config: import("./interfaces/sdk-co
75
75
  endpointVersion: "v1";
76
76
  operations: ("get" | "delete" | "list" | "listAll" | "create" | "update")[];
77
77
  };
78
+ invoice: {
79
+ endpoint: "invoices";
80
+ endpointVersion: "v2";
81
+ operations: ("get" | "list" | "listAll")[];
82
+ customOperations: {
83
+ get: (ctx: import("./ops.js").OperationContext, id: number) => import("./ops.js").RequestConfig<void, import("./interfaces/invoice.interface.js").Invoice & import("./interfaces/invoice.interface.js").InvoiceDownload>;
84
+ };
85
+ };
78
86
  leaveEmbargo: {
79
87
  endpoint: "leave_embargoes";
80
88
  endpointVersion: "v1";
package/dist/service.d.ts CHANGED
@@ -9,6 +9,7 @@ import { ShiftDropRequest } from './interfaces/drop-request.interface.js';
9
9
  import { ToilAllowanceQueryParams } from './interfaces/query-params/index.js';
10
10
  import { LogbookEntry, LogbookQueryParameters } from './interfaces/logbook.interface.js';
11
11
  import { Message } from './interfaces/message.interface.js';
12
+ import { Invoice, InvoiceDownload } from './interfaces/invoice.interface.js';
12
13
  export type ServiceSpecification<CustomOp extends OpDef<unknown> = OpDef<any>> = {
13
14
  /** Operations allowed and usable for the endpoint */
14
15
  operations: Operation[];
@@ -117,6 +118,14 @@ export declare const SERVICES: {
117
118
  endpointVersion: "v1";
118
119
  operations: ("get" | "delete" | "list" | "listAll" | "create" | "update")[];
119
120
  };
121
+ invoice: {
122
+ endpoint: "invoices";
123
+ endpointVersion: "v2";
124
+ operations: ("get" | "list" | "listAll")[];
125
+ customOperations: {
126
+ get: (ctx: OperationContext, id: number) => RequestConfig<void, Invoice & InvoiceDownload>;
127
+ };
128
+ };
120
129
  leaveEmbargo: {
121
130
  endpoint: "leave_embargoes";
122
131
  endpointVersion: "v1";
package/dist/service.js CHANGED
@@ -106,6 +106,18 @@ export const SERVICES = {
106
106
  endpointVersion: 'v1',
107
107
  operations: ['create', 'get', 'list', 'listAll', 'update', 'delete'],
108
108
  },
109
+ invoice: {
110
+ endpoint: 'invoices',
111
+ endpointVersion: 'v2',
112
+ operations: ['get', 'list', 'listAll'],
113
+ customOperations: {
114
+ get: (ctx, id) => ({
115
+ ...ctx.request,
116
+ url: `${ctx.service.endpointVersion}/${ctx.service.endpoint}/${id}`,
117
+ method: 'GET',
118
+ }),
119
+ },
120
+ },
109
121
  leaveEmbargo: {
110
122
  endpoint: 'leave_embargoes',
111
123
  endpointVersion: 'v1',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotacloud",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "The RotaCloud SDK for the RotaCloud API",
5
5
  "type": "module",
6
6
  "engines": {
package/src/endpoint.ts CHANGED
@@ -52,6 +52,7 @@ import {
52
52
  UsersQueryParams,
53
53
  } from './interfaces/query-params/index.js';
54
54
  import { RequirementsOf } from './utils.js';
55
+ import { Invoice, InvoiceQueryParameters } from './interfaces/invoice.interface.js';
55
56
 
56
57
  /** Endpoint versions supported by the API */
57
58
  export type EndpointVersion = 'v1' | 'v2';
@@ -120,6 +121,7 @@ export interface EndpointEntityMap extends Record<EndpointVersion, Record<string
120
121
  /** Type mappings for v2 endpoints */
121
122
  v2: {
122
123
  logbook: Endpoint<LogbookEntry, LogbookQueryParameters, 'name' | 'description' | 'date' | 'userId'>;
124
+ invoices: Endpoint<Invoice, InvoiceQueryParameters>;
123
125
  dayNotes: Endpoint<
124
126
  DayNoteV2,
125
127
  DayNoteV2QueryParameters,
@@ -0,0 +1,68 @@
1
+ export type InvoiceStatus = 'paid' | 'posted' | 'payment_due' | 'not_paid' | 'voided' | 'pending';
2
+
3
+ export type PricingModel = 'flat_fee' | 'per_unit' | 'tiered' | 'volume' | 'stairstep';
4
+
5
+ export interface Invoice {
6
+ id: string;
7
+ /** The status of the invoice */
8
+ status: InvoiceStatus;
9
+ /** The currency code of the invoice, e.g., GBP */
10
+ currencyCode: string;
11
+ /** The total amount of the invoice in subunits (pence, cents, etc.) */
12
+ total: number | null;
13
+ amountDue: number | null;
14
+ /** The date and time in ISO 8601 format when the invoice was issued */
15
+ date: string | null;
16
+ /** The date and time in ISO 8601 format when the invoice is due */
17
+ dueDate: string | null;
18
+ deleted: boolean;
19
+ /** The date and time in ISO 8601 format when the invoice was last updated */
20
+ updatedAt: string | null;
21
+ /** The purchase order number associated with this invoice */
22
+ poNumber: number | null;
23
+ recurring: boolean | null;
24
+ vatNumber: string | null;
25
+ priceType: string | null;
26
+ netTermDays: number | null;
27
+ amountPaid: number | null;
28
+ amountAdjusted: number | null;
29
+ writeOffAmount: number | null;
30
+ creditsApplied: number | null;
31
+ /** Date and time in ISO 8601 format */
32
+ paidAt: string | null;
33
+ dunningStatus: string | null;
34
+ /** Date and time in ISO 8601 format */
35
+ nextRetryAt: string | null;
36
+ /** Date and time in ISO 8601 format */
37
+ voidedAt: string | null;
38
+ subTotal: number | null;
39
+ tax: number | null;
40
+ lineItems: LineItem[] | null;
41
+ }
42
+
43
+ export interface InvoiceDownload {
44
+ downloadLink: string;
45
+ downloadLinkExpiresAt: string;
46
+ }
47
+
48
+ export interface LineItem {
49
+ unitAmount: number;
50
+ quantity?: number;
51
+ amount?: number;
52
+ pricingModel?: PricingModel;
53
+ description: string;
54
+ entityDescription?: string;
55
+ }
56
+
57
+ export interface InvoiceQueryParameters {
58
+ /** Invoice status to filter by */
59
+ status?: InvoiceStatus;
60
+ /** The date to filter from, e.g., 2025-01-01 */
61
+ dateFrom?: string;
62
+ /** The date to filter to, e.g., 2025-12-30 */
63
+ dateTo?: string;
64
+ /** The minimum total amount of the invoice */
65
+ minTotal?: number;
66
+ /** The maximum total amount of the invoice */
67
+ maxTotal?: number;
68
+ }
package/src/service.ts CHANGED
@@ -33,6 +33,7 @@ import { ShiftDropRequest } from './interfaces/drop-request.interface.js';
33
33
  import { ToilAllowanceQueryParams } from './interfaces/query-params/index.js';
34
34
  import { LogbookEntry, LogbookQueryParameters } from './interfaces/logbook.interface.js';
35
35
  import { Message } from './interfaces/message.interface.js';
36
+ import { Invoice, InvoiceDownload } from './interfaces/invoice.interface.js';
36
37
 
37
38
  export type ServiceSpecification<CustomOp extends OpDef<unknown> = OpDef<any>> = {
38
39
  /** Operations allowed and usable for the endpoint */
@@ -178,6 +179,18 @@ export const SERVICES = {
178
179
  endpointVersion: 'v1',
179
180
  operations: ['create', 'get', 'list', 'listAll', 'update', 'delete'],
180
181
  },
182
+ invoice: {
183
+ endpoint: 'invoices',
184
+ endpointVersion: 'v2',
185
+ operations: ['get', 'list', 'listAll'],
186
+ customOperations: {
187
+ get: (ctx, id: number): RequestConfig<void, Invoice & InvoiceDownload> => ({
188
+ ...ctx.request,
189
+ url: `${ctx.service.endpointVersion}/${ctx.service.endpoint}/${id}`,
190
+ method: 'GET',
191
+ }),
192
+ },
193
+ },
181
194
  leaveEmbargo: {
182
195
  endpoint: 'leave_embargoes',
183
196
  endpointVersion: 'v1',