Skip to content

Commit

Permalink
fix: rm lingering cases of program-question/custom-attribute/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jannisvisser committed Nov 6, 2024
1 parent 09249e1 commit 291d054
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 1,119 deletions.
1,037 changes: 36 additions & 1,001 deletions e2e/test-registration-data/test-registrations-westeros-1000.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion features/121-Portal/Export_Payment_Details.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Feature: Export payment data
And it shows a list of the registrations that have been paid out
And - if program and user have scope - then it shows only the PAs within the scope of the user
And "transaction" data: "payment", "timestamp", "amount" (multiplication of "paymentAmountMultiplier" and "transfer value"), "status", "errorMessage", "financialServiceProvider"
And "registration" data: "referenceId", "phoneNumber" and any defined program-questions, fsp-questions and program-custom-attributes that have "payment" as part of the "export" attribute
And "registration" data: "referenceId", "phoneNumber" and any defined registration attributes that have "payment" as part of the "export" attribute

Scenario: Viewing the export options without permission
Given a logged-in user without "RegistrationPersonalEXPORT", "PaymentREAD" and "PaymentTransactionREAD" permissions
Expand Down
6 changes: 2 additions & 4 deletions features/121-Portal/Import_registrations.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Feature: Import registrations with status registered
Then a CSV-file is downloaded
And it contains 1 row of column names
And it contains the generic column names "phoneNumber", "preferredLanguage", "fspName", "paymentAmountMultiplier"
And it has dynamic "programCustomAttributes" of that program
And it has the dynamic columns for programQuestions of that program
And it has the dynamic columns for "programRegistrationAttributes" of that program

When the program is not configured with a paymentAmountMultiplierFormula
Then it contains the column "paymentAmountMultiplier" after the "fspQuestions"
Expand All @@ -24,8 +23,7 @@ Feature: Import registrations with status registered
Given a valid import CSV file is prepared based on the template
Given - if program and user have a scope - the file only contains records within the scope of the user
And it has generic columns "preferredLanguage", "phoneNumber", "fspName"
And it has the dynamic columns for programQuestions of that program
And it has the dynamic "programCustomAttributes" of that program
And it has the dynamic columns for "programRegistrationAttributes" of that program
And it has as delimiter ";" or ","
And it has "X" rows
And the input of each cell is valid
Expand Down

This file was deleted.

20 changes: 0 additions & 20 deletions features/Admin-user/Update_program_question.feature

This file was deleted.

20 changes: 20 additions & 0 deletions features/Admin-user/Update_program_registration_attribute.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@swagger-ui
Feature: Update Program registration attribute

Background:
Given a logged-in "admin" user in the Swagger UI

Scenario: Successfully update properties of program registration attribute
Given the "programId" is provided
Given the required property "attributeName" is provided and is existing in the database
Given 0 or more other attributes are provided
When the user fills in the body properties
And calls the "PATCH /programs/{programId}/registration-attributes/${attributeName}" endpoint
Then only the provided properties of the existing "program registration attribute" are updated
And the whole "program registration attribute" object is returned

Scenario: Unsuccessfully update unknown program registration attribute
Given the required property "attributeName" is provided and is not existing in the database
When the user fills in the body properties
And calls the "PATCH /programs/{programId}/registration-attributes/${attributeName}" endpoint
Then a 404 response is returned with a message that the "program registration attribute" is not found
3 changes: 1 addition & 2 deletions features/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ Using application such as EspoCRM to call our API
#### Using Swagger UI

