/** * @param feeAmount TODO * @param processAmount Amount used to pay off this charge * @return Actual amount paid on this charge */ public Money updatePaidAmountBy( final Money incrementBy, final Integer installmentNumber, final Money feeAmount) { Money processAmount = Money.zero(incrementBy.getCurrency()); if (isInstalmentFee()) { if (installmentNumber == null) { processAmount = getUnpaidInstallmentLoanCharge().updatePaidAmountBy(incrementBy, feeAmount); } else { processAmount = getInstallmentLoanCharge(installmentNumber).updatePaidAmountBy(incrementBy, feeAmount); } } else { processAmount = incrementBy; } Money amountPaidToDate = Money.of(processAmount.getCurrency(), this.amountPaid); final Money amountOutstanding = Money.of(processAmount.getCurrency(), this.amountOutstanding); Money amountPaidOnThisCharge = Money.zero(processAmount.getCurrency()); if (processAmount.isGreaterThanOrEqualTo(amountOutstanding)) { amountPaidOnThisCharge = amountOutstanding; amountPaidToDate = amountPaidToDate.plus(amountOutstanding); this.amountPaid = amountPaidToDate.getAmount(); this.amountOutstanding = BigDecimal.ZERO; this.paid = true; } else { amountPaidOnThisCharge = processAmount; amountPaidToDate = amountPaidToDate.plus(processAmount); this.amountPaid = amountPaidToDate.getAmount(); this.amountOutstanding = calculateAmountOutstanding(incrementBy.getCurrency()); } return amountPaidOnThisCharge; }
private SavingsAccountTransaction( final SavingsAccount savingsAccount, final Integer typeOf, final LocalDate dateOf, final Money amount, final boolean isReversed) { this.savingsAccount = savingsAccount; this.typeOf = typeOf; this.dateOf = dateOf.toDate(); this.amount = amount.getAmount(); this.reversed = isReversed; }
public Money waive(final MonetaryCurrency currency, final Integer loanInstallmentNumber) { if (isInstalmentFee()) { final LoanInstallmentCharge chargePerInstallment = getInstallmentLoanCharge(loanInstallmentNumber); final Money amountWaived = chargePerInstallment.waive(currency); if (this.amountWaived == null) { this.amountWaived = BigDecimal.ZERO; } this.amountWaived = this.amountWaived.add(amountWaived.getAmount()); this.amountOutstanding = this.amountOutstanding.subtract(amountWaived.getAmount()); if (determineIfFullyPaid()) { this.paid = false; this.waived = true; } return amountWaived; } this.amountWaived = this.amountOutstanding; this.amountOutstanding = BigDecimal.ZERO; this.paid = false; this.waived = true; return getAmountWaived(currency); }
private SavingsAccountTransaction( final SavingsAccount savingsAccount, final PaymentDetail paymentDetail, final Integer typeOf, final LocalDate transactionLocalDate, final Money amount, final boolean isReversed) { this.savingsAccount = savingsAccount; this.typeOf = typeOf; this.dateOf = transactionLocalDate.toDate(); this.amount = amount.getAmount(); this.reversed = isReversed; this.paymentDetail = paymentDetail; }
public LoanRepaymentScheduleInstallment fetchRepaymentInstallment(final Money trasferedAmount) { for (final LoanInstallmentCharge loanChargePerInstallment : this.loanInstallmentCharge) { if (loanChargePerInstallment.isPending() && trasferedAmount .getAmount() .equals( loanChargePerInstallment .getAmountThroughChargePayment(trasferedAmount.getCurrency()) .getAmount())) { return loanChargePerInstallment.getRepaymentInstallment(); } } return null; }
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; } }
public void updateRunningBalance(final Money balance) { this.runningBalance = balance.getAmount(); }
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(); }