placementt-core 1.400.1085 → 1.400.1086

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 (48) hide show
  1. package/lib/callables/billing.d.ts +259 -0
  2. package/lib/callables/billing.js +61 -0
  3. package/lib/callables/billing.js.map +1 -0
  4. package/lib/callables/index.d.ts +1 -0
  5. package/lib/callables/index.js +1 -0
  6. package/lib/callables/index.js.map +1 -1
  7. package/lib/callables/jobRoles.d.ts +33 -491
  8. package/lib/callables/jobRoles.js +23 -59
  9. package/lib/callables/jobRoles.js.map +1 -1
  10. package/lib/callables/registry.d.ts +358 -932
  11. package/lib/callables/registry.js +5 -3
  12. package/lib/callables/registry.js.map +1 -1
  13. package/lib/index.d.ts +2 -0
  14. package/lib/index.js +2 -0
  15. package/lib/index.js.map +1 -1
  16. package/lib/invoicing.d.ts +182 -0
  17. package/lib/invoicing.js +144 -0
  18. package/lib/invoicing.js.map +1 -0
  19. package/lib/invoicing.test.d.ts +1 -0
  20. package/lib/invoicing.test.js +124 -0
  21. package/lib/invoicing.test.js.map +1 -0
  22. package/lib/lmi.d.ts +113 -1
  23. package/lib/lmi.js +227 -6
  24. package/lib/lmi.js.map +1 -1
  25. package/lib/lmi.test.d.ts +1 -0
  26. package/lib/lmi.test.js +100 -0
  27. package/lib/lmi.test.js.map +1 -0
  28. package/lib/lmiCategories.d.ts +39 -0
  29. package/lib/lmiCategories.js +293 -0
  30. package/lib/lmiCategories.js.map +1 -0
  31. package/lib/lmiCategories.test.d.ts +1 -0
  32. package/lib/lmiCategories.test.js +110 -0
  33. package/lib/lmiCategories.test.js.map +1 -0
  34. package/lib/typeDefinitions.d.ts +70 -1
  35. package/lib/typeDefinitions.js.map +1 -1
  36. package/package.json +1 -1
  37. package/src/callables/billing.ts +64 -0
  38. package/src/callables/index.ts +1 -0
  39. package/src/callables/jobRoles.ts +24 -61
  40. package/src/callables/registry.ts +5 -3
  41. package/src/index.ts +2 -0
  42. package/src/invoicing.test.ts +149 -0
  43. package/src/invoicing.ts +276 -0
  44. package/src/lmi.test.ts +115 -0
  45. package/src/lmi.ts +250 -6
  46. package/src/lmiCategories.test.ts +125 -0
  47. package/src/lmiCategories.ts +297 -0
  48. package/src/typeDefinitions.ts +70 -1
