コード例 #1
0
  public void updateSummary(
      final MonetaryCurrency currency,
      final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments,
      final LoanSummaryWrapper summaryWrapper) {

    this.totalPrincipalOverdue =
        summaryWrapper
            .calculateTotalPrincipalOverdueOn(
                repaymentScheduleInstallments, currency, DateUtils.getLocalDateOfTenant())
            .getAmount();
    this.totalInterestOverdue =
        summaryWrapper
            .calculateTotalInterestOverdueOn(
                repaymentScheduleInstallments, currency, DateUtils.getLocalDateOfTenant())
            .getAmount();
    this.totalFeeChargesOverdue =
        summaryWrapper
            .calculateTotalFeeChargesOverdueOn(
                repaymentScheduleInstallments, currency, DateUtils.getLocalDateOfTenant())
            .getAmount();
    this.totalPenaltyChargesOverdue =
        summaryWrapper
            .calculateTotalPenaltyChargesOverdueOn(
                repaymentScheduleInstallments, currency, DateUtils.getLocalDateOfTenant())
            .getAmount();

    final Money totalOverdue =
        Money.of(currency, this.totalPrincipalOverdue)
            .plus(this.totalInterestOverdue)
            .plus(this.totalFeeChargesOverdue)
            .plus(this.totalPenaltyChargesOverdue);
    this.totalOverdue = totalOverdue.getAmount();

    final LocalDate overdueSinceLocalDate =
        summaryWrapper.determineOverdueSinceDateFrom(
            repaymentScheduleInstallments, currency, DateUtils.getLocalDateOfTenant());
    if (overdueSinceLocalDate != null) {
      this.overdueSinceDate = overdueSinceLocalDate.toDate();
    } else {
      this.overdueSinceDate = null;
    }
  }
