diff --git a/src/bootstrap.js b/src/bootstrap.js index ab512e6..33446d1 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -18,7 +18,7 @@ Joi.title = () => Joi.string().max(128) Joi.paymentStatus = () => Joi.string().valid('pending', 'partially-completed', 'completed', 'cancelled') Joi.xaiTemplate = () => Joi.string().valid(...allowedXAITemplates) Joi.interviewStatus = () => Joi.string().valid(...allowedInterviewStatuses) -Joi.workPeriodPaymentStatus = () => Joi.string().valid('completed', 'scheduled', 'cancelled') +Joi.workPeriodPaymentStatus = () => Joi.string().valid('completed', 'scheduled', 'in-progress', 'failed', 'cancelled') // Empty string is not allowed by Joi by default and must be enabled with allow(''). // See https://joi.dev/api/?v=17.3.0#string fro details why it's like this. // In many cases we would like to allow empty string to make it easier to create UI for editing data. diff --git a/src/scripts/createIndex.js b/src/scripts/createIndex.js index c643a42..8051f5d 100644 --- a/src/scripts/createIndex.js +++ b/src/scripts/createIndex.js @@ -130,6 +130,16 @@ async function createIndex () { challengeId: { type: 'keyword' }, amount: { type: 'float' }, status: { type: 'keyword' }, + statusDetails: { + type: 'nested', + properties: { + errorMessage: { type: 'text' }, + errorCode: { type: 'integer' }, + retry: { type: 'integer' }, + step: { type: 'keyword' }, + challengeId: { type: 'keyword' } + } + }, billingAccountId: { type: 'integer' }, createdAt: { type: 'date' }, createdBy: { type: 'keyword' }, diff --git a/src/services/WorkPeriodPaymentProcessorService.js b/src/services/WorkPeriodPaymentProcessorService.js index 736cacb..a168ded 100644 --- a/src/services/WorkPeriodPaymentProcessorService.js +++ b/src/services/WorkPeriodPaymentProcessorService.js @@ -69,6 +69,13 @@ processCreate.schema = { amount: Joi.number().greater(0).allow(null), status: Joi.workPeriodPaymentStatus().required(), billingAccountId: Joi.number().allow(null), + statusDetails: Joi.object().keys({ + errorMessage: Joi.string().required(), + errorCode: Joi.number().integer().allow(null), + retry: Joi.number().integer().allow(null), + step: Joi.string().allow(null), + challengeId: Joi.string().uuid().allow(null) + }).unknown(true).allow(null), createdAt: Joi.date().required(), createdBy: Joi.string().uuid().required(), updatedAt: Joi.date().allow(null), diff --git a/test/common/testHelper.js b/test/common/testHelper.js index fd310d8..6410492 100644 --- a/test/common/testHelper.js +++ b/test/common/testHelper.js @@ -40,7 +40,8 @@ async function clearES () { query: { match_all: {} } - } + }, + refresh: true }) } }