@@ -0,0 +1,259 @@
1
+ import { z } from "zod";
2
+ export declare const invoiceDraftSchema: z.ZodObject<{
3
+ lines: z.ZodArray<z.ZodObject<{
4
+ key: z.ZodOptional<z.ZodEnum<["base", "wexY10", "wexY12", "events", "destinations", "hubBase", "hubSchools", "adjustment"]>>;
5
+ description: z.ZodString;
6
+ quantity: z.ZodNumber;
7
+ unitAmount: z.ZodNumber;
8
+ discount: z.ZodOptional<z.ZodObject<{
9
+ type: z.ZodEnum<["percent", "amount"]>;
10
+ value: z.ZodNumber;
11
+ }, "strip", z.ZodTypeAny, {
12
+ type: "percent" | "amount";
13
+ value: number;
14
+ }, {
15
+ type: "percent" | "amount";
16
+ value: number;
17
+ }>>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ description: string;
20
+ quantity: number;
21
+ unitAmount: number;
22
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
23
+ discount?: {
24
+ type: "percent" | "amount";
25
+ value: number;
26
+ } | undefined;
27
+ }, {
28
+ description: string;
29
+ quantity: number;
30
+ unitAmount: number;
31
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
32
+ discount?: {
33
+ type: "percent" | "amount";
34
+ value: number;
35
+ } | undefined;
36
+ }>, "many">;
37
+ discount: z.ZodOptional<z.ZodObject<{
38
+ type: z.ZodEnum<["percent", "amount"]>;
39
+ value: z.ZodNumber;
40
+ }, "strip", z.ZodTypeAny, {
41
+ type: "percent" | "amount";
42
+ value: number;
43
+ }, {
44
+ type: "percent" | "amount";
45
+ value: number;
46
+ }>>;
47
+ reference: z.ZodOptional<z.ZodString>;
48
+ date: z.ZodOptional<z.ZodString>;
49
+ dueDate: z.ZodOptional<z.ZodString>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ lines: {
52
+ description: string;
53
+ quantity: number;
54
+ unitAmount: number;
55
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
56
+ discount?: {
57
+ type: "percent" | "amount";
58
+ value: number;
59
+ } | undefined;
60
+ }[];
61
+ date?: string | undefined;
62
+ discount?: {
63
+ type: "percent" | "amount";
64
+ value: number;
65
+ } | undefined;
66
+ dueDate?: string | undefined;
67
+ reference?: string | undefined;
68
+ }, {
69
+ lines: {
70
+ description: string;
71
+ quantity: number;
72
+ unitAmount: number;
73
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
74
+ discount?: {
75
+ type: "percent" | "amount";
76
+ value: number;
77
+ } | undefined;
78
+ }[];
79
+ date?: string | undefined;
80
+ discount?: {
81
+ type: "percent" | "amount";
82
+ value: number;
83
+ } | undefined;
84
+ dueDate?: string | undefined;
85
+ reference?: string | undefined;
86
+ }>;
87
+ export declare const billingCallables: {
88
+ /** Create a DRAFT invoice in Xero for an institute and record it in `invoices`. */
89
+ "billing-createXeroInvoice": {
90
+ request: z.ZodObject<{
91
+ oId: z.ZodString;
92
+ draft: z.ZodObject<{
93
+ lines: z.ZodArray<z.ZodObject<{
94
+ key: z.ZodOptional<z.ZodEnum<["base", "wexY10", "wexY12", "events", "destinations", "hubBase", "hubSchools", "adjustment"]>>;
95
+ description: z.ZodString;
96
+ quantity: z.ZodNumber;
97
+ unitAmount: z.ZodNumber;
98
+ discount: z.ZodOptional<z.ZodObject<{
99
+ type: z.ZodEnum<["percent", "amount"]>;
100
+ value: z.ZodNumber;
101
+ }, "strip", z.ZodTypeAny, {
102
+ type: "percent" | "amount";
103
+ value: number;
104
+ }, {
105
+ type: "percent" | "amount";
106
+ value: number;
107
+ }>>;
108
+ }, "strip", z.ZodTypeAny, {
109
+ description: string;
110
+ quantity: number;
111
+ unitAmount: number;
112
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
113
+ discount?: {
114
+ type: "percent" | "amount";
115
+ value: number;
116
+ } | undefined;
117
+ }, {
118
+ description: string;
119
+ quantity: number;
120
+ unitAmount: number;
121
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
122
+ discount?: {
123
+ type: "percent" | "amount";
124
+ value: number;
125
+ } | undefined;
126
+ }>, "many">;
127
+ discount: z.ZodOptional<z.ZodObject<{
128
+ type: z.ZodEnum<["percent", "amount"]>;
129
+ value: z.ZodNumber;
130
+ }, "strip", z.ZodTypeAny, {
131
+ type: "percent" | "amount";
132
+ value: number;
133
+ }, {
134
+ type: "percent" | "amount";
135
+ value: number;
136
+ }>>;
137
+ reference: z.ZodOptional<z.ZodString>;
138
+ date: z.ZodOptional<z.ZodString>;
139
+ dueDate: z.ZodOptional<z.ZodString>;
140
+ }, "strip", z.ZodTypeAny, {
141
+ lines: {
142
+ description: string;
143
+ quantity: number;
144
+ unitAmount: number;
145
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
146
+ discount?: {
147
+ type: "percent" | "amount";
148
+ value: number;
149
+ } | undefined;
150
+ }[];
151
+ date?: string | undefined;
152
+ discount?: {
153
+ type: "percent" | "amount";
154
+ value: number;
155
+ } | undefined;
156
+ dueDate?: string | undefined;
157
+ reference?: string | undefined;
158
+ }, {
159
+ lines: {
160
+ description: string;
161
+ quantity: number;
162
+ unitAmount: number;
163
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
164
+ discount?: {
165
+ type: "percent" | "amount";
166
+ value: number;
167
+ } | undefined;
168
+ }[];
169
+ date?: string | undefined;
170
+ discount?: {
171
+ type: "percent" | "amount";
172
+ value: number;
173
+ } | undefined;
174
+ dueDate?: string | undefined;
175
+ reference?: string | undefined;
176
+ }>;
177
+ }, "strip", z.ZodTypeAny, {
178
+ oId: string;
179
+ draft: {
180
+ lines: {
181
+ description: string;
182
+ quantity: number;
183
+ unitAmount: number;
184
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
185
+ discount?: {
186
+ type: "percent" | "amount";
187
+ value: number;
188
+ } | undefined;
189
+ }[];
190
+ date?: string | undefined;
191
+ discount?: {
192
+ type: "percent" | "amount";
193
+ value: number;
194
+ } | undefined;
195
+ dueDate?: string | undefined;
196
+ reference?: string | undefined;
197
+ };
198
+ }, {
199
+ oId: string;
200
+ draft: {
201
+ lines: {
202
+ description: string;
203
+ quantity: number;
204
+ unitAmount: number;
205
+ key?: "base" | "events" | "destinations" | "wexY10" | "wexY12" | "hubBase" | "hubSchools" | "adjustment" | undefined;
206
+ discount?: {
207
+ type: "percent" | "amount";
208
+ value: number;
209
+ } | undefined;
210
+ }[];
211
+ date?: string | undefined;
212
+ discount?: {
213
+ type: "percent" | "amount";
214
+ value: number;
215
+ } | undefined;
216
+ dueDate?: string | undefined;
217
+ reference?: string | undefined;
218
+ };
219
+ }>;
220
+ response: z.ZodObject<{
221
+ /** The Xero InvoiceID, which is also the `invoices` doc id. */
222
+ invoiceId: z.ZodString;
223
+ /** Absent until Xero approves the draft. */
224
+ invoiceNumber: z.ZodOptional<z.ZodString>;
225
+ /** Deep link to the draft in Xero. */
226
+ url: z.ZodString;
227
+ /** Inc VAT, as Xero calculated it. */
228
+ total: z.ZodNumber;
229
+ }, "strip", z.ZodTypeAny, {
230
+ total: number;
231
+ url: string;
232
+ invoiceId: string;
233
+ invoiceNumber?: string | undefined;
234
+ }, {
235
+ total: number;
236
+ url: string;
237
+ invoiceId: string;
238
+ invoiceNumber?: string | undefined;
239
+ }>;
240
+ };
241
+ /** Pull invoice statuses from Xero into `invoices`. One institute, or every
242
+ * invoice changed since the last sync when no oId is given. */
243
+ "billing-syncXeroInvoices": {
244
+ request: z.ZodObject<{
245
+ oId: z.ZodOptional<z.ZodString>;
246
+ }, "strip", z.ZodTypeAny, {
247
+ oId?: string | undefined;
248
+ }, {
249
+ oId?: string | undefined;
250
+ }>;
251
+ response: z.ZodObject<{
252
+ synced: z.ZodNumber;
253
+ }, "strip", z.ZodTypeAny, {
254
+ synced: number;
255
+ }, {
256
+ synced: number;
257
+ }>;
258
+ };
259
+ };
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.billingCallables = exports.invoiceDraftSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Contracts for invoicing (`Placementt-Backend/functions/src/billing.ts`).
7
+ *
8
+ * Both are admin-only. The draft is validated here rather than trusted, since
9
+ * it is what becomes a real invoice in Xero — a row with a NaN quantity would
10
+ * be rejected by Xero with an error that says nothing about which row.
11
+ */
12
+ const invoiceDiscountSchema = zod_1.z.object({
13
+ type: zod_1.z.enum(["percent", "amount"]),
14
+ value: zod_1.z.number().min(0),
15
+ });
16
+ /** Mirrors `PricingLineKey | "adjustment"` in ../invoicing. */
17
+ const invoiceLineKeySchema = zod_1.z.enum(["base", "wexY10", "wexY12", "events", "destinations", "hubBase", "hubSchools", "adjustment"]);
18
+ const invoiceLineSchema = zod_1.z.object({
19
+ key: invoiceLineKeySchema.optional(),
20
+ description: zod_1.z.string().min(1),
21
+ quantity: zod_1.z.number(),
22
+ unitAmount: zod_1.z.number(),
23
+ discount: invoiceDiscountSchema.optional(),
24
+ });
25
+ exports.invoiceDraftSchema = zod_1.z.object({
26
+ lines: zod_1.z.array(invoiceLineSchema).min(1),
27
+ discount: invoiceDiscountSchema.optional(),
28
+ reference: zod_1.z.string().optional(),
29
+ date: zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
30
+ dueDate: zod_1.z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
31
+ });
32
+ exports.billingCallables = {
33
+ /** Create a DRAFT invoice in Xero for an institute and record it in `invoices`. */
34
+ "billing-createXeroInvoice": {
35
+ request: zod_1.z.object({
36
+ oId: zod_1.z.string(),
37
+ draft: exports.invoiceDraftSchema,
38
+ }),
39
+ response: zod_1.z.object({
40
+ /** The Xero InvoiceID, which is also the `invoices` doc id. */
41
+ invoiceId: zod_1.z.string(),
42
+ /** Absent until Xero approves the draft. */
43
+ invoiceNumber: zod_1.z.string().optional(),
44
+ /** Deep link to the draft in Xero. */
45
+ url: zod_1.z.string(),
46
+ /** Inc VAT, as Xero calculated it. */
47
+ total: zod_1.z.number(),
48
+ }),
49
+ },
50
+ /** Pull invoice statuses from Xero into `invoices`. One institute, or every
51
+ * invoice changed since the last sync when no oId is given. */
52
+ "billing-syncXeroInvoices": {
53
+ request: zod_1.z.object({
54
+ oId: zod_1.z.string().optional(),
55
+ }),
56
+ response: zod_1.z.object({
57
+ synced: zod_1.z.number(),
58
+ }),
59
+ },
60
+ };
61
+ //# sourceMappingURL=billing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/callables/billing.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAGtB;;;;;;GAMG;AAEH,MAAM,qBAAqB,GAAG,OAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3B,CAAC,CAAC;AAEH,+DAA+D;AAC/D,MAAM,oBAAoB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AAEnI,MAAM,iBAAiB,GAAG,OAAC,CAAC,MA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C+D;IAC/D,0BAA0B,EAAE;QACxB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;YACd,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC7B,CAAC;QACF,QAAQ,EAAE,OAAC,CAAC,MAAM,CAAC;YACf,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;SACrB,CAAC;KACL;CACoB,CAAC"}
@@ -7,3 +7,4 @@ export * from "./jobRoles";
7
7
  export * from "./apprenticeships";
8
8
  export * from "./he";
9
9
  export * from "./activityLogging";
10
+ export * from "./billing";
@@ -23,4 +23,5 @@ __exportStar(require("./jobRoles"), exports);
23
23
  __exportStar(require("./apprenticeships"), exports);
24
24
  __exportStar(require("./he"), exports);
25
25
  __exportStar(require("./activityLogging"), exports);
26
+ __exportStar(require("./billing"), exports);
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/callables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,uDAAqC;AACrC,8CAA4B;AAC5B,2CAAyB;AACzB,6CAA2B;AAC3B,oDAAkC;AAClC,uCAAqB;AACrB,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/callables/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,uDAAqC;AACrC,8CAA4B;AAC5B,2CAAyB;AACzB,6CAA2B;AAC3B,oDAAkC;AAClC,uCAAqB;AACrB,oDAAkC;AAClC,4CAA0B"}