Skip to content

Commit

Permalink
Bug/SU-504: Electronic Invoice UAT fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fiter-julius-oketayot committed Dec 16, 2024
1 parent 1598f49 commit 3581ce0
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,8 @@ public ChangedTransactionDetail reprocessTransactions() {

// just like handleChargeAppliedTransaction , create a new method to handle charges per installment using locan
// charge installement
public void handleChargeAppliedTransactionPerInstallment(final List<LoanCharge> charges, final LocalDate suppliedTransactionDate) {
public void handleChargeAppliedTransactionPerInstallment(final List<LoanCharge> charges, final LocalDate suppliedTransactionDate,
final boolean hasOccurredOnSuspendedAccount) {
for (LoanCharge loanCharge : charges) {
validateLoanIsNotClosed(loanCharge);
validateLoanChargeIsNotWaived(loanCharge);
Expand Down Expand Up @@ -3297,8 +3298,8 @@ private void handleDisbursementTransaction(final LocalDate disbursedOn, final Pa
}
// SU-444 generate charges from disbursement day
if (!installmentalCharges.isEmpty()) {

handleChargeAppliedTransactionPerInstallment(installmentalCharges, disbursedOn);
final boolean hasOccurredOnSuspendedAccount = false;
handleChargeAppliedTransactionPerInstallment(installmentalCharges, disbursedOn, hasOccurredOnSuspendedAccount);
}

if (disbursentMoney.isGreaterThanZero()) {
Expand Down Expand Up @@ -3845,7 +3846,7 @@ private List<LoanTransaction> retrieveListOfTransactionsExcludeAccruals() {
return repaymentsOrWaivers;
}

private List<LoanTransaction> retrieveListOfAccrualTransactions() {
public List<LoanTransaction> retrieveListOfAccrualTransactions() {
final List<LoanTransaction> transactions = new ArrayList<>();
for (final LoanTransaction transaction : this.loanTransactions) {
if (transaction.isNotReversed() && transaction.isAccrual()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import lombok.Getter;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
import org.apache.fineract.infrastructure.core.domain.ExternalId;
import org.apache.fineract.infrastructure.core.service.DateUtils;
Expand Down Expand Up @@ -145,6 +147,11 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
@Column(name = "occurred_on_suspended_account", nullable = false)
private boolean occurredOnSuspendedAccount;

@Setter
@Getter
@Column(name = "invoiced_by_transaction_id")
private Long invoicedByTransactionId;

// This property is added to process vertical payments horizontally for Past Due and Due installments.
// Advance Payments will be handled through VerticalPayment Scheme
@Transient
Expand Down Expand Up @@ -483,6 +490,10 @@ public boolean hasOccurredOnSuspendedAccount() {
return this.occurredOnSuspendedAccount;
}

public void resetInvoicedByTransactionId() {
this.invoicedByTransactionId = null;
}

public void resetDerivedComponents() {
this.principalPortion = null;
this.interestPortion = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.client.domain.LegalForm;
import org.apache.fineract.portfolio.loanaccount.invoice.domain.FacturaElectronicaMensual;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductType;

@Data
@AllArgsConstructor
Expand Down Expand Up @@ -148,32 +149,27 @@ public FacturaElectronicaMensual toEntity() {
}

// INFORMATION AT COMPANY LEVEL
final String taxInformation = "RESPONSABLE DEL IVA. No Somos Grandes Contribuyentes. Autorretenedores Renta según Resol. No. 04314 may 16 de 20028. Auterretenedores especiales según Decreto No. 2201 dic 30 de 2016. Autorretenedores de ICA según Resol. No. 202150186360 del 22 de dic de 2021 Medellín";
final String taxInformation = "RESPONSABLE DEL IVA. No Somos Grandes Contribuyentes. Autorretenedores Renta según Resol. No. 04314 may 16 de 20028. Auterretenedores especiales según Decreto No. 2201 dic 30 de 2016. Autorretenedores de ICA según Resol. No. 202150186360 del 22 de dic de 2021 Medellín.";
facturaElectronicaMensual.setInf_tributaria(taxInformation);
facturaElectronicaMensual.setCantidad(BigDecimal.ONE);
if (LegalForm.fromInt(this.clientLegalForm).isEntity()) {
final String companyCountryCode = "CO";
final String companyCountryName = "COLOMBIA";
facturaElectronicaMensual.setNit_emisor(this.companyNIT);
if ("NIT".equalsIgnoreCase(this.companyDocType)) {
facturaElectronicaMensual.setTipo_docid("31");
} else {
facturaElectronicaMensual.setTipo_docid("13");
}
facturaElectronicaMensual.setNom_emisor(this.clientDisplayName);
facturaElectronicaMensual.setCod_pais_tienda(companyCountryCode);
facturaElectronicaMensual.setNom_pais_tienda(companyCountryName);
facturaElectronicaMensual.setDep_tienda(this.companyDeptCode);
facturaElectronicaMensual.setNom_dep_tienda(this.companyDeptName);
facturaElectronicaMensual.setCod_mun_tienda("05001");
facturaElectronicaMensual.setCiudad_tienda(this.companyCityName);
facturaElectronicaMensual.setDireccion_tienda(this.companyAddress);
facturaElectronicaMensual.setNombre_tienda(this.clientDisplayName);
facturaElectronicaMensual.setTel_tienda(this.companyTelephone);
facturaElectronicaMensual.setEmail_tienda(this.clientEmailAddress);
facturaElectronicaMensual.setTipo_pers(1L);
facturaElectronicaMensual.setCodigopostal(this.companyCityCode);
facturaElectronicaMensual.setTelefono(this.companyTelephone);
facturaElectronicaMensual.setEmail(this.clientEmailAddress);
facturaElectronicaMensual.setId_cliente(this.clientIdNumber);
facturaElectronicaMensual.setNombre_cliente(this.clientDisplayName);
Expand All @@ -188,24 +184,31 @@ public FacturaElectronicaMensual toEntity() {
facturaElectronicaMensual.setApellido_cliente(this.clientLastName);
facturaElectronicaMensual.setDireccion(this.clientAddress);
facturaElectronicaMensual.setCiudad(this.clientCityName);
facturaElectronicaMensual.setCodigopostal(this.clientCityCode);
facturaElectronicaMensual.setTelefono(this.clientTelephone);
facturaElectronicaMensual.setEmail(this.clientEmailAddress);
}

// INFORMATION AT TAX LEVEL
facturaElectronicaMensual.setIva_codigo("01");
facturaElectronicaMensual.setIva_name("IVA");
facturaElectronicaMensual.setBase(BigDecimal.ZERO);
facturaElectronicaMensual.setPorcentaje_impuesto(BigDecimal.ZERO);
facturaElectronicaMensual.setImpuesto(BigDecimal.ZERO);
facturaElectronicaMensual.setNota2("Estos valores corresponden a los cobros asociados a tu crédito: " + this.productTypeName);
facturaElectronicaMensual.setBase(this.totalPaid);

if (LoanProductType.SUMAS_PAY.getCode().equals(this.productTypeName)) {
facturaElectronicaMensual.setNota2("Estos valores corresponden a los cobros asociados a tu Credito Sumas Pay.");
}
facturaElectronicaMensual.setTipo_prod(this.productTypeName);

facturaElectronicaMensual.setPor_dto(this.totalPaid);
facturaElectronicaMensual.setVal_dto(this.totalPaid);
facturaElectronicaMensual.setTotal(this.totalPaid);
facturaElectronicaMensual.setLoan_transaction_id(this.loanTransactionId);
facturaElectronicaMensual.setTel_tienda("018000187373");
facturaElectronicaMensual.setTelefono(this.clientTelephone);

/** SU+ Constant Fields **/
facturaElectronicaMensual.setNit_emisor("800139398-6");
facturaElectronicaMensual.setNom_emisor("Intercrédito de Colombia S.A.S");
facturaElectronicaMensual.setNombre_tienda("Intercrédito de Colombia S.A.S");

return facturaElectronicaMensual;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@

import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.jobs.service.JobName;
import org.apache.fineract.portfolio.loanaccount.invoice.domain.FacturaElectronicMensualRepository;
import org.apache.fineract.portfolio.loanaccount.service.LoanWritePlatformService;
import org.apache.fineract.portfolio.loanproductparameterization.domain.LoanProductParameterizationRepository;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.job.builder.JobBuilder;
Expand All @@ -40,22 +38,17 @@ public class FacturaElectronicaMensualConfig {

private final JobRepository jobRepository;
private final PlatformTransactionManager transactionManager;
private final FacturaElectronicMensualRepository facturaElectronicMensualRepository;
private final JdbcTemplate jdbcTemplate;
private final LoanProductParameterizationRepository productParameterizationRepository;
private final ConfigurationDomainService configurationDomainService;
private final LoanWritePlatformService loanWritePlatformService;

@Autowired
public FacturaElectronicaMensualConfig(final JobRepository jobRepository, final PlatformTransactionManager transactionManager,
final FacturaElectronicMensualRepository facturaElectronicMensualRepository, final JdbcTemplate jdbcTemplate,
final LoanProductParameterizationRepository productParameterizationRepository,
ConfigurationDomainService configurationDomainService, LoanWritePlatformService loanWritePlatformService) {
final JdbcTemplate jdbcTemplate, final ConfigurationDomainService configurationDomainService,
final LoanWritePlatformService loanWritePlatformService) {
this.jobRepository = jobRepository;
this.transactionManager = transactionManager;
this.facturaElectronicMensualRepository = facturaElectronicMensualRepository;
this.jdbcTemplate = jdbcTemplate;
this.productParameterizationRepository = productParameterizationRepository;
this.configurationDomainService = configurationDomainService;
this.loanWritePlatformService = loanWritePlatformService;
}
Expand All @@ -74,7 +67,6 @@ public Job facturaElectronicaMensualJob() {

@Bean
public FacturaElectronicaMensualTasklet facturaElectronicaMensualTaskletStepTasklet() {
return new FacturaElectronicaMensualTasklet(facturaElectronicMensualRepository, jdbcTemplate, productParameterizationRepository,
configurationDomainService, loanWritePlatformService);
return new FacturaElectronicaMensualTasklet(jdbcTemplate, configurationDomainService, loanWritePlatformService);
}
}
Loading

0 comments on commit 3581ce0

Please sign in to comment.