Skip to content

Commit

Permalink
Feature/EA-80: Fondo Nacional de Garantías
Browse files Browse the repository at this point in the history
  • Loading branch information
fiter-julius-oketayot committed Jan 9, 2025
2 parents 1a4eca2 + 677b2f5 commit e84c530
Show file tree
Hide file tree
Showing 72 changed files with 3,021 additions and 1,098 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,6 @@ public interface ConfigurationDomainService {

Integer retriveIvaConfiguration();

LocalDate retrievePenaltyStartDate();

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public enum JobName {
PURGE_PROCESSED_COMMANDS("Purge Processed Commands"), //
REACTIVATE_BLOCKED_APP_USERS("Reactivate Blocked App Users"), //
BLOCK_INACTIVE_CLIENTS("Block Inactive Clients"), //
LOAN_CUSTOM_CHARGE_HONORARIO_UPDATE("Loans - Custom Charge Honorario Update"), //
LIQUIDACION_DE_RECAUDOS("Liquidacion de Recaudos"), //
RECALCULATE_LOAN_INTEREST_AFTER_MAXIMUM_LEGAL_RATE_CHANGE("Recalculate Loan Interest After Maximum Legal Rate Change"), //
LIQUIDACION_DE_COMPRAS("Liquidacion de Compras"), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ public void validateChargeIsSetupCorrectly() {
this.getName());
}

if (!this.isPenalty() && !ChargeTimeType.fromInt(this.getChargeTimeType()).isInstalmentFee()) {
if (!this.isPenalty() && !ChargeTimeType.fromInt(this.getChargeTimeType()).isInstalmentFee() && !this.isDisbursementCharge()) {
throw new GeneralPlatformDomainRuleException("error.msg.charge.not.setup.correctly", "Charge not setup correctly",
this.getName());
}
Expand All @@ -1075,7 +1075,7 @@ private void verifyChargeConfiguration(String code, Integer index1, Integer inde
this.getName());
}
}
if (!this.isPenalty() && !this.isInstallmentFee()) {
if (!this.isPenalty() && !this.isInstallmentFee() && !this.isDisbursementCharge()) {
throw new GeneralPlatformDomainRuleException("error.msg.charge.not.setup.correctly", "Charge not setup correctly",
this.getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ public boolean isInstalmentFee() {
return this.value.equals(ChargeTimeType.INSTALMENT_FEE.getValue());
}

public boolean isDisbursementCharge() {
return ChargeTimeType.DISBURSEMENT.getValue().equals(this.value)
|| ChargeTimeType.TRANCHE_DISBURSEMENT.getValue().equals(this.value);
}

public boolean isOverdueInstallment() {
return this.value.equals(ChargeTimeType.OVERDUE_INSTALLMENT.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ public class CustomChargeHonorarioMap extends AbstractPersistableCustom {
@Column(name = "loan_charge_id", nullable = true)
private Long loanChargeId;

// This column is used to identify the batch inserted so that on transaction reversal the latest batch can be
// identified and removed from the table to
// recalculate the installment fee
@Column(name = "version", nullable = true)
private Long version;

// @Column(name = "is_installment_already_paid")
@Transient
private boolean isInstallmentAlreadyPaid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

Expand All @@ -36,4 +37,11 @@ public interface CustomChargeHonorarioMapRepository
@Query(FIND_BY_NIT_LOAN_INSTALLMENT_ACTIVE)
Optional<CustomChargeHonorarioMap> findByNitLoanIdLoanInstallmentNr(@Param("nit") String nit, @Param("loanId") Long loanId,
@Param("loanInstallmentNr") Integer loanInstallmentNr);

@Query("SELECT MAX(c.version) FROM CustomChargeHonorarioMap c WHERE c.loanId = :loanId")
Long getMaxVersionByLoan(@Param("loanId") Long loanId);

@Modifying
@Query("DELETE FROM CustomChargeHonorarioMap p WHERE p.loanId = :loanId and p.version = :version")
int deleteLatestVersionMapEntryOnReversal(@Param("loanId") Long loanId, @Param("version") Long version);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.fineract.portfolio.loanaccount.domain.LoanChargePaidBy;

@Getter
@Setter
Expand All @@ -39,5 +40,15 @@ public class LoanChargePaidByData {
private BigDecimal aval;
private BigDecimal hono;
private BigDecimal penalty;
private boolean penaltyCharge;

public LoanChargePaidByData(LoanChargePaidBy originalData) {
this.id = originalData.getId();
this.amount = originalData.getAmount();
this.installmentNumber = originalData.getInstallmentNumber();
this.chargeId = originalData.getLoanCharge().getId();
this.transactionId = originalData.getLoanTransaction().getId();
this.penaltyCharge = originalData.getLoanCharge().isPenaltyCharge();
this.name = "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,8 @@ public void setLoanChargePaidBySummary(LoanChargePaidByData loanChargePaidBySumm
this.loanChargePaidBySummary = loanChargePaidBySummary;
}

public void updateFeeChargesPortion(BigDecimal amount) {
this.feeChargesPortion = this.feeChargesPortion.add(amount);
}

}
Loading

0 comments on commit e84c530

Please sign in to comment.