コード例 #2
0
  public void updateSummary(
      final MonetaryCurrency currency,
      final Money principal,
      final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments,
      final LoanSummaryWrapper summaryWrapper,
      final Boolean disbursed) {

    this.totalPrincipalDisbursed = principal.getAmount();
    this.totalPrincipalRepaid =
        summaryWrapper
            .calculateTotalPrincipalRepaid(repaymentScheduleInstallments, currency)
            .getAmount();
    this.totalPrincipalWrittenOff =
        summaryWrapper
            .calculateTotalPrincipalWrittenOff(repaymentScheduleInstallments, currency)
            .getAmount();

    this.totalPrincipalOutstanding =
        principal.minus(this.totalPrincipalRepaid).minus(this.totalPrincipalWrittenOff).getAmount();

    final Money totalInterestCharged =
        summaryWrapper.calculateTotalInterestCharged(repaymentScheduleInstallments, currency);
    this.totalInterestCharged = totalInterestCharged.getAmount();
    this.totalInterestRepaid =
        summaryWrapper
            .calculateTotalInterestRepaid(repaymentScheduleInstallments, currency)
            .getAmount();
    this.totalInterestWaived =
        summaryWrapper
            .calculateTotalInterestWaived(repaymentScheduleInstallments, currency)
            .getAmount();
    this.totalInterestWrittenOff =
        summaryWrapper
            .calculateTotalInterestWrittenOff(repaymentScheduleInstallments, currency)
            .getAmount();

    this.totalInterestOutstanding =
        totalInterestCharged
            .minus(this.totalInterestRepaid)
            .minus(this.totalInterestWaived)
            .minus(this.totalInterestWrittenOff)
            .getAmount();

    final Money totalFeeChargesCharged =
        summaryWrapper
            .calculateTotalFeeChargesCharged(repaymentScheduleInstallments, currency)
            .plus(this.totalFeeChargesDueAtDisbursement);
    this.totalFeeChargesCharged = totalFeeChargesCharged.getAmount();

    Money totalFeeChargesRepaid =
        summaryWrapper.calculateTotalFeeChargesRepaid(repaymentScheduleInstallments, currency);
    if (disbursed) {
      totalFeeChargesRepaid = totalFeeChargesRepaid.plus(this.totalFeeChargesDueAtDisbursement);
    }
    this.totalFeeChargesRepaid = totalFeeChargesRepaid.getAmount();

    this.totalFeeChargesWaived =
        summaryWrapper
            .calculateTotalFeeChargesWaived(repaymentScheduleInstallments, currency)
            .getAmount();
    this.totalFeeChargesWrittenOff =
        summaryWrapper
            .calculateTotalFeeChargesWrittenOff(repaymentScheduleInstallments, currency)
            .getAmount();

    this.totalFeeChargesOutstanding =
        totalFeeChargesCharged
            .minus(this.totalFeeChargesRepaid)
            .minus(this.totalFeeChargesWaived)
            .minus(this.totalFeeChargesWrittenOff)
            .getAmount();

    final Money totalPenaltyChargesCharged =
        summaryWrapper.calculateTotalPenaltyChargesCharged(repaymentScheduleInstallments, currency);
    this.totalPenaltyChargesCharged = totalPenaltyChargesCharged.getAmount();
    this.totalPenaltyChargesRepaid =
        summaryWrapper
            .calculateTotalPenaltyChargesRepaid(repaymentScheduleInstallments, currency)
            .getAmount();
    this.totalPenaltyChargesWaived =
        summaryWrapper
            .calculateTotalPenaltyChargesWaived(repaymentScheduleInstallments, currency)
            .getAmount();
    this.totalPenaltyChargesWrittenOff =
        summaryWrapper
            .calculateTotalPenaltyChargesWrittenOff(repaymentScheduleInstallments, currency)
            .getAmount();

    this.totalPenaltyChargesOutstanding =
        totalPenaltyChargesCharged
            .minus(this.totalPenaltyChargesRepaid)
            .minus(this.totalPenaltyChargesWaived)
            .minus(this.totalPenaltyChargesWrittenOff)
            .getAmount();

    final Money totalExpectedRepayment =
        Money.of(currency, this.totalPrincipalDisbursed)
            .plus(this.totalInterestCharged)
            .plus(this.totalFeeChargesCharged)
            .plus(this.totalPenaltyChargesCharged);
    this.totalExpectedRepayment = totalExpectedRepayment.getAmount();

    final Money totalRepayment =
        Money.of(currency, this.totalPrincipalRepaid)
            .plus(this.totalInterestRepaid)
            .plus(this.totalFeeChargesRepaid)
            .plus(this.totalPenaltyChargesRepaid);
    this.totalRepayment = totalRepayment.getAmount();

    final Money totalExpectedCostOfLoan =
        Money.of(currency, this.totalInterestCharged)
            .plus(this.totalFeeChargesCharged)
            .plus(this.totalPenaltyChargesCharged);
    this.totalExpectedCostOfLoan = totalExpectedCostOfLoan.getAmount();

    final Money totalCostOfLoan =
        Money.of(currency, this.totalInterestRepaid)
            .plus(this.totalFeeChargesRepaid)
            .plus(this.totalPenaltyChargesRepaid);
    this.totalCostOfLoan = totalCostOfLoan.getAmount();

    final Money totalWaived =
        Money.of(currency, this.totalInterestWaived)
            .plus(this.totalFeeChargesWaived)
            .plus(this.totalPenaltyChargesWaived);
    this.totalWaived = totalWaived.getAmount();

    final Money totalWrittenOff =
        Money.of(currency, this.totalPrincipalWrittenOff)
            .plus(this.totalInterestWrittenOff)
            .plus(this.totalFeeChargesWrittenOff)
            .plus(this.totalPenaltyChargesWrittenOff);
    this.totalWrittenOff = totalWrittenOff.getAmount();

    final Money totalOutstanding =
        Money.of(currency, this.totalPrincipalOutstanding)
            .plus(this.totalInterestOutstanding)
            .plus(this.totalFeeChargesOutstanding)
            .plus(this.totalPenaltyChargesOutstanding);
    this.totalOutstanding = totalOutstanding.getAmount();
  }