@defra/fcp-sfd-frontend-engine 0.26.0 → 0.28.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 +160 -3
- package/dist/index.js +160 -3
- package/package.json +1 -1
- package/src/constants/business-legal-status.js +77 -0
- package/src/constants/index.js +13 -0
- package/src/mappers/business-details-mapper.js +6 -0
- package/src/mutations/business/update-business-legal-status.js +15 -0
- package/src/mutations/business/update-business-registration-numbers.js +15 -0
- package/src/mutations/mutations.js +5 -1
- package/src/schemas/business/business-charity-registration-number-schema.js +15 -0
- package/src/schemas/business/business-company-registration-number-schema.js +15 -0
- package/src/schemas/business/business-legal-status-schema.js +16 -0
- package/src/schemas/business/business-schemas.js +8 -0
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,8 +335,9 @@ 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 ?? {};
|
|
340
|
+
const registrationNumbers = info.registrationNumbers ?? {};
|
|
261
341
|
return {
|
|
262
342
|
sbi: business.sbi,
|
|
263
343
|
businessName: asNullable(info.name),
|
|
@@ -265,7 +345,12 @@ var mapBusinessInfo = (business) => {
|
|
|
265
345
|
traderNumber: asNullable(info.traderNumber),
|
|
266
346
|
vendorNumber: asNullable(info.vendorNumber),
|
|
267
347
|
legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
|
|
268
|
-
|
|
348
|
+
legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
|
|
349
|
+
registrationNumbers: {
|
|
350
|
+
companiesHouse: asNullable(registrationNumbers.companiesHouse),
|
|
351
|
+
charityCommission: asNullable(registrationNumbers.charityCommission)
|
|
352
|
+
},
|
|
353
|
+
type: asNullable((_c = info.type) == null ? void 0 : _c.type),
|
|
269
354
|
countyParishHoldingNumbers: business.countyParishHoldings ?? []
|
|
270
355
|
};
|
|
271
356
|
};
|
|
@@ -420,6 +505,37 @@ var businessVatRemoveSchema = Joi.object({
|
|
|
420
505
|
})
|
|
421
506
|
});
|
|
422
507
|
|
|
508
|
+
// src/schemas/business/business-legal-status-schema.js
|
|
509
|
+
var ERROR_MESSAGE = "Select a legal status";
|
|
510
|
+
var businessLegalStatusSchema = Joi.object({
|
|
511
|
+
// Restricting to our own known codes means an invalid/tampered value is treated the same as no selection
|
|
512
|
+
businessLegalStatus: Joi.string().valid(...BUSINESS_LEGAL_STATUS_CODES).required().messages({
|
|
513
|
+
"string.empty": ERROR_MESSAGE,
|
|
514
|
+
"any.required": ERROR_MESSAGE,
|
|
515
|
+
"any.only": ERROR_MESSAGE
|
|
516
|
+
})
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
// src/schemas/business/business-charity-registration-number-schema.js
|
|
520
|
+
var businessCharityRegistrationNumberSchema = Joi.object({
|
|
521
|
+
charityCommissionRegistrationNumber: Joi.string().trim().required().pattern(/^\d{7,8}$/).messages({
|
|
522
|
+
"string.empty": "Enter the charity commission registration number",
|
|
523
|
+
"any.required": "Enter the charity commission registration number",
|
|
524
|
+
"string.pattern.base": "Charity commission registration number must be 7 or 8 numbers",
|
|
525
|
+
"string.noControlChars": "Charity commission registration number must only include numbers"
|
|
526
|
+
})
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
// src/schemas/business/business-company-registration-number-schema.js
|
|
530
|
+
var businessCompanyRegistrationNumberSchema = Joi.object({
|
|
531
|
+
companyRegistrationNumber: Joi.string().trim().required().pattern(/^(\d{8}|[A-Za-z]{2}\d{6})$/).messages({
|
|
532
|
+
"string.empty": "Enter the company registration number",
|
|
533
|
+
"any.required": "Enter the company registration number",
|
|
534
|
+
"string.pattern.base": "Company registration number must be 8 numbers, or 2 letters followed by 6 numbers",
|
|
535
|
+
"string.noControlChars": "Company registration number must only include letters and numbers"
|
|
536
|
+
})
|
|
537
|
+
});
|
|
538
|
+
|
|
423
539
|
// src/schemas/business/business-schemas.js
|
|
424
540
|
var businessSchemas = {
|
|
425
541
|
sbi: businessSbiSchema,
|
|
@@ -433,6 +549,11 @@ var businessSchemas = {
|
|
|
433
549
|
vat: {
|
|
434
550
|
change: businessVatChangeSchema,
|
|
435
551
|
remove: businessVatRemoveSchema
|
|
552
|
+
},
|
|
553
|
+
legalStatus: businessLegalStatusSchema,
|
|
554
|
+
legalStatusRegistration: {
|
|
555
|
+
charity: businessCharityRegistrationNumberSchema,
|
|
556
|
+
company: businessCompanyRegistrationNumberSchema
|
|
436
557
|
}
|
|
437
558
|
};
|
|
438
559
|
|
|
@@ -983,6 +1104,40 @@ var updateCustomerDetailsMutation = `
|
|
|
983
1104
|
}
|
|
984
1105
|
`;
|
|
985
1106
|
|
|
1107
|
+
// src/mutations/business/update-business-legal-status.js
|
|
1108
|
+
var updateBusinessLegalStatusMutation = `
|
|
1109
|
+
mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
|
|
1110
|
+
updateBusinessLegalStatus(input: $input) {
|
|
1111
|
+
business {
|
|
1112
|
+
info {
|
|
1113
|
+
legalStatus {
|
|
1114
|
+
code
|
|
1115
|
+
type
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
success
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
`;
|
|
1123
|
+
|
|
1124
|
+
// src/mutations/business/update-business-registration-numbers.js
|
|
1125
|
+
var updateBusinessRegistrationNumbersMutation = `
|
|
1126
|
+
mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
|
|
1127
|
+
updateBusinessRegistrationNumbers(input: $input) {
|
|
1128
|
+
business {
|
|
1129
|
+
info {
|
|
1130
|
+
registrationNumbers {
|
|
1131
|
+
companiesHouse
|
|
1132
|
+
charityCommission
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
success
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
`;
|
|
1140
|
+
|
|
986
1141
|
// src/mutations/mutations.js
|
|
987
1142
|
var mutations = {
|
|
988
1143
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
@@ -995,7 +1150,9 @@ var mutations = {
|
|
|
995
1150
|
updateCustomerEmail: updateCustomerEmailMutation,
|
|
996
1151
|
updateCustomerAddress: updateCustomerAddressMutation,
|
|
997
1152
|
updateBusinessVat: updateBusinessVatMutation,
|
|
998
|
-
updateCustomerDetails: updateCustomerDetailsMutation
|
|
1153
|
+
updateCustomerDetails: updateCustomerDetailsMutation,
|
|
1154
|
+
updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
|
|
1155
|
+
updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
|
|
999
1156
|
};
|
|
1000
1157
|
|
|
1001
1158
|
// 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,8 +294,9 @@ 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 ?? {};
|
|
299
|
+
const registrationNumbers = info.registrationNumbers ?? {};
|
|
220
300
|
return {
|
|
221
301
|
sbi: business.sbi,
|
|
222
302
|
businessName: asNullable(info.name),
|
|
@@ -224,7 +304,12 @@ var mapBusinessInfo = (business) => {
|
|
|
224
304
|
traderNumber: asNullable(info.traderNumber),
|
|
225
305
|
vendorNumber: asNullable(info.vendorNumber),
|
|
226
306
|
legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
|
|
227
|
-
|
|
307
|
+
legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
|
|
308
|
+
registrationNumbers: {
|
|
309
|
+
companiesHouse: asNullable(registrationNumbers.companiesHouse),
|
|
310
|
+
charityCommission: asNullable(registrationNumbers.charityCommission)
|
|
311
|
+
},
|
|
312
|
+
type: asNullable((_c = info.type) == null ? void 0 : _c.type),
|
|
228
313
|
countyParishHoldingNumbers: business.countyParishHoldings ?? []
|
|
229
314
|
};
|
|
230
315
|
};
|
|
@@ -379,6 +464,37 @@ var businessVatRemoveSchema = Joi.object({
|
|
|
379
464
|
})
|
|
380
465
|
});
|
|
381
466
|
|
|
467
|
+
// src/schemas/business/business-legal-status-schema.js
|
|
468
|
+
var ERROR_MESSAGE = "Select a legal status";
|
|
469
|
+
var businessLegalStatusSchema = Joi.object({
|
|
470
|
+
// Restricting to our own known codes means an invalid/tampered value is treated the same as no selection
|
|
471
|
+
businessLegalStatus: Joi.string().valid(...BUSINESS_LEGAL_STATUS_CODES).required().messages({
|
|
472
|
+
"string.empty": ERROR_MESSAGE,
|
|
473
|
+
"any.required": ERROR_MESSAGE,
|
|
474
|
+
"any.only": ERROR_MESSAGE
|
|
475
|
+
})
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// src/schemas/business/business-charity-registration-number-schema.js
|
|
479
|
+
var businessCharityRegistrationNumberSchema = Joi.object({
|
|
480
|
+
charityCommissionRegistrationNumber: Joi.string().trim().required().pattern(/^\d{7,8}$/).messages({
|
|
481
|
+
"string.empty": "Enter the charity commission registration number",
|
|
482
|
+
"any.required": "Enter the charity commission registration number",
|
|
483
|
+
"string.pattern.base": "Charity commission registration number must be 7 or 8 numbers",
|
|
484
|
+
"string.noControlChars": "Charity commission registration number must only include numbers"
|
|
485
|
+
})
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// src/schemas/business/business-company-registration-number-schema.js
|
|
489
|
+
var businessCompanyRegistrationNumberSchema = Joi.object({
|
|
490
|
+
companyRegistrationNumber: Joi.string().trim().required().pattern(/^(\d{8}|[A-Za-z]{2}\d{6})$/).messages({
|
|
491
|
+
"string.empty": "Enter the company registration number",
|
|
492
|
+
"any.required": "Enter the company registration number",
|
|
493
|
+
"string.pattern.base": "Company registration number must be 8 numbers, or 2 letters followed by 6 numbers",
|
|
494
|
+
"string.noControlChars": "Company registration number must only include letters and numbers"
|
|
495
|
+
})
|
|
496
|
+
});
|
|
497
|
+
|
|
382
498
|
// src/schemas/business/business-schemas.js
|
|
383
499
|
var businessSchemas = {
|
|
384
500
|
sbi: businessSbiSchema,
|
|
@@ -392,6 +508,11 @@ var businessSchemas = {
|
|
|
392
508
|
vat: {
|
|
393
509
|
change: businessVatChangeSchema,
|
|
394
510
|
remove: businessVatRemoveSchema
|
|
511
|
+
},
|
|
512
|
+
legalStatus: businessLegalStatusSchema,
|
|
513
|
+
legalStatusRegistration: {
|
|
514
|
+
charity: businessCharityRegistrationNumberSchema,
|
|
515
|
+
company: businessCompanyRegistrationNumberSchema
|
|
395
516
|
}
|
|
396
517
|
};
|
|
397
518
|
|
|
@@ -942,6 +1063,40 @@ var updateCustomerDetailsMutation = `
|
|
|
942
1063
|
}
|
|
943
1064
|
`;
|
|
944
1065
|
|
|
1066
|
+
// src/mutations/business/update-business-legal-status.js
|
|
1067
|
+
var updateBusinessLegalStatusMutation = `
|
|
1068
|
+
mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
|
|
1069
|
+
updateBusinessLegalStatus(input: $input) {
|
|
1070
|
+
business {
|
|
1071
|
+
info {
|
|
1072
|
+
legalStatus {
|
|
1073
|
+
code
|
|
1074
|
+
type
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
success
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
`;
|
|
1082
|
+
|
|
1083
|
+
// src/mutations/business/update-business-registration-numbers.js
|
|
1084
|
+
var updateBusinessRegistrationNumbersMutation = `
|
|
1085
|
+
mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
|
|
1086
|
+
updateBusinessRegistrationNumbers(input: $input) {
|
|
1087
|
+
business {
|
|
1088
|
+
info {
|
|
1089
|
+
registrationNumbers {
|
|
1090
|
+
companiesHouse
|
|
1091
|
+
charityCommission
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
success
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
`;
|
|
1099
|
+
|
|
945
1100
|
// src/mutations/mutations.js
|
|
946
1101
|
var mutations = {
|
|
947
1102
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
@@ -954,7 +1109,9 @@ var mutations = {
|
|
|
954
1109
|
updateCustomerEmail: updateCustomerEmailMutation,
|
|
955
1110
|
updateCustomerAddress: updateCustomerAddressMutation,
|
|
956
1111
|
updateBusinessVat: updateBusinessVatMutation,
|
|
957
|
-
updateCustomerDetails: updateCustomerDetailsMutation
|
|
1112
|
+
updateCustomerDetails: updateCustomerDetailsMutation,
|
|
1113
|
+
updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
|
|
1114
|
+
updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
|
|
958
1115
|
};
|
|
959
1116
|
|
|
960
1117
|
// src/presenters/base-presenter.js
|
package/package.json
CHANGED
|
@@ -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
|
+
]
|
package/src/constants/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -15,6 +15,7 @@ const asNullable = (value) => value ?? null
|
|
|
15
15
|
|
|
16
16
|
const mapBusinessInfo = (business) => {
|
|
17
17
|
const info = business.info ?? {}
|
|
18
|
+
const registrationNumbers = info.registrationNumbers ?? {}
|
|
18
19
|
|
|
19
20
|
return {
|
|
20
21
|
sbi: business.sbi,
|
|
@@ -23,6 +24,11 @@ const mapBusinessInfo = (business) => {
|
|
|
23
24
|
traderNumber: asNullable(info.traderNumber),
|
|
24
25
|
vendorNumber: asNullable(info.vendorNumber),
|
|
25
26
|
legalStatus: asNullable(info.legalStatus?.type),
|
|
27
|
+
legalStatusCode: asNullable(info.legalStatus?.code),
|
|
28
|
+
registrationNumbers: {
|
|
29
|
+
companiesHouse: asNullable(registrationNumbers.companiesHouse),
|
|
30
|
+
charityCommission: asNullable(registrationNumbers.charityCommission)
|
|
31
|
+
},
|
|
26
32
|
type: asNullable(info.type?.type),
|
|
27
33
|
countyParishHoldingNumbers: business.countyParishHoldings ?? []
|
|
28
34
|
}
|
|
@@ -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
|
}
|