- [Manage user roles](Admin-user/Manage_Roles.feature)
- [Add and Update program custom attribute](Admin-user/Add_And_Update_program_custom_attribute.feature)
- [Update program question](Admin-user/Update_program_question.feature)
- [Update program registration attribute](Admin-user/Update_program_registration_attribute.feature)
- [Update program](Admin-user/Update_program.feature)
- [Export Intersolve vouchers to cancel](Admin-user/Export_vouchers_to_cancel.feature)
- [Sync Intersolve Visa Customer](Admin-user/Sync_Intersolve_Visa_Customer.feature)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ export class RegistrationActivityOverviewComponent implements OnInit {
if (attribute?.type === RegistrationAttributeType.Boolean) {
const booleanLabel = {
true: this.translate.instant(
'page.program.program-people-affected.column.custom-attribute-true',
'page.program.program-people-affected.column.registration-attribute-true',
),
false: this.translate.instant(
'page.program.program-people-affected.column.custom-attribute-false',
'page.program.program-people-affected.column.registration-attribute-false',
),
};
oldValue = booleanLabel[oldValue];
Expand Down
11 changes: 0 additions & 11 deletions interfaces/Portal/src/app/mocks/api.programs.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ const programsArray: Program[] = [
author: {},
published: true,
notifications: { en: 'Notification text' },
programCustomAttributes: [
{
id: 1,
name: 'namePartnerOrganization',
type: 'string',
programId: 1,
label: {
en: 'Partner Organization',
},
},
],
programRegistrationAttributes: [
{
id: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@
<span
[title]="
value
? ('page.program.program-people-affected.column.custom-attribute-true'
? ('page.program.program-people-affected.column.registration-attribute-true'
| translate)
: ('page.program.program-people-affected.column.custom-attribute-false'
: ('page.program.program-people-affected.column.registration-attribute-false'
| translate)
"
>
Expand Down
4 changes: 2 additions & 2 deletions interfaces/Portal/src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@
},
"choose-action": "اختر الإجراء...",
"column": {
"custom-attribute-false": "لا",
"custom-attribute-true": "نعم",
"dob": "تاريخ الميلاد",
"failedPayment": "فشل الدفع #",
"hasNote": "لديه ملاحظة",
Expand All @@ -381,6 +379,8 @@
"preferredLanguage": "اللغة المفضلة",
"programFinancialServiceProviderConfigurationLabel": "مزود الخدمات المالية",
"referenceId": "الرقم المرجعي",
"registration-attribute-false": "لا",
"registration-attribute-true": "نعم",
"registrationCreated": "تم إنشاء التسجيل",
"registrationCreatedDate": "تاريخ إنشاء التسجيل",
"select": "اختار",
Expand Down
4 changes: 2 additions & 2 deletions interfaces/Portal/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,6 @@
},
"choose-action": "Choose action...",
"column": {
"custom-attribute-false": "No",
"custom-attribute-true": "Yes",
"dob": "Date of birth",
"failedPayment": "Failed for payment #",
"financialServiceProvider": "Financial Service Provider",
Expand All @@ -361,6 +359,8 @@
"preferredLanguage": "Preferred language",
"programFinancialServiceProviderConfigurationLabel": "Financial Service Provider",
"referenceId": "Reference ID",
"registration-attribute-false": "No",
"registration-attribute-true": "Yes",
"registrationCreated": "Registration created",
"registrationCreatedDate": "Registration created date",
"select": "Select",
Expand Down
4 changes: 2 additions & 2 deletions interfaces/Portal/src/assets/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@
},
"choose-action": "Elige acción...",
"column": {
"custom-attribute-false": "No",
"custom-attribute-true": "",
"dob": "Fecha de nacimiento",
"failedPayment": "Error en el pago #",
"hasNote": "Tiene nota",
Expand All @@ -381,6 +379,8 @@
"preferredLanguage": "Idioma preferido",
"programFinancialServiceProviderConfigurationLabel": "Proveedor de servicios financieros",
"referenceId": "ID de referencia",
"registration-attribute-false": "No",
"registration-attribute-true": "",
"registrationCreated": "Registro creado",
"registrationCreatedDate": "Fecha de creación de la inscripción",
"select": "Escoger",
Expand Down
4 changes: 2 additions & 2 deletions interfaces/Portal/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,6 @@
},
"choose-action": "Sélectionner une action...",
"column": {
"custom-attribute-false": "Non",
"custom-attribute-true": "Oui",
"dob": "Date de naissance",
"failedPayment": "Échec du paiement #",
"financialServiceProvider": "Prestataire de Services Financiers",
Expand All @@ -392,6 +390,8 @@
"preferredLanguage": "Langue préférée",
"programFinancialServiceProviderConfigurationLabel": "Prestataire de Services Financiers",
"referenceId": "Identifiant de référence",
"registration-attribute-false": "Non",
"registration-attribute-true": "Oui",
"registrationCreated": "Création d’un enregistrement",
"registrationCreatedDate": "Date de création de l'enregistrement",
"select": "Sélectionner",
Expand Down
4 changes: 2 additions & 2 deletions interfaces/Portal/src/assets/i18n/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,6 @@
},
"choose-action": "Kies actie...",
"column": {
"custom-attribute-false": "Nee",
"custom-attribute-true": "Ja",
"dob": "Geboortedatum",
"failedPayment": "Mislukt bij betaling #",
"financialServiceProvider": "Type hulp",
Expand All @@ -396,6 +394,8 @@
"preferredLanguage": "Voorkeurstaal",
"programFinancialServiceProviderConfigurationLabel": "Type hulp",
"referenceId": "Referentie nummer",
"registration-attribute-false": "Nee",
"registration-attribute-true": "Ja",
"registrationCreated": "Aanmaakdatum",
"registrationCreatedDate": "Aanmaakdatum registratie",
"select": "Selecteer",
Expand Down
3 changes: 2 additions & 1 deletion services/121-service/src/programs/dto/create-program.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ export class CreateProgramDto {

@ApiProperty({
example: ['nameFirst', 'nameLast'],
description: 'Should be array of name-related program-questions.',
description:
'Should be array of name-related program-registration-attributes.',
})
@IsArray()
public readonly fullnameNamingConvention: string[];
Expand Down
3 changes: 2 additions & 1 deletion services/121-service/src/programs/dto/program-return.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ export class ProgramReturnDto {

@ApiProperty({
example: ['nameFirst', 'nameLast'],
description: 'Should be array of name-related program-questions.',
description:
'Should be array of name-related program-registration-attributes.',
})
@IsArray()
@IsOptional()
Expand Down
2 changes: 1 addition & 1 deletion services/121-service/src/programs/program.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class ProgramEntity extends CascadeDeleteEntity {
public tryWhatsAppFirst: boolean;

// TODO: This can be refactored into 'nameField' so that this can be 1 field name that maps to the 'Name' column in the Portal.
// This is an array of ProgramQuestionEntity names that build up the full name of a PA.
// This is an array of ProgramRegistrationAttributeEntity names that build up the full name of a PA.
@Column('json', { nullable: true })
public fullnameNamingConvention: string[] | null;

Expand Down
8 changes: 6 additions & 2 deletions services/121-service/src/programs/programs.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,15 @@ You can also leave the body empty.`,
description: 'Return program registration attribute',
type: ProgramRegistrationAttributeEntity,
})
@ApiResponse({
status: HttpStatus.NOT_FOUND,
description: 'Providede program registration attribute name not found',
})
@ApiParam({ name: 'programId', required: true, type: 'integer' })
@ApiParam({
name: 'programRegistrationAttributeId',
name: 'programRegistrationAttributeName',
required: true,
type: 'integer',
type: 'string',
})
@Patch(':programId/registration-attributes/:programRegistrationAttributeName')
public async updateProgramRegistrationAttribute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ export class RegistrationDataService {
.andWhere('programRegistrationAttributes.name = :name', { name })
.select('"programRegistrationAttributes".id', 'id');

const resultProgramQuestion = await query.getRawOne();
const resultProgramRegistrationAttribute = await query.getRawOne();

if (resultProgramQuestion) {
result.programRegistrationAttributeId = resultProgramQuestion.id;
if (resultProgramRegistrationAttribute) {
result.programRegistrationAttributeId =
resultProgramRegistrationAttribute.id;
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ export class RegistrationsService {
return [];
}

const customAttributesPhoneNumberNames = [
const registrationAttributesPhoneNumberNames = [
DefaultRegistrationDataAttributeNames.phoneNumber as string,
DefaultRegistrationDataAttributeNames.whatsappPhoneNumber as string,
];
Expand All @@ -767,7 +767,10 @@ export class RegistrationsService {

for (const d of matchingRegistrationData) {
const dataName = await d.getDataName();
if (dataName && customAttributesPhoneNumberNames.includes(dataName)) {
if (
dataName &&
registrationAttributesPhoneNumberNames.includes(dataName)
) {
matchingRegistrations.push({
programId: d.registration.programId,
referenceId: d.registration.referenceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"fixedTransferValue": 10,
"paymentAmountMultiplierFormula": "1 + 1 * dragon",
"targetNrRegistrations": 250,
"programQuestions": [
"programRegistrationAttributes": [
{
"name": "name",
"label": {
Expand Down Expand Up @@ -112,34 +112,6 @@
"showInPeopleAffectedTable": false
}
],
"programCustomAttributes": [
{
"label": {
"ar": "لا يعرف شيئًا",
"en": "Knows nothing",
"es": "No sabe nada",
"fr": "Ne sait rien",
"nl": "Weet niets"
},
"name": "knowsNothing",
"type": "boolean",
"editableInPortal": true,
"showInPeopleAffectedTable": true
},
{
"label": {
"ar": "الشعار",
"en": "Motto",
"es": "Lema",
"fr": "Devise",
"nl": "Motto"
},
"name": "motto",
"type": "text",
"editableInPortal": true,
"showInPeopleAffectedTable": true
}
],
"aboutProgram": {
"ar": "[حول برنامج المساعدات]",
"en": "[about aid program]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ describe('Create program', () => {
// Arrange
const requiredAttributes = ['name', 'type', 'label'];
for (const attribute of requiredAttributes) {
const programCustomAttributeCopy = { ...programRegistrationAttribute };
delete programCustomAttributeCopy[attribute];
const programRegistrationAttributeCopy = {
...programRegistrationAttribute,
};
delete programRegistrationAttributeCopy[attribute];

const createResponse = await postProgramRegistrationAttribute(
programCustomAttributeCopy as any,
programRegistrationAttributeCopy as any,
programIdPV,
accessToken,
);
Expand All @@ -88,12 +90,14 @@ describe('Create program', () => {
// Arrange
const names = ['namePartnerOrganization', 'whatsappPhoneNumber'];
for (const name of names) {
const programCustomAttributeCopy = { ...programRegistrationAttribute };
programCustomAttributeCopy.name = name;
const programRegistrationAttributeCopy = {
...programRegistrationAttribute,
};
programRegistrationAttributeCopy.name = name;

// Act
const createReponse = await postProgramRegistrationAttribute(
programCustomAttributeCopy,
programRegistrationAttributeCopy,
programIdPV,
accessToken,
);
Expand Down

0 comments on commit 291d054

Please sign in to comment.