@defra/fcp-sfd-frontend-engine 0.26.0 → 0.27.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/dist/index.cjs CHANGED
@@ -150,6 +150,79 @@ var BUSINESS_UPDATE_TEXT_LABELS = {
150
150
  vat: "your business VAT number"
151
151
  };
152
152
 
153
+ // src/constants/business-legal-status.js
154
+ var BUSINESS_LEGAL_STATUS = {
155
+ charitableIncorporatedOrganisation: {
156
+ text: "Charitable incorporated organisation (CIO)",
157
+ code: "102101"
158
+ },
159
+ charitableTrust: {
160
+ text: "Charitable trust",
161
+ code: "102113"
162
+ },
163
+ communityInterestCompany: {
164
+ text: "Community interest company (CIC)",
165
+ code: "102102"
166
+ },
167
+ governmentCentral: {
168
+ text: "Government (central)",
169
+ code: "102103"
170
+ },
171
+ governmentLocal: {
172
+ text: "Government (local)",
173
+ code: "102104"
174
+ },
175
+ limitedLiabilityPartnership: {
176
+ text: "Limited liability partnership (LLP)",
177
+ code: "102105"
178
+ },
179
+ limitedPartnership: {
180
+ text: "Limited partnership",
181
+ code: "102106"
182
+ },
183
+ nonUkCompany: {
184
+ text: "Non-UK company",
185
+ code: "102107"
186
+ },
187
+ partnership: {
188
+ text: "Partnership",
189
+ code: "102108"
190
+ },
191
+ privateLimitedCompany: {
192
+ text: "Private limited company (Ltd)",
193
+ code: "102109"
194
+ },
195
+ publicLimitedCompany: {
196
+ text: "Public limited company (PLC)",
197
+ code: "102110"
198
+ },
199
+ soleProprietorship: {
200
+ text: "Sole proprietorship",
201
+ code: "102111"
202
+ },
203
+ crown: {
204
+ text: "The Crown",
205
+ code: "102112"
206
+ },
207
+ unlimitedCompany: {
208
+ text: "Unlimited company (Ultd)",
209
+ code: "102114"
210
+ }
211
+ };
212
+ var BUSINESS_LEGAL_STATUS_CODES = Object.values(BUSINESS_LEGAL_STATUS).map(({ code }) => code);
213
+ var CHARITY_REGISTRATION_LEGAL_STATUS_CODES = [
214
+ BUSINESS_LEGAL_STATUS.charitableIncorporatedOrganisation.code
215
+ ];
216
+ var COMPANY_REGISTRATION_LEGAL_STATUS_CODES = [
217
+ BUSINESS_LEGAL_STATUS.communityInterestCompany.code,
218
+ BUSINESS_LEGAL_STATUS.limitedLiabilityPartnership.code,
219
+ BUSINESS_LEGAL_STATUS.limitedPartnership.code,
220
+ BUSINESS_LEGAL_STATUS.nonUkCompany.code,
221
+ BUSINESS_LEGAL_STATUS.privateLimitedCompany.code,
222
+ BUSINESS_LEGAL_STATUS.publicLimitedCompany.code,
223
+ BUSINESS_LEGAL_STATUS.unlimitedCompany.code
224
+ ];
225
+
153
226
  // src/constants/index.js
