Skip to content

Commit

Permalink
Feature/FBR-420: Optimize Loan Additional Information
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius Peter Oketayot committed Dec 14, 2023
1 parent 6e63d19 commit 41b19e0
Show file tree
Hide file tree
Showing 5 changed files with 709 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,30 @@ public class LoanAdditionalData {

private BigDecimal ventas;

private BigDecimal cuentasPorCobrar;

private BigDecimal hipotecas;

private String excepcion;

private Integer tipoExcepcion;

private String descripcionExcepcion;

private BigDecimal montoAutorizado;

private String observaciones;

private BigDecimal capitalDdeTrabajo;

private BigDecimal montoOtrosIngresos;

private String origenOtrosIngresos;

private String otrosIngresos;

private BigDecimal relacionOtrosIngresos;

public LoanAdditionProperties toEntity() {
final LoanAdditionProperties loanAdditionProperties = new LoanAdditionProperties();
BeanUtils.copyProperties(this, loanAdditionProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,43 @@ public class LoanAdditionProperties extends AbstractPersistableCustom {
@Column(name = "ventas")
private BigDecimal ventas;

public LoanAdditionProperties() {}
@Column(name = "cuentas_por_cobrar")
private BigDecimal cuentasPorCobrar;

public static LoanAdditionProperties fromAdditionalData(final LoanAdditionalData loanAdditionalData) {
final LoanAdditionProperties loanAdditionProperties = new LoanAdditionProperties();
BeanUtils.copyProperties(loanAdditionalData, loanAdditionProperties);
return loanAdditionProperties;
}
@Column(name = "hipotecas")
private BigDecimal hipotecas;

@Column(name = "excepcion")
private String excepcion;

@Column(name = "tipo_excepcion")
private Integer tipoExcepcion;

@Column(name = "descripcion_excepcion")
private String descripcionExcepcion;

@Column(name = "monto_autorizado")
private BigDecimal montoAutorizado;

@Column(name = "observaciones")
private String observaciones;

@Column(name = "capital_de_trabajo")
private BigDecimal capitalDdeTrabajo;

@Column(name = "monto_otros_ingresos")
private BigDecimal montoOtrosIngresos;

@Column(name = "origen_otros_ingresos")
private String origenOtrosIngresos;

@Column(name = "otros_ingresos")
private String otrosIngresos;

@Column(name = "Relacion_otros_ingresos")
private BigDecimal relacionOtrosIngresos;

public LoanAdditionProperties() {}

public LoanAdditionalData toData() {
final LoanAdditionalData loanAdditionalData = LoanAdditionalData.builder().build();
Expand Down Expand Up @@ -899,4 +929,60 @@ public void setCaseType(String caseType) {
public void setDateOpened(LocalDateTime dateOpened) {
this.dateOpened = dateOpened;
}

public void setFechaFin(LocalDate fechaFin) {
this.fechaFin = fechaFin;
}

public void setVentas(BigDecimal ventas) {
this.ventas = ventas;
}

public void setCuentasPorCobrar(BigDecimal cuentasPorCobrar) {
this.cuentasPorCobrar = cuentasPorCobrar;
}

public void setHipotecas(BigDecimal hipotecas) {
this.hipotecas = hipotecas;
}

public void setExcepcion(String excepcion) {
this.excepcion = excepcion;
}

public void setTipoExcepcion(Integer tipoExcepcion) {
this.tipoExcepcion = tipoExcepcion;
}

public void setDescripcionExcepcion(String descripcionExcepcion) {
this.descripcionExcepcion = descripcionExcepcion;
}

public void setMontoAutorizado(BigDecimal montoAutorizado) {
this.montoAutorizado = montoAutorizado;
}

public void setObservaciones(String observaciones) {
this.observaciones = observaciones;
}

public void setCapitalDdeTrabajo(BigDecimal capitalDdeTrabajo) {
this.capitalDdeTrabajo = capitalDdeTrabajo;
}

public void setMontoOtrosIngresos(BigDecimal montoOtrosIngresos) {
this.montoOtrosIngresos = montoOtrosIngresos;
}

public void setOrigenOtrosIngresos(String origenOtrosIngresos) {
this.origenOtrosIngresos = origenOtrosIngresos;
}

public void setOtrosIngresos(String otrosIngresos) {
this.otrosIngresos = otrosIngresos;
}

public void setRelacionOtrosIngresos(BigDecimal relacionOtrosIngresos) {
this.relacionOtrosIngresos = relacionOtrosIngresos;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import javax.net.ssl.HttpsURLConnection;
import org.apache.commons.codec.binary.Base64;
import org.apache.fineract.infrastructure.configuration.data.ExternalServicesPropertiesData;
import org.apache.fineract.infrastructure.configuration.service.ExternalServicesConstants;
Expand All @@ -52,6 +53,7 @@
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
import org.apache.fineract.portfolio.loanproduct.exception.LoanProductNotFoundException;
import org.apache.fineract.useradministration.domain.AppUser;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -199,6 +201,7 @@ public LoanAdditionalData retrieveAdditionProperties(final Long productId, final
final String url = loanAdditionalsApiHost + "?caseid=" + caseId;
ResponseEntity<String> responseEntity = null;
try {
HttpsURLConnection.setDefaultHostnameVerifier(NoopHostnameVerifier.INSTANCE);
responseEntity = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(httpHeaders), String.class);
} catch (RestClientException ex) {
LOG.debug("Loan Additional API Provider {} not available", url, ex);
Expand Down Expand Up @@ -274,7 +277,7 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement) {
loanAdditionalDataBuilder.activoCorriente(activoCorriente);

final BigDecimal activoNocorriente = this.fromApiJsonHelper.extractBigDecimalNamed("activo_no_corriente", jsonElement, locale);
loanAdditionalDataBuilder.activoCorriente(activoNocorriente);
loanAdditionalDataBuilder.activoNocorriente(activoNocorriente);

final BigDecimal alimentacion = this.fromApiJsonHelper.extractBigDecimalNamed("alimentacion", jsonElement, locale);
loanAdditionalDataBuilder.alimentacion(alimentacion);
Expand Down Expand Up @@ -320,9 +323,12 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement) {
final String cOtroNombre = this.fromApiJsonHelper.extractStringNamed("c_otro_nombre", jsonElement);
loanAdditionalDataBuilder.cOtroNombre(cOtroNombre);

final String cPrimerApellido = this.fromApiJsonHelper.extractStringNamed("c_primer_nombre", jsonElement);
final String cPrimerApellido = this.fromApiJsonHelper.extractStringNamed("c_primer_apellido", jsonElement);
loanAdditionalDataBuilder.cPrimerApellido(cPrimerApellido);

final String cPrimerNombre = this.fromApiJsonHelper.extractStringNamed("c_primer_nombre", jsonElement);
loanAdditionalDataBuilder.cPrimerNombre(cPrimerNombre);

final String cProfesion = this.fromApiJsonHelper.extractStringNamed("c_profesion", jsonElement);
loanAdditionalDataBuilder.cProfesion(cProfesion);

Expand Down Expand Up @@ -377,9 +383,12 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement) {
final BigDecimal efectivo = this.fromApiJsonHelper.extractBigDecimalNamed("efectivo", jsonElement, locale);
loanAdditionalDataBuilder.efectivo(efectivo);

final BigDecimal endeudamientoActual = this.fromApiJsonHelper.extractBigDecimalNamed("endeudamiento_futuro", jsonElement, locale);
final BigDecimal endeudamientoActual = this.fromApiJsonHelper.extractBigDecimalNamed("endeudamiento_actual", jsonElement, locale);
loanAdditionalDataBuilder.endeudamientoActual(endeudamientoActual);

final BigDecimal endeudamientoFuturo = this.fromApiJsonHelper.extractBigDecimalNamed("endeudamiento_futuro", jsonElement, locale);
loanAdditionalDataBuilder.endeudamientoFuturo(endeudamientoFuturo);

final Integer enf = this.fromApiJsonHelper.extractIntegerNamed("enf", jsonElement, locale);
loanAdditionalDataBuilder.enf(enf);

Expand Down Expand Up @@ -436,7 +445,7 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement) {
loanAdditionalDataBuilder.inventarios(inventarios);

final BigDecimal inversionTotal = this.fromApiJsonHelper.extractBigDecimalNamed("inversion_total", jsonElement, locale);
loanAdditionalDataBuilder.inventarios(inversionTotal);
loanAdditionalDataBuilder.inversionTotal(inversionTotal);

final String invertir = this.fromApiJsonHelper.extractStringNamed("invertir", jsonElement);
loanAdditionalDataBuilder.invertir(invertir);
Expand Down Expand Up @@ -480,7 +489,7 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement) {
final Integer plazoVigente = this.fromApiJsonHelper.extractIntegerNamed("plazo_vigente", jsonElement, locale);
loanAdditionalDataBuilder.plazoVigente(plazoVigente);

final String poseeCuenta = this.fromApiJsonHelper.extractStringNamed("poseeCuenta", jsonElement);
final String poseeCuenta = this.fromApiJsonHelper.extractStringNamed("posee_cuenta", jsonElement);
loanAdditionalDataBuilder.poseeCuenta(poseeCuenta);

final Long prestamoPuente = this.fromApiJsonHelper.extractLongNamed("prestamo_puente", jsonElement);
Expand Down Expand Up @@ -593,6 +602,43 @@ public LoanAdditionalData mapFromJson(final JsonElement jsonElement) {
final BigDecimal ventas = this.fromApiJsonHelper.extractBigDecimalNamed("ventas", jsonElement, locale);
loanAdditionalDataBuilder.ventas(ventas);

final BigDecimal cuentasPorCobrar = this.fromApiJsonHelper.extractBigDecimalNamed("cuentas_por_cobrar", jsonElement, locale);
loanAdditionalDataBuilder.cuentasPorCobrar(cuentasPorCobrar);

final BigDecimal hipotecas = this.fromApiJsonHelper.extractBigDecimalNamed("hipotecas", jsonElement, locale);
loanAdditionalDataBuilder.hipotecas(hipotecas);

final String excepcion = this.fromApiJsonHelper.extractStringNamed("excepcion", jsonElement);
loanAdditionalDataBuilder.excepcion(excepcion);

final Integer tipoExcepcion = this.fromApiJsonHelper.extractIntegerNamed("tipo_excepcion", jsonElement, locale);
loanAdditionalDataBuilder.tipoExcepcion(tipoExcepcion);

final String descripcionExcepcion = this.fromApiJsonHelper.extractStringNamed("descripcion_excepcion", jsonElement);
loanAdditionalDataBuilder.descripcionExcepcion(descripcionExcepcion);

final BigDecimal montoAutorizado = this.fromApiJsonHelper.extractBigDecimalNamed("monto_autorizado", jsonElement, locale);
loanAdditionalDataBuilder.montoAutorizado(montoAutorizado);

final String observaciones = this.fromApiJsonHelper.extractStringNamed("observaciones", jsonElement);
loanAdditionalDataBuilder.observaciones(observaciones);

final BigDecimal montoOtrosIngresos = this.fromApiJsonHelper.extractBigDecimalNamed("monto_otros_ingresos", jsonElement, locale);
loanAdditionalDataBuilder.montoOtrosIngresos(montoOtrosIngresos);

final BigDecimal capitalDdeTrabajo = this.fromApiJsonHelper.extractBigDecimalNamed("capital_de_trabajo", jsonElement, locale);
loanAdditionalDataBuilder.capitalDdeTrabajo(capitalDdeTrabajo);

final String origenOtrosIngresos = this.fromApiJsonHelper.extractStringNamed("origen_otros_ingresos", jsonElement);
loanAdditionalDataBuilder.origenOtrosIngresos(origenOtrosIngresos);

final String otrosIngresos = this.fromApiJsonHelper.extractStringNamed("otros_ingresos", jsonElement);
loanAdditionalDataBuilder.otrosIngresos(otrosIngresos);

final BigDecimal relacionOtrosIngresos = this.fromApiJsonHelper.extractBigDecimalNamed("Relacion_otros_ingresos", jsonElement,
locale);
loanAdditionalDataBuilder.relacionOtrosIngresos(relacionOtrosIngresos);

return loanAdditionalDataBuilder.build();
}
}
Loading

0 comments on commit 41b19e0

Please sign in to comment.