diff --git a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java index 94affe6d2..020399f5e 100644 --- a/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java +++ b/apps/onboarding-functions/src/main/java/it/pagopa/selfcare/onboarding/service/ContractServiceDefault.java @@ -508,9 +508,14 @@ private File generateAggregatesCsv( break; case "prod-pn": headers = CSV_HEADERS_SEND; - User user = institutions.get(0).getUsers().get(0); - UserResource userInfo = userRegistryApi.findByIdUsingGET(USERS_WORKS_FIELD_LIST, user.getId()); - mapper = sendMapper(userInfo, user); + mapper = institution -> { + List records = new ArrayList<>(); + for (User user : institution.getUsers()) { + UserResource userInfo = userRegistryApi.findByIdUsingGET(USERS_WORKS_FIELD_LIST, user.getId()); + records.addAll(sendMapper(userInfo, user).apply(institution)); + } + return records; + }; break; default: throw new IllegalArgumentException(