154
227
  var constants = {
155
228
  statusCodes: {
@@ -199,6 +272,12 @@ var constants = {
199
272
  BUSINESS_SECTION_LABELS,
200
273
  PERSONAL_UPDATE_TEXT_LABELS,
201
274
  BUSINESS_UPDATE_TEXT_LABELS
275
+ },
276
+ business: {
277
+ LEGAL_STATUS: BUSINESS_LEGAL_STATUS,
278
+ LEGAL_STATUS_CODES: BUSINESS_LEGAL_STATUS_CODES,
279
+ CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
280
+ COMPANY_REGISTRATION_LEGAL_STATUS_CODES
202
281
  }
203
282
  };
204
283
 
@@ -256,7 +335,7 @@ var mapCustomerName = (name = {}) => {
256
335
  // src/mappers/business-details-mapper.js
257
336
  var asNullable = (value) => value ?? null;
258
337
  var mapBusinessInfo = (business) => {
259
- var _a, _b;
338
+ var _a, _b, _c;
260
339
  const info = business.info ?? {};
261
340
  return {
262
341
  sbi: business.sbi,
@@ -265,7 +344,8 @@ var mapBusinessInfo = (business) => {
265
344
  traderNumber: asNullable(info.traderNumber),
266
345
  vendorNumber: asNullable(info.vendorNumber),
267
346
  legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
268
- type: asNullable((_b = info.type) == null ? void 0 : _b.type),
347
+ legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
348
+ type: asNullable((_c = info.type) == null ? void 0 : _c.type),
269
349
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
270
350
  };
271
351
  };
@@ -420,6 +500,37 @@ var businessVatRemoveSchema = Joi.object({
420
500
  })
421
501
  });
422
502
 
503
+ // src/schemas/business/business-legal-status-schema.js
504
+ var ERROR_MESSAGE = "Select a legal status";
505
+ var businessLegalStatusSchema = Joi.object({
506
+ // Restricting to our own known codes means an invalid/tampered value is treated the same as no selection
507
+ businessLegalStatus: Joi.string().valid(...BUSINESS_LEGAL_STATUS_CODES).required().messages({
508
+ "string.empty": ERROR_MESSAGE,
509
+ "any.required": ERROR_MESSAGE,
510
+ "any.only": ERROR_MESSAGE
511
+ })
512
+ });
513
+
514
+ // src/schemas/business/business-charity-registration-number-schema.js
515
+ var businessCharityRegistrationNumberSchema = Joi.object({
516
+ charityCommissionRegistrationNumber: Joi.string().trim().required().pattern(/^\d{7,8}$/).messages({
517
+ "string.empty": "Enter the charity commission registration number",
518
+ "any.required": "Enter the charity commission registration number",
519
+ "string.pattern.base": "Charity commission registration number must be 7 or 8 numbers",
520
+ "string.noControlChars": "Charity commission registration number must only include numbers"
521
+ })
522
+ });
523
+
524
+ // src/schemas/business/business-company-registration-number-schema.js
525
+ var businessCompanyRegistrationNumberSchema = Joi.object({
526
+ companyRegistrationNumber: Joi.string().trim().required().pattern(/^(\d{8}|[A-Za-z]{2}\d{6})$/).messages({
527
+ "string.empty": "Enter the company registration number",
528
+ "any.required": "Enter the company registration number",
529
+ "string.pattern.base": "Company registration number must be 8 numbers, or 2 letters followed by 6 numbers",
530
+ "string.noControlChars": "Company registration number must only include letters and numbers"
531
+ })
532
+ });
533
+
423
534
  // src/schemas/business/business-schemas.js
424
535
  var businessSchemas = {
425
536
  sbi: businessSbiSchema,
@@ -433,6 +544,11 @@ var businessSchemas = {
433
544
  vat: {
434
545
  change: businessVatChangeSchema,
435
546
  remove: businessVatRemoveSchema
547
+ },
548
+ legalStatus: businessLegalStatusSchema,
549
+ legalStatusRegistration: {
550
+ charity: businessCharityRegistrationNumberSchema,
551
+ company: businessCompanyRegistrationNumberSchema
436
552
  }
437
553
  };
438
554
 
@@ -983,6 +1099,40 @@ var updateCustomerDetailsMutation = `
983
1099
  }
984
1100
  `;
985
1101
 
1102
+ // src/mutations/business/update-business-legal-status.js
1103
+ var updateBusinessLegalStatusMutation = `
1104
+ mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
1105
+ updateBusinessLegalStatus(input: $input) {
1106
+ business {
1107
+ info {
1108
+ legalStatus {
1109
+ code
1110
+ type
1111
+ }
1112
+ }
1113
+ }
1114
+ success
1115
+ }
1116
+ }
1117
+ `;
1118
+
1119
+ // src/mutations/business/update-business-registration-numbers.js
1120
+ var updateBusinessRegistrationNumbersMutation = `
1121
+ mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
1122
+ updateBusinessRegistrationNumbers(input: $input) {
1123
+ business {
1124
+ info {
1125
+ registrationNumbers {
1126
+ companiesHouse
1127
+ charityCommission
1128
+ }
1129
+ }
1130
+ }
1131
+ success
1132
+ }
1133
+ }
1134
+ `;
1135
+
986
1136
  // src/mutations/mutations.js
987
1137
  var mutations = {
988
1138
  updateBusinessEmail: updateBusinessEmailMutation,
@@ -995,7 +1145,9 @@ var mutations = {
995
1145
  updateCustomerEmail: updateCustomerEmailMutation,
996
1146
  updateCustomerAddress: updateCustomerAddressMutation,
997
1147
  updateBusinessVat: updateBusinessVatMutation,
998
- updateCustomerDetails: updateCustomerDetailsMutation
1148
+ updateCustomerDetails: updateCustomerDetailsMutation,
1149
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1150
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
999
1151
  };
1000
1152
 
1001
1153
  // src/presenters/base-presenter.js
package/dist/index.js CHANGED
@@ -109,6 +109,79 @@ var BUSINESS_UPDATE_TEXT_LABELS = {
109
109
  vat: "your business VAT number"
110
110
  };
111
111
 
112
+ // src/constants/business-legal-status.js
113
+ var BUSINESS_LEGAL_STATUS = {
114
+ charitableIncorporatedOrganisation: {
115
+ text: "Charitable incorporated organisation (CIO)",
116
+ code: "102101"
117
+ },
118
+ charitableTrust: {
119
+ text: "Charitable trust",
120
+ code: "102113"
121
+ },
122
+ communityInterestCompany: {
123
+ text: "Community interest company (CIC)",
124
+ code: "102102"
125
+ },
126
+ governmentCentral: {
127
+ text: "Government (central)",
128
+ code: "102103"
129
+ },
130
+ governmentLocal: {
131
+ text: "Government (local)",
132
+ code: "102104"
133
+ },
134
+ limitedLiabilityPartnership: {
135
+ text: "Limited liability partnership (LLP)",
136
+ code: "102105"
137
+ },
138
+ limitedPartnership: {
139
+ text: "Limited partnership",
140
+ code: "102106"
141
+ },
142
+ nonUkCompany: {
143
+ text: "Non-UK company",
144
+ code: "102107"
145
+ },
146
+ partnership: {
147
+ text: "Partnership",
148
+ code: "102108"
149
+ },
150
+ privateLimitedCompany: {
151
+ text: "Private limited company (Ltd)",
152
+ code: "102109"
153
+ },
154
+ publicLimitedCompany: {
155
+ text: "Public limited company (PLC)",
156
+ code: "102110"
157
+ },
158
+ soleProprietorship: {
159
+ text: "Sole proprietorship",
160
+ code: "102111"
161
+ },
162
+ crown: {
163
+ text: "The Crown",
164
+ code: "102112"
165
+ },
166
+ unlimitedCompany: {
167
+ text: "Unlimited company (Ultd)",
168
+ code: "102114"
169
+ }
170
+ };
171
+ var BUSINESS_LEGAL_STATUS_CODES = Object.values(BUSINESS_LEGAL_STATUS).map(({ code }) => code);
172
+ var CHARITY_REGISTRATION_LEGAL_STATUS_CODES = [
173
+ BUSINESS_LEGAL_STATUS.charitableIncorporatedOrganisation.code
174
+ ];
175
+ var COMPANY_REGISTRATION_LEGAL_STATUS_CODES = [
176
+ BUSINESS_LEGAL_STATUS.communityInterestCompany.code,
177
+ BUSINESS_LEGAL_STATUS.limitedLiabilityPartnership.code,
178
+ BUSINESS_LEGAL_STATUS.limitedPartnership.code,
179
+ BUSINESS_LEGAL_STATUS.nonUkCompany.code,
180
+ BUSINESS_LEGAL_STATUS.privateLimitedCompany.code,
181
+ BUSINESS_LEGAL_STATUS.publicLimitedCompany.code,
182
+ BUSINESS_LEGAL_STATUS.unlimitedCompany.code
183
+ ];
184
+
112
185
  // src/constants/index.js
113
186
  var constants = {
114
187
  statusCodes: {
@@ -158,6 +231,12 @@ var constants = {
158
231
  BUSINESS_SECTION_LABELS,
159
232
  PERSONAL_UPDATE_TEXT_LABELS,
160
233
  BUSINESS_UPDATE_TEXT_LABELS
234
+ },
235
+ business: {
236
+ LEGAL_STATUS: BUSINESS_LEGAL_STATUS,
237
+ LEGAL_STATUS_CODES: BUSINESS_LEGAL_STATUS_CODES,
238
+ CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
239
+ COMPANY_REGISTRATION_LEGAL_STATUS_CODES
161
240
  }
162
241
  };
163
242
 
@@ -215,7 +294,7 @@ var mapCustomerName = (name = {}) => {
215
294
  // src/mappers/business-details-mapper.js
216
295
  var asNullable = (value) => value ?? null;
217
296
  var mapBusinessInfo = (business) => {
218
- var _a, _b;
297
+ var _a, _b, _c;
219
298
  const info = business.info ?? {};
220
299
  return {
221
300
  sbi: business.sbi,
@@ -224,7 +303,8 @@ var mapBusinessInfo = (business) => {
224
303
  traderNumber: asNullable(info.traderNumber),
225
304
  vendorNumber: asNullable(info.vendorNumber),
226
305
  legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
227
- type: asNullable((_b = info.type) == null ? void 0 : _b.type),
306
+ legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
307
+ type: asNullable((_c = info.type) == null ? void 0 : _c.type),
228
308
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
229
309
  };
230
310
  };
@@ -379,6 +459,37 @@ var businessVatRemoveSchema = Joi.object({
379
459
  })
380
460
  });
381
461
 
462
+ // src/schemas/business/business-legal-status-schema.js
463
+ var ERROR_MESSAGE = "Select a legal status";
464
+ var businessLegalStatusSchema = Joi.object({
465
+ // Restricting to our own known codes means an invalid/tampered value is treated the same as no selection
466
+ businessLegalStatus: Joi.string().valid(...BUSINESS_LEGAL_STATUS_CODES).required().messages({
467
+ "string.empty": ERROR_MESSAGE,
468
+ "any.required": ERROR_MESSAGE,
469
+ "any.only": ERROR_MESSAGE
470
+ })
471
+ });
472
+
473
+ // src/schemas/business/business-charity-registration-number-schema.js
474
+ var businessCharityRegistrationNumberSchema = Joi.object({
475
+ charityCommissionRegistrationNumber: Joi.string().trim().required().pattern(/^\d{7,8}$/).messages({
476
+ "string.empty": "Enter the charity commission registration number",
477
+ "any.required": "Enter the charity commission registration number",
478
+ "string.pattern.base": "Charity commission registration number must be 7 or 8 numbers",
479
+ "string.noControlChars": "Charity commission registration number must only include numbers"
480
+ })
481
+ });
482
+
483
+ // src/schemas/business/business-company-registration-number-schema.js
484
+ var businessCompanyRegistrationNumberSchema = Joi.object({
485
+ companyRegistrationNumber: Joi.string().trim().required().pattern(/^(\d{8}|[A-Za-z]{2}\d{6})$/).messages({
486
+ "string.empty": "Enter the company registration number",
487
+ "any.required": "Enter the company registration number",
488
+ "string.pattern.base": "Company registration number must be 8 numbers, or 2 letters followed by 6 numbers",
489
+ "string.noControlChars": "Company registration number must only include letters and numbers"
490
+ })
491
+ });
492
+
382
493
  // src/schemas/business/business-schemas.js
383
494
  var businessSchemas = {
384
495
  sbi: businessSbiSchema,
@@ -392,6 +503,11 @@ var businessSchemas = {
392
503
  vat: {
393
504
  change: businessVatChangeSchema,
394
505
  remove: businessVatRemoveSchema
506
+ },
507
+ legalStatus: businessLegalStatusSchema,
508
+ legalStatusRegistration: {
509
+ charity: businessCharityRegistrationNumberSchema,
510
+ company: businessCompanyRegistrationNumberSchema
395
511
  }
396
512
  };
397
513
 
@@ -942,6 +1058,40 @@ var updateCustomerDetailsMutation = `
942
1058
  }
943
1059
  `;
944
1060
 
1061
+ // src/mutations/business/update-business-legal-status.js
1062
+ var updateBusinessLegalStatusMutation = `
1063
+ mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
1064
+ updateBusinessLegalStatus(input: $input) {
1065
+ business {
1066
+ info {
1067
+ legalStatus {
1068
+ code
1069
+ type
1070
+ }
1071
+ }
1072
+ }
1073
+ success
1074
+ }
1075
+ }
1076
+ `;
1077
+
1078
+ // src/mutations/business/update-business-registration-numbers.js
1079
+ var updateBusinessRegistrationNumbersMutation = `
1080
+ mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
1081
+ updateBusinessRegistrationNumbers(input: $input) {
1082
+ business {
1083
+ info {
1084
+ registrationNumbers {
1085
+ companiesHouse
1086
+ charityCommission
1087
+ }
1088
+ }
1089
+ }
1090
+ success
1091
+ }
1092
+ }
1093
+ `;
1094
+
945
1095
  // src/mutations/mutations.js
946
1096
  var mutations = {
947
1097
  updateBusinessEmail: updateBusinessEmailMutation,
@@ -954,7 +1104,9 @@ var mutations = {
954
1104
  updateCustomerEmail: updateCustomerEmailMutation,
955
1105
  updateCustomerAddress: updateCustomerAddressMutation,
956
1106
  updateBusinessVat: updateBusinessVatMutation,
957
- updateCustomerDetails: updateCustomerDetailsMutation
1107
+ updateCustomerDetails: updateCustomerDetailsMutation,
1108
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1109
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
958
1110
  };
959
1111
 
960
1112
  // src/presenters/base-presenter.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/fcp-sfd-frontend-engine",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Shared frontend engine used by both the internal and external frontend applications.",
5
5
  "main": "./dist/index.cjs",
6
6
  "exports": {
@@ -0,0 +1,77 @@
1
+ export const BUSINESS_LEGAL_STATUS = {
2
+ charitableIncorporatedOrganisation: {
3
+ text: 'Charitable incorporated organisation (CIO)',
4
+ code: '102101'
5
+ },
6
+ charitableTrust: {
7
+ text: 'Charitable trust',
8
+ code: '102113'
9
+ },
10
+ communityInterestCompany: {
11
+ text: 'Community interest company (CIC)',
12
+ code: '102102'
13
+ },
14
+ governmentCentral: {
15
+ text: 'Government (central)',
16
+ code: '102103'
17
+ },
18
+ governmentLocal: {
19
+ text: 'Government (local)',
20
+ code: '102104'
21
+ },
22
+ limitedLiabilityPartnership: {
23
+ text: 'Limited liability partnership (LLP)',
24
+ code: '102105'
25
+ },
26
+ limitedPartnership: {
27
+ text: 'Limited partnership',
28
+ code: '102106'
29
+ },
30
+ nonUkCompany: {
31
+ text: 'Non-UK company',
32
+ code: '102107'
33
+ },
34
+ partnership: {
35
+ text: 'Partnership',
36
+ code: '102108'
37
+ },
38
+ privateLimitedCompany: {
39
+ text: 'Private limited company (Ltd)',
40
+ code: '102109'
41
+ },
42
+ publicLimitedCompany: {
43
+ text: 'Public limited company (PLC)',
44
+ code: '102110'
45
+ },
46
+ soleProprietorship: {
47
+ text: 'Sole proprietorship',
48
+ code: '102111'
49
+ },
50
+ crown: {
51
+ text: 'The Crown',
52
+ code: '102112'
53
+ },
54
+ unlimitedCompany: {
55
+ text: 'Unlimited company (Ultd)',
56
+ code: '102114'
57
+ },
58
+ }
59
+
60
+ // Derived from BUSINESS_LEGAL_STATUS so the codes can't drift out of sync
61
+ export const BUSINESS_LEGAL_STATUS_CODES = Object.values(BUSINESS_LEGAL_STATUS).map(({ code }) => code)
62
+
63
+ // Legal statuses that must provide a Charity Commission registration number
64
+ export const CHARITY_REGISTRATION_LEGAL_STATUS_CODES = [
65
+ BUSINESS_LEGAL_STATUS.charitableIncorporatedOrganisation.code
66
+ ]
67
+
68
+ // Legal statuses that must provide a Companies House registration number
69
+ export const COMPANY_REGISTRATION_LEGAL_STATUS_CODES = [
70
+ BUSINESS_LEGAL_STATUS.communityInterestCompany.code,
71
+ BUSINESS_LEGAL_STATUS.limitedLiabilityPartnership.code,
72
+ BUSINESS_LEGAL_STATUS.limitedPartnership.code,
73
+ BUSINESS_LEGAL_STATUS.nonUkCompany.code,
74
+ BUSINESS_LEGAL_STATUS.privateLimitedCompany.code,
75
+ BUSINESS_LEGAL_STATUS.publicLimitedCompany.code,
76
+ BUSINESS_LEGAL_STATUS.unlimitedCompany.code
77
+ ]
@@ -53,6 +53,13 @@ import {
53
53
  BUSINESS_UPDATE_TEXT_LABELS
54
54
  } from './interrupter-journey.js'
55
55
 
56
+ import {
57
+ BUSINESS_LEGAL_STATUS,
58
+ BUSINESS_LEGAL_STATUS_CODES,
59
+ CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
60
+ COMPANY_REGISTRATION_LEGAL_STATUS_CODES
61
+ } from './business-legal-status.js'
62
+
56
63
  export const constants = {
57
64
  statusCodes: {
58
65
  BAD_REQUEST,
@@ -101,5 +108,11 @@ export const constants = {
101
108
  BUSINESS_SECTION_LABELS,
102
109
  PERSONAL_UPDATE_TEXT_LABELS,
103
110
  BUSINESS_UPDATE_TEXT_LABELS
111
+ },
112
+ business: {
113
+ LEGAL_STATUS: BUSINESS_LEGAL_STATUS,
114
+ LEGAL_STATUS_CODES: BUSINESS_LEGAL_STATUS_CODES,
115
+ CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
116
+ COMPANY_REGISTRATION_LEGAL_STATUS_CODES
104
117
  }
105
118
  }
@@ -23,6 +23,7 @@ const mapBusinessInfo = (business) => {
23
23
  traderNumber: asNullable(info.traderNumber),
24
24
  vendorNumber: asNullable(info.vendorNumber),
25
25
  legalStatus: asNullable(info.legalStatus?.type),
26
+ legalStatusCode: asNullable(info.legalStatus?.code),
26
27
  type: asNullable(info.type?.type),
27
28
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
28
29
  }
@@ -0,0 +1,15 @@
1
+ export const updateBusinessLegalStatusMutation = `
2
+ mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
3
+ updateBusinessLegalStatus(input: $input) {
4
+ business {
5
+ info {
6
+ legalStatus {
7
+ code
8
+ type
9
+ }
10
+ }
11
+ }
12
+ success
13
+ }
14
+ }
15
+ `
@@ -0,0 +1,15 @@
1
+ export const updateBusinessRegistrationNumbersMutation = `
2
+ mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
3
+ updateBusinessRegistrationNumbers(input: $input) {
4
+ business {
5
+ info {
6
+ registrationNumbers {
7
+ companiesHouse
8
+ charityCommission
9
+ }
10
+ }
11
+ }
12
+ success
13
+ }
14
+ }
15
+ `
@@ -9,6 +9,8 @@ import { updateCustomerAddressMutation } from './personal/update-customer-addres
9
9
  import { updateBusinessAddressMutation } from './business/update-business-address.js'
10
10
  import { updateBusinessVatMutation } from './business/update-business-vat.js'
11
11
  import { updateCustomerDetailsMutation } from './personal/update-customer-details.js'
12
+ import { updateBusinessLegalStatusMutation } from './business/update-business-legal-status.js'
13
+ import { updateBusinessRegistrationNumbersMutation } from './business/update-business-registration-numbers.js'
12
14
 
13
15
  export const mutations = {
14
16
  updateBusinessEmail: updateBusinessEmailMutation,
@@ -21,5 +23,7 @@ export const mutations = {
21
23
  updateCustomerEmail: updateCustomerEmailMutation,
22
24
  updateCustomerAddress: updateCustomerAddressMutation,
23
25
  updateBusinessVat: updateBusinessVatMutation,
24
- updateCustomerDetails: updateCustomerDetailsMutation
26
+ updateCustomerDetails: updateCustomerDetailsMutation,
27
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
28
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
25
29
  }
@@ -0,0 +1,15 @@
1
+ import { Joi } from '../../utils/joi.js'
2
+
3
+ // Charity Commission registration numbers are 7 or 8 digits (England and Wales)
4
+ export const businessCharityRegistrationNumberSchema = Joi.object({
5
+ charityCommissionRegistrationNumber: Joi.string()
6
+ .trim()
7
+ .required()
8
+ .pattern(/^\d{7,8}$/)
9
+ .messages({
10
+ 'string.empty': 'Enter the charity commission registration number',
11
+ 'any.required': 'Enter the charity commission registration number',
12
+ 'string.pattern.base': 'Charity commission registration number must be 7 or 8 numbers',
13
+ 'string.noControlChars': 'Charity commission registration number must only include numbers'
14
+ })
15
+ })
@@ -0,0 +1,15 @@
1
+ import { Joi } from '../../utils/joi.js'
2
+
3
+ // Companies House registration numbers are either 8 digits, or 2 letters followed by 6 digits
4
+ export const businessCompanyRegistrationNumberSchema = Joi.object({
5
+ companyRegistrationNumber: Joi.string()
6
+ .trim()
7
+ .required()
8
+ .pattern(/^(\d{8}|[A-Za-z]{2}\d{6})$/)
9
+ .messages({
10
+ 'string.empty': 'Enter the company registration number',
11
+ 'any.required': 'Enter the company registration number',
12
+ 'string.pattern.base': 'Company registration number must be 8 numbers, or 2 letters followed by 6 numbers',
13
+ 'string.noControlChars': 'Company registration number must only include letters and numbers'
14
+ })
15
+ })
@@ -0,0 +1,16 @@
1
+ import { Joi } from '../../utils/joi.js'
2
+ import { BUSINESS_LEGAL_STATUS_CODES } from '../../constants/business-legal-status.js'
3
+
4
+ const ERROR_MESSAGE = 'Select a legal status'
5
+
6
+ export const businessLegalStatusSchema = Joi.object({
7
+ // Restricting to our own known codes means an invalid/tampered value is treated the same as no selection
8
+ businessLegalStatus: Joi.string()
9
+ .valid(...BUSINESS_LEGAL_STATUS_CODES)
10
+ .required()
11
+ .messages({
12
+ 'string.empty': ERROR_MESSAGE,
13
+ 'any.required': ERROR_MESSAGE,
14
+ 'any.only': ERROR_MESSAGE
15
+ })
16
+ })
@@ -6,6 +6,9 @@ import { businessPhoneSchema } from './business-phone-schema.js'
6
6
  import { businessVatSchema } from './business-vat-schema.js'
7
7
  import { businessVatChangeSchema } from './business-vat-change-schema.js'
8
8
  import { businessVatRemoveSchema } from './business-vat-remove-schema.js'
9
+ import { businessLegalStatusSchema } from './business-legal-status-schema.js'
10
+ import { businessCharityRegistrationNumberSchema } from './business-charity-registration-number-schema.js'
11
+ import { businessCompanyRegistrationNumberSchema } from './business-company-registration-number-schema.js'
9
12
 
10
13
  /**
11
14
  * The businessSchema object has a nested property of `details`.
@@ -34,5 +37,10 @@ export const businessSchemas = {
34
37
  vat: {
35
38
  change: businessVatChangeSchema,
36
39
  remove: businessVatRemoveSchema
40
+ },
41
+ legalStatus: businessLegalStatusSchema,
42
+ legalStatusRegistration: {
43
+ charity: businessCharityRegistrationNumberSchema,
44
+ company: businessCompanyRegistrationNumberSchema
37
45
  }
38
46
  }