@defra/fcp-sfd-frontend-engine 0.25.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
@@ -102,6 +102,7 @@ var BUSINESS_EMAIL_ADDRESS = "You have updated your business email address";
102
102
  var BUSINESS_NAME = "You have updated your business name";
103
103
  var BUSINESS_PHONE_NUMBERS = "You have updated your business phone numbers";
104
104
  var BUSINESS_VAT = "You have updated your VAT registration number";
105
+ var BUSINESS_VAT_REMOVE = "You have removed your VAT registration number";
105
106
 
106
107
  // src/constants/interrupter-journey.js
107
108
  var PERSONAL_SECTION_FIELD_ORDER = {
@@ -149,6 +150,79 @@ var BUSINESS_UPDATE_TEXT_LABELS = {
149
150
  vat: "your business VAT number"
150
151
  };
151
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
+
152
226
  // src/constants/index.js
153
227
  var constants = {
154
228
  statusCodes: {
@@ -186,7 +260,8 @@ var constants = {
186
260
  BUSINESS_EMAIL_ADDRESS,
187
261
  BUSINESS_NAME,
188
262
  BUSINESS_PHONE_NUMBERS,
189
- BUSINESS_VAT
263
+ BUSINESS_VAT,
264
+ BUSINESS_VAT_REMOVE
190
265
  },
191
266
  interrupterJourney: {
192
267
  PERSONAL_SECTION_FIELD_ORDER,
@@ -197,6 +272,12 @@ var constants = {
197
272
  BUSINESS_SECTION_LABELS,
198
273
  PERSONAL_UPDATE_TEXT_LABELS,
199
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
200
281
  }
201
282
  };
202
283
 
@@ -254,7 +335,7 @@ var mapCustomerName = (name = {}) => {
254
335
  // src/mappers/business-details-mapper.js
255
336
  var asNullable = (value) => value ?? null;
256
337
  var mapBusinessInfo = (business) => {
257
- var _a, _b;
338
+ var _a, _b, _c;
258
339
  const info = business.info ?? {};
259
340
  return {
260
341
  sbi: business.sbi,
@@ -263,7 +344,8 @@ var mapBusinessInfo = (business) => {
263
344
  traderNumber: asNullable(info.traderNumber),
264
345
  vendorNumber: asNullable(info.vendorNumber),
265
346
  legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
266
- 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),
267
349
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
268
350
  };
269
351
  };
@@ -418,6 +500,37 @@ var businessVatRemoveSchema = Joi.object({
418
500
  })
419
501
  });
420
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
+
421
534
  // src/schemas/business/business-schemas.js
422
535
  var businessSchemas = {
423
536
  sbi: businessSbiSchema,
@@ -431,6 +544,11 @@ var businessSchemas = {
431
544
  vat: {
432
545
  change: businessVatChangeSchema,
433
546
  remove: businessVatRemoveSchema
547
+ },
548
+ legalStatus: businessLegalStatusSchema,
549
+ legalStatusRegistration: {
550
+ charity: businessCharityRegistrationNumberSchema,
551
+ company: businessCompanyRegistrationNumberSchema
434
552
  }
435
553
  };
436
554
 
@@ -981,6 +1099,40 @@ var updateCustomerDetailsMutation = `
981
1099
  }
982
1100
  `;
983
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
+
984
1136
  // src/mutations/mutations.js
985
1137
  var mutations = {
986
1138
  updateBusinessEmail: updateBusinessEmailMutation,
@@ -993,7 +1145,9 @@ var mutations = {
993
1145
  updateCustomerEmail: updateCustomerEmailMutation,
994
1146
  updateCustomerAddress: updateCustomerAddressMutation,
995
1147
  updateBusinessVat: updateBusinessVatMutation,
996
- updateCustomerDetails: updateCustomerDetailsMutation
1148
+ updateCustomerDetails: updateCustomerDetailsMutation,
1149
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1150
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
997
1151
  };
998
1152
 
999
1153
  // src/presenters/base-presenter.js
package/dist/index.js CHANGED
@@ -61,6 +61,7 @@ var BUSINESS_EMAIL_ADDRESS = "You have updated your business email address";
61
61
  var BUSINESS_NAME = "You have updated your business name";
62
62
  var BUSINESS_PHONE_NUMBERS = "You have updated your business phone numbers";
63
63
  var BUSINESS_VAT = "You have updated your VAT registration number";
64
+ var BUSINESS_VAT_REMOVE = "You have removed your VAT registration number";
64
65
 
65
66
  // src/constants/interrupter-journey.js
66
67
  var PERSONAL_SECTION_FIELD_ORDER = {
@@ -108,6 +109,79 @@ var BUSINESS_UPDATE_TEXT_LABELS = {
108
109
  vat: "your business VAT number"
109
110
  };
110
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
+
111
185
  // src/constants/index.js
112
186
  var constants = {
113
187
  statusCodes: {
@@ -145,7 +219,8 @@ var constants = {
145
219
  BUSINESS_EMAIL_ADDRESS,
146
220
  BUSINESS_NAME,
147
221
  BUSINESS_PHONE_NUMBERS,
148
- BUSINESS_VAT
222
+ BUSINESS_VAT,
223
+ BUSINESS_VAT_REMOVE
149
224
  },
150
225
  interrupterJourney: {
151
226
  PERSONAL_SECTION_FIELD_ORDER,
@@ -156,6 +231,12 @@ var constants = {
156
231
  BUSINESS_SECTION_LABELS,
157
232
  PERSONAL_UPDATE_TEXT_LABELS,
158
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
159
240
  }
160
241
  };
161
242
 
@@ -213,7 +294,7 @@ var mapCustomerName = (name = {}) => {
213
294
  // src/mappers/business-details-mapper.js
214
295
  var asNullable = (value) => value ?? null;
215
296
  var mapBusinessInfo = (business) => {
216
- var _a, _b;
297
+ var _a, _b, _c;
217
298
  const info = business.info ?? {};
218
299
  return {
219
300
  sbi: business.sbi,
@@ -222,7 +303,8 @@ var mapBusinessInfo = (business) => {
222
303
  traderNumber: asNullable(info.traderNumber),
223
304
  vendorNumber: asNullable(info.vendorNumber),
224
305
  legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
225
- 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),
226
308
  countyParishHoldingNumbers: business.countyParishHoldings ?? []
227
309
  };
228
310
  };
@@ -377,6 +459,37 @@ var businessVatRemoveSchema = Joi.object({
377
459
  })
378
460
  });
379
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
+
380
493
  // src/schemas/business/business-schemas.js
381
494
  var businessSchemas = {
382
495
  sbi: businessSbiSchema,
@@ -390,6 +503,11 @@ var businessSchemas = {
390
503
  vat: {
391
504
  change: businessVatChangeSchema,
392
505
  remove: businessVatRemoveSchema
506
+ },
507
+ legalStatus: businessLegalStatusSchema,
508
+ legalStatusRegistration: {
509
+ charity: businessCharityRegistrationNumberSchema,
510
+ company: businessCompanyRegistrationNumberSchema
393
511
  }
394
512
  };
395
513
 
@@ -940,6 +1058,40 @@ var updateCustomerDetailsMutation = `
940
1058
  }
941
1059
  `;
942
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
+
943
1095
  // src/mutations/mutations.js
944
1096
  var mutations = {
945
1097
  updateBusinessEmail: updateBusinessEmailMutation,
@@ -952,7 +1104,9 @@ var mutations = {
952
1104
  updateCustomerEmail: updateCustomerEmailMutation,
953
1105
  updateCustomerAddress: updateCustomerAddressMutation,
954
1106
  updateBusinessVat: updateBusinessVatMutation,
955
- updateCustomerDetails: updateCustomerDetailsMutation
1107
+ updateCustomerDetails: updateCustomerDetailsMutation,
1108
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1109
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
956
1110
  };
957
1111
 
958
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.25.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
+ ]
@@ -37,7 +37,8 @@ import {
37
37
  BUSINESS_EMAIL_ADDRESS,
38
38
  BUSINESS_NAME,
39
39
  BUSINESS_PHONE_NUMBERS,
40
- BUSINESS_VAT
40
+ BUSINESS_VAT,
41
+ BUSINESS_VAT_REMOVE
41
42
  } from './success-messages.js'
42
43
 
43
44
  // Interrupter journey constants
@@ -52,6 +53,13 @@ import {
52
53
  BUSINESS_UPDATE_TEXT_LABELS
53
54
  } from './interrupter-journey.js'
54
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
+
55
63
  export const constants = {
56
64
  statusCodes: {
57
65
  BAD_REQUEST,
@@ -88,7 +96,8 @@ export const constants = {
88
96
  BUSINESS_EMAIL_ADDRESS,
89
97
  BUSINESS_NAME,
90
98
  BUSINESS_PHONE_NUMBERS,
91
- BUSINESS_VAT
99
+ BUSINESS_VAT,
100
+ BUSINESS_VAT_REMOVE
92
101
  },
93
102
  interrupterJourney: {
94
103
  PERSONAL_SECTION_FIELD_ORDER,
@@ -99,5 +108,11 @@ export const constants = {
99
108
  BUSINESS_SECTION_LABELS,
100
109
  PERSONAL_UPDATE_TEXT_LABELS,
101
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
102
117
  }
103
118
  }
@@ -2,3 +2,4 @@ export const BUSINESS_EMAIL_ADDRESS = 'You have updated your business email addr
2
2
  export const BUSINESS_NAME = 'You have updated your business name'
3
3
  export const BUSINESS_PHONE_NUMBERS = 'You have updated your business phone numbers'
4
4
  export const BUSINESS_VAT = 'You have updated your VAT registration number'
5
+ export const BUSINESS_VAT_REMOVE = 'You have removed your VAT registration number'
@@ -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
  }