Skip to content

Commit

Permalink
Fix post double call to intersolve visa and refactor input validator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben authored and diderikvw committed Feb 20, 2025
1 parent 13fc275 commit f6b69b9
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,14 @@ export class RegistrationsService {
});
}

if (process.env.SYNC_WITH_THIRD_PARTIES) {
const intersolveVisaAttributeNames =
getFinancialServiceProviderSettingByNameOrThrow(
FinancialServiceProviders.intersolveVisa,
).attributes.map((attr) => attr.name) as string[];
if (
process.env.SYNC_WITH_THIRD_PARTIES &&
intersolveVisaAttributeNames.includes(attribute)
) {
await this.sendContactInformationToIntersolve(registration);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,30 @@ describe('RegistrationsInputValidator', () => {

expect(result[0]).toEqual(expected);
});

it('should only return the value you try to validate', async () => {
const fullName = 'testName';
const csvArray = [
{
fullName,
},
];
const result = await validator.validateAndCleanInput({
registrationInputArray: csvArray,
programId,
userId,
typeOfInput: RegistrationValidationInputType.update,
validationConfig: {
validatePhoneNumberLookup: true,
validateUniqueReferenceId: true,
validateExistingReferenceId: true,
},
});
const expectedResult = {
data: {
fullName,
},
};
expect(result[0]).toEqual(expectedResult);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,24 @@ export class RegistrationsInputValidator {
* Add default registration attributes without custom validation
* =============================================================
*/
const {
errorOjb: errorObjPaymentAmountMultiplier,
validatedPaymentAmountMultiplier,
} = this.validatePaymentAmountMultiplier({
value: row.paymentAmountMultiplier,
programPaymentAmountMultiplierFormula:
program.paymentAmountMultiplierFormula,
i,
});
if (errorObjPaymentAmountMultiplier) {
errors.push(errorObjPaymentAmountMultiplier);
} else {
validatedRegistrationInput.paymentAmountMultiplier =
validatedPaymentAmountMultiplier;
if (row[AdditionalAttributes.paymentAmountMultiplier] !== undefined) {
const {
errorOjb: errorObjPaymentAmountMultiplier,
validatedPaymentAmountMultiplier,
} = this.validatePaymentAmountMultiplier({
value: row.paymentAmountMultiplier,
programPaymentAmountMultiplierFormula:
program.paymentAmountMultiplierFormula,
i,
});
if (errorObjPaymentAmountMultiplier) {
errors.push(errorObjPaymentAmountMultiplier);
} else {
validatedRegistrationInput.paymentAmountMultiplier =
validatedPaymentAmountMultiplier;
}
}

if (program.enableMaxPayments && row.maxPayments !== undefined) {
const { errorObj: errorObjMaxPayments, validatedMaxPayments } =
this.validateMaxPayments({
Expand All @@ -140,19 +143,21 @@ export class RegistrationsInputValidator {
* Validate default registration properties
* ========================================
*/
const errorObjScope = this.validateRowScope({
row,
userScope,
i,
typeOfInput,
});
if (errorObjScope) {
errors.push(errorObjScope);
} else if (program.enableScope) {
// We know that scope is undefined or string, or an error would have occured
validatedRegistrationInput.scope = row[AdditionalAttributes.scope] as
| undefined
| string;
if (row[AdditionalAttributes.scope] !== undefined) {
const errorObjScope = this.validateRowScope({
row,
userScope,
i,
typeOfInput,
});
if (errorObjScope) {
errors.push(errorObjScope);
} else if (program.enableScope) {
// We know that scope is undefined or string, or an error would have occured
validatedRegistrationInput.scope = row[AdditionalAttributes.scope] as
| undefined
| string;
}
}

const {
Expand Down

0 comments on commit f6b69b9

Please sign in to comment.