diff --git a/src/Schemas/getRepBody.ts b/src/Schemas/getRepBody.ts index deadbe2ba3bb2a80f9aa1925f2855debf7578afd..a6ce5f1c4fcdb8559e07bd4e015d7d33265a28b0 100644 --- a/src/Schemas/getRepBody.ts +++ b/src/Schemas/getRepBody.ts @@ -130,27 +130,7 @@ const getRepBody = { type: 'number' as const, minimum: 0, }, - countryBirthRate: { - type: 'number' as const, - minimum: 0, - }, - countryWomenInAgeGroup: { - type: 'number' as const, - exclusiveMinimum: 0, - }, - countryPopulation: { - type: 'number' as const, - exclusiveMinimum: 0, - }, }, - oneOf: [ - { - required: ['pregnantWomen', 'lactatingWomen'], - }, - { - required: ['countryBirthRate', 'countryWomenInAgeGroup', 'countryPopulation'], - }, - ], }, }, }, diff --git a/src/Services/ERCalculator.ts b/src/Services/ERCalculator.ts index 868c353c7b03dc3fcf627d83a4e8c415a255aa7e..f0dd0992dfc3d6ac6f4cd199d5a7858728fbab9d 100644 --- a/src/Services/ERCalculator.ts +++ b/src/Services/ERCalculator.ts @@ -196,13 +196,11 @@ const calculate30To59Years = (group: AgeGroup, params: number[], data: ExtraData // If the group's sex is Female, then you have to take into account // the extra energy required by women that are pregnant or lactating - if (group.sex === Sex.Female) { - if (typeof (data.maternity30To59) === 'undefined') { - throw new Error('Missing maternity data for women aged 30 to 59'); - } else if (isIndividualMaternity(data.maternity30To59)) { + if (group.sex === Sex.Female && data.maternity30To59 !== undefined) { + if (isIndividualMaternity(data.maternity30To59)) { requirement = calculateERWomenIndividual(group, params, data.maternity30To59, requirement); } else { - requirement = calculateERWomenPopulation(params, data.maternity30To59, requirement); + throw new Error('Invalid maternity data for 30 to 59 years old women group'); } }