Skip to content

Commit

Permalink
Merge branch 'refs/heads/develop' into P4ADEV-1744-add-api-finalize-s…
Browse files Browse the repository at this point in the history
…ync-status

# Conflicts:
#	openapi/generated.openapi.json
#	src/main/java/it/gov/pagopa/pu/debtpositions/mapper/DebtPositionMapper.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/mapper/InstallmentMapper.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/mapper/PaymentOptionMapper.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/mapper/PersonMapper.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/mapper/TransferMapper.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/model/DebtPosition.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/model/PaymentOption.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/model/Transfer.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionService.java
#	src/main/java/it/gov/pagopa/pu/debtpositions/service/DebtPositionServiceImpl.java
#	src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/DebtPositionFaker.java
#	src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/InstallmentFaker.java
#	src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/PaymentOptionFaker.java
#	src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/PersonFaker.java
#	src/test/java/it/gov/pagopa/pu/debtpositions/util/faker/TransferFaker.java
  • Loading branch information
LarissaASLeite committed Jan 14, 2025
2 parents 38ce7ff + 314c933 commit 59116c8
Show file tree
Hide file tree
Showing 34 changed files with 1,141 additions and 649 deletions.
943 changes: 408 additions & 535 deletions openapi/generated.openapi.json

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions openapi/p4pa-debt-position.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ components:
format: int64
iupdOrg:
type: string
iupdPagopa:
type: string
description:
type: string
status:
Expand Down Expand Up @@ -125,6 +123,9 @@ components:
paymentOptionId:
type: integer
format: int64
debtPositionId:
type: integer
format: int64
totalAmountCents:
type: integer
format: int64
Expand Down Expand Up @@ -163,7 +164,7 @@ components:
format: int64
status:
type: string
iupd_pagopa:
iupdPagopa:
type: string
iud:
type: string
Expand Down Expand Up @@ -218,6 +219,9 @@ components:
transferId:
type: integer
format: int64
installmentId:
type: integer
format: int64
orgFiscalCode:
type: string
orgName:
Expand All @@ -241,7 +245,7 @@ components:
type: string
transferIndex:
type: integer
format: int32
format: int64
ReceiptDTO:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package it.gov.pagopa.pu.debtpositions.config;

import it.gov.pagopa.pu.debtpositions.util.SecurityUtils;
import jakarta.persistence.EntityManagerFactory;
import org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy;
import org.springframework.beans.factory.annotation.Qualifier;
Expand All @@ -10,6 +11,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
Expand All @@ -18,9 +21,11 @@

import javax.sql.DataSource;
import java.util.Map;
import java.util.Optional;

@Configuration
@EnableTransactionManagement
@EnableJpaAuditing(auditorAwareRef="auditorProvider")
@EnableJpaRepositories(
entityManagerFactoryRef = "emfDebtPosition",
transactionManagerRef = "tmDebtPosition",
Expand Down Expand Up @@ -58,4 +63,9 @@ public PlatformTransactionManager debtPositionTransactionManager(

return new JpaTransactionManager(debtPositionEntityManagerFactory);
}

@Bean
public AuditorAware<String> auditorProvider() {
return () -> Optional.ofNullable(SecurityUtils.getCurrentUserExternalId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.util.List;

Expand Down Expand Up @@ -36,9 +37,9 @@ public class Installment {
private String legacyPaymentMetadata;
private Person debtor;
private List<Transfer> transfers;
private OffsetDateTime creationDate;
private OffsetDateTime updateDate;
private Long updateOperatorExternalId;
private LocalDateTime creationDate;
private LocalDateTime updateDate;
private String updateOperatorExternalId;

@JsonIgnore
private InstallmentNoPII noPII;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,64 @@
package it.gov.pagopa.pu.debtpositions.mapper;

import it.gov.pagopa.pu.debtpositions.dto.Installment;
import it.gov.pagopa.pu.debtpositions.dto.generated.DebtPositionDTO;
import it.gov.pagopa.pu.debtpositions.model.DebtPosition;
import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII;
import it.gov.pagopa.pu.debtpositions.model.PaymentOption;
import org.mapstruct.Mapper;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;

@Mapper(componentModel = "spring", uses = {PaymentOptionMapper.class})
public interface DebtPositionMapper {
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

DebtPositionDTO map(DebtPosition debtPosition);
@Service
public class DebtPositionMapper {

private final PaymentOptionMapper paymentOptionMapper;

private static final Collector<PaymentOption, ?, SortedSet<PaymentOption>> toPaymentOptionTreeSet = Collectors.toCollection(TreeSet::new);

public DebtPositionMapper(PaymentOptionMapper paymentOptionMapper) {
this.paymentOptionMapper = paymentOptionMapper;
}

public Pair<DebtPosition, Map<InstallmentNoPII, Installment>> mapToModel(DebtPositionDTO dto) {
DebtPosition debtPosition = new DebtPosition();
debtPosition.setDebtPositionId(dto.getDebtPositionId());
debtPosition.setIupdOrg(dto.getIupdOrg());
debtPosition.setDescription(dto.getDescription());
debtPosition.setStatus(dto.getStatus());
debtPosition.setIngestionFlowFileId(dto.getIngestionFlowFileId());
debtPosition.setIngestionFlowFileLineNumber(dto.getIngestionFlowFileLineNumber());
debtPosition.setOrganizationId(dto.getOrganizationId());
debtPosition.setDebtPositionTypeOrgId(dto.getDebtPositionTypeOrgId());
debtPosition.setNotificationDate(dto.getNotificationDate());
debtPosition.setValidityDate(dto.getValidityDate());
debtPosition.setFlagIuvVolatile(dto.getFlagIuvVolatile());
debtPosition.setCreationDate(dto.getCreationDate().toLocalDateTime());
debtPosition.setUpdateDate(dto.getUpdateDate().toLocalDateTime());

Map<InstallmentNoPII, Installment> installmentMapping = new HashMap<>();

SortedSet<PaymentOption> paymentOptions = dto.getPaymentOptions().stream()
.map(paymentOptionDTO -> {
Pair<PaymentOption, Map<InstallmentNoPII, Installment>> paymentOptionWithInstallments = paymentOptionMapper.mapToModel(paymentOptionDTO);
installmentMapping.putAll(paymentOptionWithInstallments.getSecond());
return paymentOptionWithInstallments.getFirst();
})
.collect(toPaymentOptionTreeSet);

debtPosition.setPaymentOptions(paymentOptions);

return Pair.of(debtPosition, installmentMapping);
}
}

//@Mapper(componentModel = "spring", uses = {PaymentOptionMapper.class})
//public interface DebtPositionMapper {
//
// DebtPositionDTO map(DebtPosition debtPosition);
//}

Original file line number Diff line number Diff line change
@@ -1,11 +1,55 @@
package it.gov.pagopa.pu.debtpositions.mapper;

import it.gov.pagopa.pu.debtpositions.dto.Installment;
import it.gov.pagopa.pu.debtpositions.dto.generated.InstallmentDTO;
import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII;
import org.mapstruct.Mapper;
import org.springframework.stereotype.Service;

@Mapper(componentModel = "spring", uses = {TransferMapper.class, PersonMapper.class})
public interface InstallmentMapper {
@Service
public class InstallmentMapper {

private final PersonMapper personMapper;

private final TransferMapper transferMapper;

public InstallmentMapper(PersonMapper personMapper, TransferMapper transferMapper) {
this.personMapper = personMapper;
this.transferMapper = transferMapper;
}

public Installment mapToModel(InstallmentDTO dto) {
Installment installment = new Installment();
installment.setInstallmentId(dto.getInstallmentId());
installment.setPaymentOptionId(dto.getPaymentOptionId());
installment.setStatus(dto.getStatus());
installment.setIupdPagopa(dto.getIupdPagopa());
installment.setIud(dto.getIud());
installment.setIuv(dto.getIuv());
installment.setIur(dto.getIur());
installment.setIuf(dto.getIuf());
installment.setNav(dto.getNav());
installment.setDueDate(dto.getDueDate());
installment.setPaymentTypeCode(dto.getPaymentTypeCode());
installment.setAmountCents(dto.getAmountCents());
installment.setNotificationFeeCents(dto.getNotificationFeeCents());
installment.setRemittanceInformation(dto.getRemittanceInformation());
installment.setHumanFriendlyRemittanceInformation(dto.getHumanFriendlyRemittanceInformation());
installment.setBalance(dto.getBalance());
installment.setLegacyPaymentMetadata(dto.getLegacyPaymentMetadata());
installment.setDebtor(personMapper.mapToModel(dto.getDebtor()));
installment.setTransfers(dto.getTransfers().stream()
.map(transferMapper::mapToModel)
.toList());
installment.setCreationDate(dto.getCreationDate().toLocalDateTime());
installment.setUpdateDate(dto.getUpdateDate().toLocalDateTime());
return installment;
}

InstallmentDTO map(InstallmentNoPII installment);
}

//@Mapper(componentModel = "spring", uses = {TransferMapper.class, PersonMapper.class})
//public interface InstallmentMapper {
//
// InstallmentDTO map(InstallmentNoPII installment);
//}
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
package it.gov.pagopa.pu.debtpositions.mapper;

import it.gov.pagopa.pu.debtpositions.dto.Installment;
import it.gov.pagopa.pu.debtpositions.dto.InstallmentPIIDTO;
import it.gov.pagopa.pu.debtpositions.dto.generated.PaymentOptionDTO;
import it.gov.pagopa.pu.debtpositions.enums.PaymentOptionType;
import it.gov.pagopa.pu.debtpositions.model.InstallmentNoPII;
import it.gov.pagopa.pu.debtpositions.model.PaymentOption;
import org.mapstruct.Mapper;
import org.springframework.data.util.Pair;
import org.springframework.stereotype.Service;

@Mapper(componentModel = "spring", uses = {InstallmentMapper.class})
public interface PaymentOptionMapper {
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;

PaymentOptionDTO map(PaymentOption paymentOption);
@Service
public class PaymentOptionMapper {

private final InstallmentMapper installmentMapper;
private final InstallmentPIIMapper installmentPIIMapper;

private static final Collector<InstallmentNoPII, ?, SortedSet<InstallmentNoPII>> toInstallmentTreeSet = Collectors.toCollection(TreeSet::new);

public PaymentOptionMapper(InstallmentMapper installmentMapper, InstallmentPIIMapper installmentPIIMapper) {
this.installmentMapper = installmentMapper;
this.installmentPIIMapper = installmentPIIMapper;
}

public Pair<PaymentOption, Map<InstallmentNoPII, Installment>> mapToModel(PaymentOptionDTO dto) {
Map<InstallmentNoPII, Installment> installmentMapping = new HashMap<>();

List<Installment> installments = dto.getInstallments().stream()
.map(installmentMapper::mapToModel)
.toList();

SortedSet<InstallmentNoPII> installmentNoPIIs = installments.stream()
.map(installment -> {
Pair<InstallmentNoPII, InstallmentPIIDTO> result = installmentPIIMapper.map(installment);
InstallmentNoPII installmentNoPII = result.getFirst();
installmentMapping.put(installmentNoPII, installment);
return installmentNoPII;
})
.collect(toInstallmentTreeSet);

PaymentOption paymentOption = new PaymentOption();
paymentOption.setPaymentOptionId(dto.getPaymentOptionId());
paymentOption.setDebtPositionId(dto.getDebtPositionId());
paymentOption.setTotalAmountCents(dto.getTotalAmountCents());
paymentOption.setStatus(dto.getStatus());
paymentOption.setMultiDebtor(dto.getMultiDebtor());
paymentOption.setDueDate(dto.getDueDate());
paymentOption.setDescription(dto.getDescription());
paymentOption.setPaymentOptionType(PaymentOptionType.valueOf(dto.getPaymentOptionType().name()));
paymentOption.setInstallments(installmentNoPIIs);

return Pair.of(paymentOption, installmentMapping);
}
}
//@Mapper(componentModel = "spring", uses = {InstallmentMapper.class})
//public interface PaymentOptionMapper {
//
// PaymentOptionDTO map(PaymentOption paymentOption);
//}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,30 @@
import it.gov.pagopa.pu.debtpositions.dto.Person;
import it.gov.pagopa.pu.debtpositions.dto.generated.PersonDTO;
import org.mapstruct.Mapper;
import org.springframework.stereotype.Service;

@Mapper(componentModel = "spring")
public interface PersonMapper {
@Service
public class PersonMapper {

public Person mapToModel(PersonDTO dto) {
Person person = new Person();
person.setEntityType(dto.getEntityType());
person.setFiscalCode(dto.getFiscalCode());
person.setFullName(dto.getFullName());
person.setAddress(dto.getAddress());
person.setCivic(dto.getCivic());
person.setPostalCode(dto.getPostalCode());
person.setLocation(dto.getLocation());
person.setProvince(dto.getProvince());
person.setNation(dto.getNation());
person.setEmail(dto.getEmail());
return person;
}

PersonDTO map(Person person);
}

//@Mapper(componentModel = "spring")
//public interface PersonMapper {
//
// PersonDTO map(Person person);
//}
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
package it.gov.pagopa.pu.debtpositions.mapper;

import it.gov.pagopa.pu.debtpositions.dto.generated.TransferDTO;
import it.gov.pagopa.pu.debtpositions.model.Stamp;
import it.gov.pagopa.pu.debtpositions.model.Transfer;
import org.mapstruct.Mapper;
import org.springframework.stereotype.Service;

@Mapper(componentModel = "spring")
public interface TransferMapper {
@Service
public class TransferMapper {

TransferDTO map(Transfer transfer);
}
public Transfer mapToModel(TransferDTO dto) {
Transfer transfer = new Transfer();
transfer.setTransferId(dto.getTransferId());
transfer.setInstallmentId(dto.getInstallmentId());
transfer.setOrgFiscalCode(dto.getOrgFiscalCode());
transfer.setOrgName(dto.getOrgName());
transfer.setAmountCents(dto.getAmountCents());
transfer.setRemittanceInformation(dto.getRemittanceInformation());
transfer.setStamp(new Stamp(dto.getStampType(), dto.getStampHashDocument(), dto.getStampProvincialResidence()));
transfer.setIban(dto.getIban());
transfer.setPostalIban(dto.getPostalIban());
transfer.setCategory(dto.getCategory());
transfer.setTransferIndex(dto.getTransferIndex());
return transfer;
}

}
//@Mapper(componentModel = "spring")
//public interface TransferMapper {
//
// TransferDTO map(Transfer transfer);
//}
Loading

0 comments on commit 59116c8

Please sign in to comment.