Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46f5a1babd | ||
|
|
20fe11e60d |
+1
-10
@@ -37,13 +37,4 @@ gradleExp/
|
||||
.windsurf/
|
||||
|
||||
# Application logs
|
||||
fineract-provider/logs/
|
||||
logs/
|
||||
|
||||
# Output of a local `gradlew devRun`
|
||||
devrun.log
|
||||
|
||||
# JVM crash dumps. The dev setup runs Fineract, the Angular dev server and Gradle on one
|
||||
# machine, so an out-of-memory kill drops these in the repo root.
|
||||
hs_err_pid*.log
|
||||
replay_pid*.log
|
||||
fineract-provider/logs/
|
||||
+9
@@ -2897,6 +2897,15 @@ public class CommandWrapperBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder paymentFixedDepositAccount(final Long accountId) {
|
||||
this.actionName = "PAYMENT";
|
||||
this.entityName = "FIXEDDEPOSITACCOUNT";
|
||||
this.entityId = accountId;
|
||||
this.savingsId = accountId;
|
||||
this.href = "/fixeddepositaccounts/" + accountId + "?command=payment";
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandWrapperBuilder fixedDepositAccountInterestCalculation(final Long accountId) {
|
||||
this.actionName = "CALCULATEINTEREST";
|
||||
this.entityName = "FIXEDDEPOSITACCOUNT";
|
||||
|
||||
+16
-1
@@ -72,11 +72,26 @@ public class SavingsAccountSummaryData {
|
||||
// differentiate deposit accounts Savings, FD and RD accounts
|
||||
private final EnumOptionData depositType;
|
||||
|
||||
/**
|
||||
* For a Fixed Deposit, the stable customer-facing FD number: the account number of the first account in the renewal
|
||||
* chain, which stays the same across every renewal even though each term is its own account row. Equals accountNo
|
||||
* for an FD that has never been renewed, and is null for non-deposit accounts.
|
||||
*/
|
||||
private final String fdAccountNumber;
|
||||
/**
|
||||
* Which renewal cycle of that FD this row is: 0 for the originally opened account, 1 for the first renewal, and so
|
||||
* on. Lets a client's account list collapse a renewal chain into one FD instead of listing each term separately.
|
||||
*/
|
||||
private final Integer renewalCycleNo;
|
||||
|
||||
public SavingsAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String productName, final String shortProductName, final SavingsAccountStatusEnumData status, final CurrencyData currency,
|
||||
final BigDecimal accountBalance, final BigDecimal onHoldFunds, final BigDecimal savingsAmountOnHold,
|
||||
final BigDecimal availableBalance, final EnumOptionData accountType, final SavingsAccountApplicationTimelineData timeline,
|
||||
final EnumOptionData depositType, final SavingsAccountSubStatusEnumData subStatus, final LocalDate lastActiveTransactionDate) {
|
||||
final EnumOptionData depositType, final SavingsAccountSubStatusEnumData subStatus, final LocalDate lastActiveTransactionDate,
|
||||
final String fdAccountNumber, final Integer renewalCycleNo) {
|
||||
this.fdAccountNumber = fdAccountNumber;
|
||||
this.renewalCycleNo = renewalCycleNo;
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.externalId = externalId;
|
||||
|
||||
+7
-1
@@ -31,7 +31,8 @@ public enum DepositAccountOnClosureType {
|
||||
WITHDRAW_DEPOSIT(100, "depositAccountClosureType.withdrawDeposit"), //
|
||||
TRANSFER_TO_SAVINGS(200, "depositAccountClosureType.transferToSavings"), //
|
||||
REINVEST_PRINCIPAL_AND_INTEREST(300, "depositAccountClosureType.reinvestPrincipalAndInterest"), //
|
||||
REINVEST_PRINCIPAL_ONLY(400, "depositAccountClosureType.reinvestPrincipalOnly"); //
|
||||
REINVEST_PRINCIPAL_ONLY(400, "depositAccountClosureType.reinvestPrincipalOnly"), //
|
||||
PARTIAL_REINVEST(500, "depositAccountClosureType.partialReinvest"); //
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
@@ -51,6 +52,7 @@ public enum DepositAccountOnClosureType {
|
||||
case 200 -> TRANSFER_TO_SAVINGS;
|
||||
case 300 -> REINVEST_PRINCIPAL_AND_INTEREST;
|
||||
case 400 -> REINVEST_PRINCIPAL_ONLY;
|
||||
case 500 -> PARTIAL_REINVEST;
|
||||
default -> INVALID;
|
||||
};
|
||||
}
|
||||
@@ -85,6 +87,10 @@ public enum DepositAccountOnClosureType {
|
||||
return this.equals(INVALID);
|
||||
}
|
||||
|
||||
public boolean isPartialReinvest() {
|
||||
return this.equals(PARTIAL_REINVEST);
|
||||
}
|
||||
|
||||
// TODO: do we really need this?!?
|
||||
public static Object[] integerValues() {
|
||||
return Arrays.stream(values()).filter(value -> !INVALID.equals(value)).map(value -> value.value).toList().toArray();
|
||||
|
||||
+1
@@ -208,6 +208,7 @@ public final class DepositsApiConstants {
|
||||
public static final String onAccountClosureIdParamName = "onAccountClosureId";
|
||||
public static final String transferDescriptionParamName = "transferDescription";
|
||||
public static final String toSavingsAccountIdParamName = "toSavingsAccountId";
|
||||
public static final String reinvestAmountParamName = "reinvestAmount";
|
||||
public static final String savingsAccounts = "savingsAccounts";
|
||||
public static final String maturityInstructionIdParamName = "maturityInstructionId";
|
||||
public static final String transferToSavingsIdParamName = "transferToSavingsId";
|
||||
|
||||
+4
@@ -797,6 +797,10 @@ public final class SavingsEnumerations {
|
||||
optionData = new EnumOptionData(DepositAccountOnClosureType.REINVEST_PRINCIPAL_ONLY.getValue().longValue(),
|
||||
DepositAccountOnClosureType.REINVEST_PRINCIPAL_ONLY.getCode(), "Re-Invest Principal Only");
|
||||
break;
|
||||
case PARTIAL_REINVEST:
|
||||
optionData = new EnumOptionData(DepositAccountOnClosureType.PARTIAL_REINVEST.getValue().longValue(),
|
||||
DepositAccountOnClosureType.PARTIAL_REINVEST.getCode(), "Partial Re-Invest");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
-20
@@ -1466,26 +1466,6 @@ public class LoanProductData implements Serializable {
|
||||
this.allowAttributeOverrides = loanProductConfigurableAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* The legacy "Account Type Creation" fields, flat and keyed by their form field name.
|
||||
*
|
||||
* Set after construction rather than through a constructor parameter: the main constructor already
|
||||
* takes over a hundred arguments, and threading two more through it would touch every call site for
|
||||
* no benefit. Follows the same pattern as setLoanProductConfigurableAttributes above.
|
||||
*/
|
||||
private Map<String, Object> cbsExtensions;
|
||||
|
||||
/** The legacy Interest Rate Detail grid: one entry per interest type, in form order. */
|
||||
private List<Map<String, Object>> interestRateDetail;
|
||||
|
||||
public void setCbsExtensions(final Map<String, Object> cbsExtensions) {
|
||||
this.cbsExtensions = cbsExtensions;
|
||||
}
|
||||
|
||||
public void setInterestRateDetail(final List<Map<String, Object>> interestRateDetail) {
|
||||
this.interestRateDetail = interestRateDetail;
|
||||
}
|
||||
|
||||
public boolean isIsLinkedToFloatingInterestRates() {
|
||||
return this.isLinkedToFloatingInterestRates;
|
||||
}
|
||||
|
||||
-740
@@ -1,740 +0,0 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanproduct.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The legacy "Account Type Creation" configuration for a loan product.
|
||||
*
|
||||
* Fineract's loan product schema has no home for these fields, and they are specific to this
|
||||
* deployment, so they hang off {@link LoanProduct} 1:1 instead of widening m_product_loan - an
|
||||
* upstream change to that table can then never collide with them.
|
||||
*
|
||||
* Loan account creation reads this at origination time, which is why these are typed columns rather
|
||||
* than a JSON blob: callers get a compile-checked getter and reports get a plain column.
|
||||
*/
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "m_product_loan_cbs_ext")
|
||||
public class LoanProductCbsExt {
|
||||
|
||||
@Id
|
||||
@Column(name = "loan_product_id")
|
||||
private Long loanProductId;
|
||||
|
||||
/**
|
||||
* Shared primary key: this and {@link #loanProductId} are the same column, so the association is
|
||||
* mapped read-only and {@code loanProductId} is the one that writes it. EclipseLink rejects an
|
||||
* entity with two writable mappings for one field.
|
||||
*/
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "loan_product_id", insertable = false, updatable = false)
|
||||
private LoanProduct loanProduct;
|
||||
|
||||
// ---- classification & legacy header fields (24) ---------------------
|
||||
|
||||
@Column(name = "product_type_group")
|
||||
private String productTypeGroup;
|
||||
|
||||
@Column(name = "product_type_sub_group")
|
||||
private String productTypeSubGroup;
|
||||
|
||||
@Column(name = "debit_int_calculation")
|
||||
private Boolean debitIntCalculation;
|
||||
|
||||
@Column(name = "separate_penal_interest")
|
||||
private Boolean separatePenalInterest;
|
||||
|
||||
@Column(name = "credit_int_calculation")
|
||||
private Boolean creditIntCalculation;
|
||||
|
||||
@Column(name = "sub_account_type_balance")
|
||||
private Boolean subAccountTypeBalance;
|
||||
|
||||
@Column(name = "final_int_rounding")
|
||||
private Boolean finalIntRounding;
|
||||
|
||||
@Column(name = "rounding_up_to")
|
||||
private Integer roundingUpTo;
|
||||
|
||||
@Column(name = "account_type_code")
|
||||
private String accountTypeCode;
|
||||
|
||||
@Column(name = "micr_transaction_code")
|
||||
private String micrTransactionCode;
|
||||
|
||||
@Column(name = "reserved_ecs_serial_number")
|
||||
private String reservedEcsSerialNumber;
|
||||
|
||||
@Column(name = "reverse_ecs_number")
|
||||
private String reverseEcsNumber;
|
||||
|
||||
@Column(name = "lock_cheque_info_enabled")
|
||||
private Boolean lockChequeInfoEnabled;
|
||||
|
||||
@Column(name = "lock_page_two_info_enabled")
|
||||
private Boolean lockPageTwoInfoEnabled;
|
||||
|
||||
@Column(name = "computerization_date")
|
||||
private LocalDate computerizationDate;
|
||||
|
||||
@Column(name = "cheque_print_description")
|
||||
private String chequePrintDescription;
|
||||
|
||||
@Column(name = "pos_account_type_description")
|
||||
private String posAccountTypeDescription;
|
||||
|
||||
@Column(name = "pfms_account_type")
|
||||
private String pfmsAccountType;
|
||||
|
||||
@Column(name = "renewal_date_add_months")
|
||||
private Integer renewalDateAddMonths;
|
||||
|
||||
@Column(name = "document_renewal_date_add_months")
|
||||
private Integer documentRenewalDateAddMonths;
|
||||
|
||||
@Column(name = "pps_limit")
|
||||
private BigDecimal ppsLimit;
|
||||
|
||||
@Column(name = "is_write_off_account_type")
|
||||
private Boolean isWriteOffAccountType;
|
||||
|
||||
@Column(name = "write_off_account_type_code")
|
||||
private String writeOffAccountTypeCode;
|
||||
|
||||
@Column(name = "renewal_grace_days")
|
||||
private Integer renewalGraceDays;
|
||||
|
||||
// ---- Cheque Book Settings (10) --------------------------------------
|
||||
|
||||
@Column(name = "cheque_book_issue_enabled")
|
||||
private Boolean chequeBookIssueEnabled;
|
||||
|
||||
@Column(name = "cheque_validation_required")
|
||||
private Boolean chequeValidationRequired;
|
||||
|
||||
@Column(name = "is_first_cheque_book_free")
|
||||
private Boolean isFirstChequeBookFree;
|
||||
|
||||
@Column(name = "cheque_printing_account_type")
|
||||
private String chequePrintingAccountType;
|
||||
|
||||
@Column(name = "allow_withdrawal_slip_usage")
|
||||
private Boolean allowWithdrawalSlipUsage;
|
||||
|
||||
@Column(name = "maintain_cheque_book_stock_registry")
|
||||
private Boolean maintainChequeBookStockRegistry;
|
||||
|
||||
@Column(name = "free_cheque_books_per_year")
|
||||
private Integer freeChequeBooksPerYear;
|
||||
|
||||
@Column(name = "allow_credit_by_cheque_number")
|
||||
private Boolean allowCreditByChequeNumber;
|
||||
|
||||
@Column(name = "credit_cheque_validation_required")
|
||||
private Boolean creditChequeValidationRequired;
|
||||
|
||||
@Column(name = "grace_days_for_stock_statement")
|
||||
private Integer graceDaysForStockStatement;
|
||||
|
||||
// ---- Additional Product Settings (37) -------------------------------
|
||||
|
||||
@Column(name = "account_type_active_for_transactions")
|
||||
private Boolean accountTypeActiveForTransactions;
|
||||
|
||||
@Column(name = "sub_type_activity_enabled")
|
||||
private Boolean subTypeActivityEnabled;
|
||||
|
||||
@Column(name = "account_opening_charges")
|
||||
private BigDecimal accountOpeningCharges;
|
||||
|
||||
@Column(name = "maximum_gold_loan_limit")
|
||||
private BigDecimal maximumGoldLoanLimit;
|
||||
|
||||
@Column(name = "last_account_number_opened")
|
||||
private String lastAccountNumberOpened;
|
||||
|
||||
@Column(name = "customer_termination_allowed")
|
||||
private Boolean customerTerminationAllowed;
|
||||
|
||||
@Column(name = "charges_for_cash_credit_above_limit")
|
||||
private BigDecimal chargesForCashCreditAboveLimit;
|
||||
|
||||
@Column(name = "death_interest_gl_account")
|
||||
private String deathInterestGLAccount;
|
||||
|
||||
@Column(name = "starting_ledger_number")
|
||||
private Integer startingLedgerNumber;
|
||||
|
||||
@Column(name = "ending_ledger_number")
|
||||
private Integer endingLedgerNumber;
|
||||
|
||||
@Column(name = "current_ledger_number")
|
||||
private Integer currentLedgerNumber;
|
||||
|
||||
@Column(name = "remittance_account_number")
|
||||
private String remittanceAccountNumber;
|
||||
|
||||
@Column(name = "is_non_resident_indian_account")
|
||||
private Boolean isNonResidentIndianAccount;
|
||||
|
||||
@Column(name = "debit_clearing_gl_account")
|
||||
private String debitClearingGLAccount;
|
||||
|
||||
@Column(name = "missed_call_alert_service_active")
|
||||
private Boolean missedCallAlertServiceActive;
|
||||
|
||||
@Column(name = "standing_instruction_charge_gl_account")
|
||||
private String standingInstructionChargeGLAccount;
|
||||
|
||||
@Column(name = "standing_instruction_debit_charge_skip_option")
|
||||
private String standingInstructionDebitChargeSkipOption;
|
||||
|
||||
@Column(name = "opening_balance_multiplier_for_remittance_charges")
|
||||
private BigDecimal openingBalanceMultiplierForRemittanceCharges;
|
||||
|
||||
@Column(name = "gold_loan_packet_number_with_year_enabled")
|
||||
private Boolean goldLoanPacketNumberWithYearEnabled;
|
||||
|
||||
@Column(name = "account_move_to_inoperative_enabled")
|
||||
private Boolean accountMoveToInoperativeEnabled;
|
||||
|
||||
@Column(name = "generate_gl_diff_entry_enabled")
|
||||
private Boolean generateGlDiffEntryEnabled;
|
||||
|
||||
@Column(name = "sub_type_wise_gl_balance_generation_enabled")
|
||||
private Boolean subTypeWiseGlBalanceGenerationEnabled;
|
||||
|
||||
@Column(name = "validate_before_deleting_debit_entry_enabled")
|
||||
private Boolean validateBeforeDeletingDebitEntryEnabled;
|
||||
|
||||
@Column(name = "rc_file_concept_enabled")
|
||||
private Boolean rcFileConceptEnabled;
|
||||
|
||||
@Column(name = "account_close_zero_balance_in_open_day_process")
|
||||
private Boolean accountCloseZeroBalanceInOpenDayProcess;
|
||||
|
||||
@Column(name = "account_close_zero_balance_at_subledger_tran_entry")
|
||||
private Boolean accountCloseZeroBalanceAtSubledgerTranEntry;
|
||||
|
||||
@Column(name = "limit_enhancement_against_clearing_screen_display_enabled")
|
||||
private Boolean limitEnhancementAgainstClearingScreenDisplayEnabled;
|
||||
|
||||
@Column(name = "advance_interest_parameter_in_ledger_enabled")
|
||||
private Boolean advanceInterestParameterInLedgerEnabled;
|
||||
|
||||
@Column(name = "vehicle_detail_in_master_enabled")
|
||||
private Boolean vehicleDetailInMasterEnabled;
|
||||
|
||||
@Column(name = "deleted_cheque_issue_enabled")
|
||||
private Boolean deletedChequeIssueEnabled;
|
||||
|
||||
@Column(name = "dp_reduce_in_document_renewal_date_enabled")
|
||||
private Boolean dpReduceInDocumentRenewalDateEnabled;
|
||||
|
||||
@Column(name = "dp_reduce_in_renewal_date_enabled")
|
||||
private Boolean dpReduceInRenewalDateEnabled;
|
||||
|
||||
@Column(name = "auto_close_at_day_end_enabled")
|
||||
private Boolean autoCloseAtDayEndEnabled;
|
||||
|
||||
@Column(name = "loan_rate_from_master_enabled")
|
||||
private Boolean loanRateFromMasterEnabled;
|
||||
|
||||
@Column(name = "cheque_short_name")
|
||||
private String chequeShortName;
|
||||
|
||||
@Column(name = "statement_print_enabled")
|
||||
private Boolean statementPrintEnabled;
|
||||
|
||||
@Column(name = "nesl_code")
|
||||
private String neslCode;
|
||||
|
||||
// ---- Interest Related Parameters (53) -------------------------------
|
||||
|
||||
@Column(name = "drawing_power_and_limit_generation_procedure")
|
||||
private String drawingPowerAndLimitGenerationProcedure;
|
||||
|
||||
@Column(name = "advances_interest_calculation_method")
|
||||
private String advancesInterestCalculationMethod;
|
||||
|
||||
@Column(name = "against_interest_calculation_enabled")
|
||||
private Boolean againstInterestCalculationEnabled;
|
||||
|
||||
@Column(name = "day_wise_against_clearing_interest_rounding")
|
||||
private Boolean dayWiseAgainstClearingInterestRounding;
|
||||
|
||||
@Column(name = "interest_calculation_one_fourth_method")
|
||||
private String interestCalculationOneFourthMethod;
|
||||
|
||||
@Column(name = "against_clearing_interest_procedure_type")
|
||||
private String againstClearingInterestProcedureType;
|
||||
|
||||
@Column(name = "consider_debit_closing_amount_for_against_clearing")
|
||||
private Boolean considerDebitClosingAmountForAgainstClearing;
|
||||
|
||||
@Column(name = "interest_rounding_method")
|
||||
private String interestRoundingMethod;
|
||||
|
||||
@Column(name = "penalty_interest_calculation_enabled")
|
||||
private Boolean penaltyInterestCalculationEnabled;
|
||||
|
||||
@Column(name = "penalty_interest_calculation_method")
|
||||
private String penaltyInterestCalculationMethod;
|
||||
|
||||
@Column(name = "penalty_interest_procedure_number")
|
||||
private String penaltyInterestProcedureNumber;
|
||||
|
||||
@Column(name = "overdrawn_interest_calculation_method")
|
||||
private String overdrawnInterestCalculationMethod;
|
||||
|
||||
@Column(name = "calculate_overdrawn_interest_after_renewal")
|
||||
private Boolean calculateOverdrawnInterestAfterRenewal;
|
||||
|
||||
@Column(name = "interest_on_credit_balance")
|
||||
private Boolean interestOnCreditBalance;
|
||||
|
||||
@Column(name = "penalty_interest_date_different_than_regular_interest")
|
||||
private Boolean penaltyInterestDateDifferentThanRegularInterest;
|
||||
|
||||
@Column(name = "fixed_deposit_overdraft_certificate_sort_order")
|
||||
private String fixedDepositOverdraftCertificateSortOrder;
|
||||
|
||||
@Column(name = "use_document_submission_date_for_interest")
|
||||
private Boolean useDocumentSubmissionDateForInterest;
|
||||
|
||||
@Column(name = "loan_management_system_renewal_penalty_active")
|
||||
private Boolean loanManagementSystemRenewalPenaltyActive;
|
||||
|
||||
@Column(name = "minimum_normal_interest_amount")
|
||||
private BigDecimal minimumNormalInterestAmount;
|
||||
|
||||
@Column(name = "minimum_interest_calculation_method")
|
||||
private String minimumInterestCalculationMethod;
|
||||
|
||||
@Column(name = "minimum_against_clearing_interest_amount")
|
||||
private BigDecimal minimumAgainstClearingInterestAmount;
|
||||
|
||||
@Column(name = "limit_increase_upto_interest_amount_in_interest_calculation")
|
||||
private Boolean limitIncreaseUptoInterestAmountInInterestCalculation;
|
||||
|
||||
@Column(name = "minimum_penalty_interest_amount")
|
||||
private BigDecimal minimumPenaltyInterestAmount;
|
||||
|
||||
@Column(name = "days_for_limit_increase_upto_interest_amount")
|
||||
private Integer daysForLimitIncreaseUptoInterestAmount;
|
||||
|
||||
@Column(name = "additional_interest_rate_for_fixed_deposit_overdraft")
|
||||
private BigDecimal additionalInterestRateForFixedDepositOverdraft;
|
||||
|
||||
@Column(name = "consider_dd_payorder_in_against_clearing_interest_calculation")
|
||||
private Boolean considerDdPayorderInAgainstClearingInterestCalculation;
|
||||
|
||||
@Column(name = "grace_days_after_renew_date")
|
||||
private Integer graceDaysAfterRenewDate;
|
||||
|
||||
@Column(name = "apply_undebited_interest_concept_enabled")
|
||||
private Boolean applyUndebitedInterestConceptEnabled;
|
||||
|
||||
@Column(name = "interest_register_print_format_type")
|
||||
private String interestRegisterPrintFormatType;
|
||||
|
||||
@Column(name = "normal_grace_days_after_overdue")
|
||||
private Integer normalGraceDaysAfterOverdue;
|
||||
|
||||
@Column(name = "allow_against_clearing_entry")
|
||||
private Boolean allowAgainstClearingEntry;
|
||||
|
||||
@Column(name = "allow_no_balance_entry")
|
||||
private Boolean allowNoBalanceEntry;
|
||||
|
||||
@Column(name = "fd_od_penalty_interest_combined_with_normal_interest")
|
||||
private Boolean fixedDepositOverdraftPenaltyInterestCombinedWithNormalInterest;
|
||||
|
||||
@Column(name = "allow_no_balance_entry_with_password")
|
||||
private Boolean allowNoBalanceEntryWithPassword;
|
||||
|
||||
@Column(name = "undebited_simple_interest_account_wise")
|
||||
private Boolean undebitedSimpleInterestAccountWise;
|
||||
|
||||
@Column(name = "daily_interest_calculation_enabled")
|
||||
private Boolean dailyInterestCalculationEnabled;
|
||||
|
||||
@Column(name = "daily_interest_calculation_start_date")
|
||||
private String dailyInterestCalculationStartDate;
|
||||
|
||||
@Column(name = "non_performing_asset_penal_interest_rate_update")
|
||||
private Boolean nonPerformingAssetPenalInterestRateUpdate;
|
||||
|
||||
@Column(name = "non_performing_asset_penal_interest_rate")
|
||||
private BigDecimal nonPerformingAssetPenalInterestRate;
|
||||
|
||||
@Column(name = "fd_od_penal_interest_rate_update_in_branch_process")
|
||||
private Boolean fixedDepositOverdraftPenalInterestRateUpdateInBranchProcess;
|
||||
|
||||
@Column(name = "add_penal_interest_rate")
|
||||
private BigDecimal addPenalInterestRate;
|
||||
|
||||
@Column(name = "atyp14_simple_interest_enabled")
|
||||
private Boolean atyp14SimpleInterestEnabled;
|
||||
|
||||
@Column(name = "fixed_deposit_overdraft_margin_type")
|
||||
private String fixedDepositOverdraftMarginType;
|
||||
|
||||
@Column(name = "check_master_detail_edited_passing_pending_enabled")
|
||||
private Boolean checkMasterDetailEditedPassingPendingEnabled;
|
||||
|
||||
@Column(name = "credit_debit_interest_calculation_separate_enabled")
|
||||
private Boolean creditDebitInterestCalculationSeparateEnabled;
|
||||
|
||||
@Column(name = "on_time_interest_provision_enabled")
|
||||
private Boolean onTimeInterestProvisionEnabled;
|
||||
|
||||
@Column(name = "check_against_clearing_enabled")
|
||||
private Boolean checkAgainstClearingEnabled;
|
||||
|
||||
@Column(name = "gst_on_penalty_enabled")
|
||||
private Boolean gstOnPenaltyEnabled;
|
||||
|
||||
@Column(name = "penalty_interest_grace_days")
|
||||
private Integer penaltyInterestGraceDays;
|
||||
|
||||
@Column(name = "overdrawn_interest_rate")
|
||||
private BigDecimal overdrawnInterestRate;
|
||||
|
||||
@Column(name = "calculate_daily_limit_enhancement_tod_enabled")
|
||||
private Boolean calculateDailyLimitEnhancementTodEnabled;
|
||||
|
||||
@Column(name = "fixed_deposit_overdraft_multiple_interest_rate_enabled")
|
||||
private Boolean fixedDepositOverdraftMultipleInterestRateEnabled;
|
||||
|
||||
@Column(name = "grace_days_after_overdue_for_moratorium")
|
||||
private Integer graceDaysAfterOverdueForMoratorium;
|
||||
|
||||
// ---- Credit Bureau Settings (CIBIL) (8) ----------------------------
|
||||
|
||||
@Column(name = "cibil_account_type")
|
||||
private String cibilAccountType;
|
||||
|
||||
@Column(name = "cibil_commercial_account_type")
|
||||
private String cibilCommercialAccountType;
|
||||
|
||||
@Column(name = "highmark_account_type")
|
||||
private String highmarkAccountType;
|
||||
|
||||
@Column(name = "highmark_commercial_account_type")
|
||||
private String highmarkCommercialAccountType;
|
||||
|
||||
@Column(name = "experian_account_type")
|
||||
private String experianAccountType;
|
||||
|
||||
@Column(name = "experian_commercial_account_type")
|
||||
private String experianCommercialAccountType;
|
||||
|
||||
@Column(name = "equifax_account_type")
|
||||
private String equifaxAccountType;
|
||||
|
||||
@Column(name = "equifax_commercial_account_type")
|
||||
private String equifaxCommercialAccountType;
|
||||
|
||||
// ---- RBI Compliance & Product Category (6) -------------------------
|
||||
|
||||
@Column(name = "loan_product_category")
|
||||
private String loanProductCategory;
|
||||
|
||||
@Column(name = "penal_charge_method")
|
||||
private String penalChargeMethod;
|
||||
|
||||
@Column(name = "is_floating_rate")
|
||||
private Boolean isFloatingRate;
|
||||
|
||||
@Column(name = "foreclosure_charges_applicable")
|
||||
private Boolean foreclosureChargesApplicable;
|
||||
|
||||
@Column(name = "key_fact_statement_enabled")
|
||||
private Boolean keyFactStatementEnabled;
|
||||
|
||||
@Column(name = "annual_percentage_rate_calculation_enabled")
|
||||
private Boolean annualPercentageRateCalculationEnabled;
|
||||
|
||||
// ---- Channel & Transaction Limits (23) ------------------------------
|
||||
|
||||
@Column(name = "is_mobile_app_enabled")
|
||||
private Boolean isMobileAppEnabled;
|
||||
|
||||
@Column(name = "is_atm_enabled")
|
||||
private Boolean isAtmEnabled;
|
||||
|
||||
@Column(name = "atm_yearly_charge_enabled")
|
||||
private Boolean atmYearlyChargeEnabled;
|
||||
|
||||
@Column(name = "atm_minimum_balance")
|
||||
private BigDecimal atmMinimumBalance;
|
||||
|
||||
@Column(name = "email_active_enabled")
|
||||
private Boolean emailActiveEnabled;
|
||||
|
||||
@Column(name = "is_imps_enabled")
|
||||
private Boolean isImpsEnabled;
|
||||
|
||||
@Column(name = "is_upi_enabled")
|
||||
private Boolean isUpiEnabled;
|
||||
|
||||
@Column(name = "is_pos_enabled")
|
||||
private Boolean isPosEnabled;
|
||||
|
||||
@Column(name = "is_bbps_enabled")
|
||||
private Boolean isBbpsEnabled;
|
||||
|
||||
@Column(name = "inter_bank_limit_per_day")
|
||||
private BigDecimal interBankLimitPerDay;
|
||||
|
||||
@Column(name = "inter_bank_limit_per_transaction")
|
||||
private BigDecimal interBankLimitPerTransaction;
|
||||
|
||||
@Column(name = "neft_rtgs_limit_per_day")
|
||||
private BigDecimal neftRtgsLimitPerDay;
|
||||
|
||||
@Column(name = "neft_rtgs_limit_per_transaction")
|
||||
private BigDecimal neftRtgsLimitPerTransaction;
|
||||
|
||||
@Column(name = "neft_cutoff_limit")
|
||||
private BigDecimal neftCutoffLimit;
|
||||
|
||||
@Column(name = "rtgs_cutoff_limit")
|
||||
private BigDecimal rtgsCutoffLimit;
|
||||
|
||||
@Column(name = "neft_rtgs_minimum_balance")
|
||||
private BigDecimal neftRtgsMinimumBalance;
|
||||
|
||||
@Column(name = "is_charge_required_neft_rtgs_cbs")
|
||||
private Boolean isChargeRequiredNeftRtgsCbs;
|
||||
|
||||
@Column(name = "is_charge_required_neft_rtgs_mobile")
|
||||
private Boolean isChargeRequiredNeftRtgsMobile;
|
||||
|
||||
@Column(name = "imps_limit_per_day")
|
||||
private BigDecimal impsLimitPerDay;
|
||||
|
||||
@Column(name = "imps_limit_per_transaction")
|
||||
private BigDecimal impsLimitPerTransaction;
|
||||
|
||||
@Column(name = "imps_limit_per_month")
|
||||
private BigDecimal impsLimitPerMonth;
|
||||
|
||||
@Column(name = "imps_min_limit")
|
||||
private BigDecimal impsMinLimit;
|
||||
|
||||
@Column(name = "imps_monthly_transaction_count")
|
||||
private Integer impsMonthlyTransactionCount;
|
||||
|
||||
// ---- POS Facility & ATM CSV Settings (10) ---------------------------
|
||||
|
||||
@Column(name = "max_per_transaction_limit_atm")
|
||||
private BigDecimal maxPerTransactionLimitAtm;
|
||||
|
||||
@Column(name = "max_day_transaction_limit_atm")
|
||||
private BigDecimal maxDayTransactionLimitAtm;
|
||||
|
||||
@Column(name = "max_per_transaction_limit_pos")
|
||||
private BigDecimal maxPerTransactionLimitPos;
|
||||
|
||||
@Column(name = "max_day_transaction_limit_pos")
|
||||
private BigDecimal maxDayTransactionLimitPos;
|
||||
|
||||
@Column(name = "max_per_transaction_limit_ecom")
|
||||
private BigDecimal maxPerTransactionLimitEcom;
|
||||
|
||||
@Column(name = "max_day_transaction_limit_ecom")
|
||||
private BigDecimal maxDayTransactionLimitEcom;
|
||||
|
||||
@Column(name = "max_per_transaction_limit_upi")
|
||||
private BigDecimal maxPerTransactionLimitUpi;
|
||||
|
||||
@Column(name = "max_day_transaction_limit_upi")
|
||||
private BigDecimal maxDayTransactionLimitUpi;
|
||||
|
||||
@Column(name = "atm_csv_product_code")
|
||||
private String atmCsvProductCode;
|
||||
|
||||
@Column(name = "atm_csv_type_code")
|
||||
private String atmCsvTypeCode;
|
||||
|
||||
// ---- Auto Interest Post Parameters (4) -----------------------------
|
||||
|
||||
@Column(name = "auto_interest_post_type")
|
||||
private String autoInterestPostType;
|
||||
|
||||
@Column(name = "auto_interest_post_when")
|
||||
private String autoInterestPostWhen;
|
||||
|
||||
@Column(name = "auto_interest_post_fix_day")
|
||||
private Integer autoInterestPostFixDay;
|
||||
|
||||
@Column(name = "auto_last_interest_date")
|
||||
private String autoLastInterestDate;
|
||||
|
||||
// ---- Foreclosure / Early Account Closure (3) -----------------------
|
||||
|
||||
@Column(name = "calculate_early_account_close_charge")
|
||||
private Boolean calculateEarlyAccountCloseCharge;
|
||||
|
||||
@Column(name = "early_account_close_charge")
|
||||
private BigDecimal earlyAccountCloseCharge;
|
||||
|
||||
@Column(name = "early_account_close_period_in_months")
|
||||
private Integer earlyAccountClosePeriodInMonths;
|
||||
|
||||
// ---- Terms step (3) ------------------------------------------------
|
||||
|
||||
@Column(name = "debit_balance_allow")
|
||||
private Boolean debitBalanceAllow;
|
||||
|
||||
@Column(name = "allow_debit_trans_after_due_date")
|
||||
private Boolean allowDebitTransAfterDueDate;
|
||||
|
||||
@Column(name = "branch_level_account_type")
|
||||
private Boolean branchLevelAccountType;
|
||||
|
||||
// ---- legacy cheque / standing instruction / minimum balance charges (24)
|
||||
|
||||
@Column(name = "cheque_book_charge_enabled")
|
||||
private Boolean chequeBookChargeEnabled;
|
||||
|
||||
@Column(name = "cheque_return_charge_enabled")
|
||||
private Boolean chequeReturnChargeEnabled;
|
||||
|
||||
@Column(name = "ic_charge_debit_enabled")
|
||||
private Boolean icChargeDebitEnabled;
|
||||
|
||||
@Column(name = "cash_bundle_charge_enabled")
|
||||
private Boolean cashBundleChargeEnabled;
|
||||
|
||||
@Column(name = "cash_bundle_charge_with_pan_limit")
|
||||
private BigDecimal cashBundleChargeWithPanLimit;
|
||||
|
||||
@Column(name = "per_cheque_entry_charge")
|
||||
private BigDecimal perChequeEntryCharge;
|
||||
|
||||
@Column(name = "per_cheque_entry_service_charge")
|
||||
private BigDecimal perChequeEntryServiceCharge;
|
||||
|
||||
@Column(name = "per_inward_cheque_entry_charge")
|
||||
private BigDecimal perInwardChequeEntryCharge;
|
||||
|
||||
@Column(name = "per_outward_cheque_entry_charge")
|
||||
private BigDecimal perOutwardChequeEntryCharge;
|
||||
|
||||
@Column(name = "creditor_standing_instruction_fail_charge")
|
||||
private BigDecimal creditorStandingInstructionFailCharge;
|
||||
|
||||
@Column(name = "debtor_standing_instruction_fail_charge")
|
||||
private BigDecimal debtorStandingInstructionFailCharge;
|
||||
|
||||
@Column(name = "minimum_balance_checking_type")
|
||||
private String minimumBalanceCheckingType;
|
||||
|
||||
@Column(name = "auto_minimum_balance_charge")
|
||||
private Boolean autoMinimumBalanceCharge;
|
||||
|
||||
@Column(name = "calculate_daily_minimum_balance_charges")
|
||||
private Boolean calculateDailyMinimumBalanceCharges;
|
||||
|
||||
@Column(name = "minimum_balance_charge_enabled")
|
||||
private Boolean minimumBalanceChargeEnabled;
|
||||
|
||||
@Column(name = "minimum_balance_charge_amount")
|
||||
private BigDecimal minimumBalanceChargeAmount;
|
||||
|
||||
@Column(name = "minimum_balance_charge_for_cheque_issue")
|
||||
private BigDecimal minimumBalanceChargeForChequeIssue;
|
||||
|
||||
@Column(name = "minimum_balance_charge_method")
|
||||
private String minimumBalanceChargeMethod;
|
||||
|
||||
@Column(name = "months_after_min_balance_charge_calculate")
|
||||
private Integer monthsAfterMinBalanceChargeCalculate;
|
||||
|
||||
@Column(name = "for_cheque_issue")
|
||||
private BigDecimal forChequeIssue;
|
||||
|
||||
@Column(name = "for_cheque_issue_avg")
|
||||
private BigDecimal forChequeIssueAvg;
|
||||
|
||||
@Column(name = "for_withdrawal_slip")
|
||||
private BigDecimal forWithdrawalSlip;
|
||||
|
||||
@Column(name = "for_withdrawal_slip_avg")
|
||||
private BigDecimal forWithdrawalSlipAvg;
|
||||
|
||||
@Column(name = "calculate_daily_against_clearing_charge")
|
||||
private Boolean calculateDailyAgainstClearingCharge;
|
||||
|
||||
// ---- custom GL account mappings (14) --------------------------------
|
||||
|
||||
@Column(name = "int_receivables_gl_account_id")
|
||||
private Long intReceivablesGlAccountId;
|
||||
|
||||
@Column(name = "int_payable_gl_account_id")
|
||||
private Long intPayableGlAccountId;
|
||||
|
||||
@Column(name = "deaf_int_payable_gl_account_id")
|
||||
private Long deafIntPayableGlAccountId;
|
||||
|
||||
@Column(name = "int_overdue_reserve_account_id")
|
||||
private Long intOverdueReserveAccountId;
|
||||
|
||||
@Column(name = "undebited_interest_account_id")
|
||||
private Long undebitedInterestAccountId;
|
||||
|
||||
@Column(name = "penal_int_cr_gl_account_id")
|
||||
private Long penalIntCrGlAccountId;
|
||||
|
||||
@Column(name = "rd_matured_gl_account_id")
|
||||
private Long rdMaturedGlAccountId;
|
||||
|
||||
@Column(name = "gl_account_id")
|
||||
private Long glAccountId;
|
||||
|
||||
@Column(name = "ic_charge_gl_account_id")
|
||||
private Long icChargeGlAccountId;
|
||||
|
||||
@Column(name = "inoperative_gl_account_id")
|
||||
private Long inoperativeGlAccountId;
|
||||
|
||||
@Column(name = "credit_balance_liability_gl_account_id")
|
||||
private Long creditBalanceLiabilityGlAccountId;
|
||||
|
||||
@Column(name = "credit_balance_asset_gl_account_id")
|
||||
private Long creditBalanceAssetGlAccountId;
|
||||
|
||||
@Column(name = "overdue_accounts_gl_account_id")
|
||||
private Long overdueAccountsGlAccountId;
|
||||
|
||||
@Column(name = "rebate_gl_account_id")
|
||||
private Long rebateGlAccountId;
|
||||
|
||||
public LoanProductCbsExt(final LoanProduct loanProduct) {
|
||||
this.loanProduct = loanProduct;
|
||||
this.loanProductId = loanProduct.getId();
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanproduct.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface LoanProductCbsExtRepository extends JpaRepository<LoanProductCbsExt, Long> {
|
||||
|
||||
/**
|
||||
* A product created before this table existed - or one saved without any legacy field filled in - has
|
||||
* no row here, so callers must handle the empty case rather than assuming one exists.
|
||||
*/
|
||||
Optional<LoanProductCbsExt> findByLoanProductId(Long loanProductId);
|
||||
}
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanproduct.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
|
||||
/**
|
||||
* One row of the legacy "Interest Rate Detail" grid on the loan product form.
|
||||
*
|
||||
* The grid is a fixed four rows - Normal Debit, Normal Credit, Against Clearing and Penalty - each
|
||||
* carrying a Normal and a Special min/max rate plus the period they apply over. It is a child table
|
||||
* rather than twenty-four columns on {@link LoanProductCbsExt} because the interest type reads far
|
||||
* better as data than as part of a column name: against_clearing_special_max_rate and its siblings
|
||||
* are almost unreadable, and any new interest type would mean another migration.
|
||||
*
|
||||
* The rows are fixed today, so {@link #INTEREST_TYPES} is the full set and the table carries a unique
|
||||
* constraint on (product, interest type) - a replayed save updates in place instead of doubling the
|
||||
* grid.
|
||||
*/
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@Table(name = "m_product_loan_cbs_interest_rate", uniqueConstraints = {
|
||||
@UniqueConstraint(columnNames = { "loan_product_id", "interest_type" }, name = "mplcir_unq_product_interest_type") })
|
||||
public class LoanProductCbsInterestRate extends AbstractPersistableCustom<Long> {
|
||||
|
||||
/** The grid's rows, in the order the form shows them. */
|
||||
public static final String[] INTEREST_TYPES = { "Normal Debit", "Normal Credit", "Against Clearing", "Penalty" };
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "loan_product_id", nullable = false)
|
||||
private LoanProduct loanProduct;
|
||||
|
||||
@Column(name = "interest_type", nullable = false, length = 30)
|
||||
private String interestType;
|
||||
|
||||
@Column(name = "calculation")
|
||||
private Boolean calculation;
|
||||
|
||||
@Column(name = "normal_min_rate", precision = 9, scale = 6)
|
||||
private BigDecimal normalMinRate;
|
||||
|
||||
@Column(name = "normal_max_rate", precision = 9, scale = 6)
|
||||
private BigDecimal normalMaxRate;
|
||||
|
||||
@Column(name = "special_min_rate", precision = 9, scale = 6)
|
||||
private BigDecimal specialMinRate;
|
||||
|
||||
@Column(name = "special_max_rate", precision = 9, scale = 6)
|
||||
private BigDecimal specialMaxRate;
|
||||
|
||||
@Column(name = "period", length = 20)
|
||||
private String period;
|
||||
|
||||
public LoanProductCbsInterestRate(final LoanProduct loanProduct, final String interestType) {
|
||||
this.loanProduct = loanProduct;
|
||||
this.interestType = interestType;
|
||||
}
|
||||
|
||||
/** True when the officer left this row untouched, so it need not be persisted. */
|
||||
public boolean isEmpty() {
|
||||
return !Boolean.TRUE.equals(this.calculation) && this.normalMinRate == null && this.normalMaxRate == null
|
||||
&& this.specialMinRate == null && this.specialMaxRate == null && (this.period == null || this.period.isBlank());
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
* Copyright since 2025 Mifos Initiative
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanproduct.domain;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface LoanProductCbsInterestRateRepository extends JpaRepository<LoanProductCbsInterestRate, Long> {
|
||||
|
||||
List<LoanProductCbsInterestRate> findByLoanProductIdOrderById(Long loanProductId);
|
||||
|
||||
LoanProductCbsInterestRate findByLoanProductIdAndInterestType(Long loanProductId, String interestType);
|
||||
}
|
||||
+16
-3
@@ -357,9 +357,14 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
|
||||
accountsSummary.append("curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ");
|
||||
accountsSummary.append("curr.display_symbol as currencyDisplaySymbol, ");
|
||||
accountsSummary.append("sa.product_id as productId, p.name as productName, p.short_name as shortProductName, ");
|
||||
accountsSummary.append("sa.deposit_type_enum as depositType ");
|
||||
accountsSummary.append("sa.deposit_type_enum as depositType, ");
|
||||
// Renewal-chain identity for Fixed Deposits: the stable customer-facing FD number and
|
||||
// this row's cycle within the chain, so a client's account list can collapse a renewed
|
||||
// FD into one entry rather than listing every term as a separate account.
|
||||
accountsSummary.append("dtp.fd_account_number as fdAccountNumber, dtp.renewal_cycle_no as renewalCycleNo ");
|
||||
accountsSummary.append("from m_savings_account sa ");
|
||||
accountsSummary.append("join m_savings_product as p on p.id = sa.product_id ");
|
||||
accountsSummary.append("left join m_deposit_account_term_and_preclosure dtp on dtp.savings_account_id = sa.id ");
|
||||
accountsSummary.append("join m_currency curr on curr.code = sa.currency_code ");
|
||||
accountsSummary.append("left join m_appuser sbu on sbu.id = sa.submittedon_userid ");
|
||||
accountsSummary.append("left join m_appuser rbu on rbu.id = sa.rejectedon_userid ");
|
||||
@@ -453,9 +458,15 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
|
||||
approvedByUsername, approvedByFirstname, approvedByLastname, activatedOnDate, activatedByUsername, activatedByFirstname,
|
||||
activatedByLastname, closedOnDate, closedByUsername, closedByFirstname, closedByLastname);
|
||||
|
||||
// Null for a savings/current account and for an FD opened before this column existed;
|
||||
// callers fall back to accountNo, so an FD that has never been renewed still reads as
|
||||
// its own FD number.
|
||||
final String fdAccountNumber = rs.getString("fdAccountNumber");
|
||||
final Integer renewalCycleNo = JdbcSupport.getInteger(rs, "renewalCycleNo");
|
||||
|
||||
return new SavingsAccountSummaryData(id, accountNo, externalId, productId, productName, shortProductName, status, currency,
|
||||
accountBalance, onHoldFunds, onHoldAmount, availableBalance, accountTypeData, timeline, depositTypeData, subStatus,
|
||||
lastActiveTransactionDate);
|
||||
lastActiveTransactionDate, fdAccountNumber, renewalCycleNo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,8 +578,10 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
|
||||
|
||||
final EnumOptionData depositTypeData = SavingsEnumerations.depositType(400);
|
||||
|
||||
// Current accounts have no deposit term, so no FD renewal chain to report.
|
||||
return new SavingsAccountSummaryData(id, accountNo, externalId, productId, productName, shortProductName, status, currency,
|
||||
accountBalance, onHoldFunds, null, accountBalance, accountTypeData, timeline, depositTypeData, subStatus, activatedOnDate);
|
||||
accountBalance, onHoldFunds, null, accountBalance, accountTypeData, timeline, depositTypeData, subStatus, activatedOnDate,
|
||||
null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-9
@@ -107,7 +107,6 @@ import org.apache.fineract.portfolio.loanproduct.exception.LoanProductNotFoundEx
|
||||
import org.apache.fineract.portfolio.loanproduct.productmix.data.ProductMixData;
|
||||
import org.apache.fineract.portfolio.loanproduct.productmix.service.ProductMixReadPlatformService;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformService;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductCbsExtService;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData;
|
||||
import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadService;
|
||||
@@ -172,7 +171,6 @@ public class LoanProductsApiResource {
|
||||
private final ConfigurationDomainService configurationDomainService;
|
||||
private final DelinquencyReadPlatformService delinquencyReadPlatformService;
|
||||
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||
private final LoanProductCbsExtService loanProductCbsExtService;
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@@ -386,13 +384,6 @@ public class LoanProductsApiResource {
|
||||
if (settings.isTemplate()) {
|
||||
loanProduct = handleTemplate(loanProduct);
|
||||
}
|
||||
|
||||
// Legacy "Account Type Creation" fields, so the edit form can be repopulated with what was saved.
|
||||
// Set here rather than in the read service because handleTemplate above returns a fresh
|
||||
// LoanProductData built by a copy constructor, which would not carry these across.
|
||||
loanProduct.setCbsExtensions(this.loanProductCbsExtService.retrieveAsMap(productId));
|
||||
loanProduct.setInterestRateDetail(this.loanProductCbsExtService.retrieveInterestRateDetail(productId));
|
||||
|
||||
return this.toApiJsonSerializer.serialize(settings, loanProduct, LOAN_PRODUCT_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
|
||||
+4
-18
@@ -77,7 +77,6 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMe
|
||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanSupportedInterestRefundTypes;
|
||||
import org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType;
|
||||
import org.apache.fineract.portfolio.loanproduct.exception.EqualAmortizationUnsupportedFeatureException;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductCbsExtService;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@@ -213,12 +212,6 @@ public final class LoanProductDataValidator {
|
||||
LoanProductConstants.ALLOW_FULL_TERM_FOR_TRANCHE_PARAM_NAME //
|
||||
));
|
||||
|
||||
static {
|
||||
// The legacy "Account Type Creation" fields are persisted by LoanProductCbsExtService, which owns
|
||||
// the authoritative list of their names -- added here rather than restated so the two cannot drift.
|
||||
SUPPORTED_PARAMETERS.addAll(Arrays.asList(LoanProductCbsExtService.CBS_PARAMETERS));
|
||||
}
|
||||
|
||||
private static final String[] SUPPORTED_LOAN_CONFIGURABLE_ATTRIBUTES = { LoanProductConstants.amortizationTypeParamName,
|
||||
LoanProductConstants.interestTypeParamName, LoanProductConstants.transactionProcessingStrategyCodeParamName,
|
||||
LoanProductConstants.interestCalculationPeriodTypeParamName, LoanProductConstants.inArrearsToleranceParamName,
|
||||
@@ -242,14 +235,8 @@ public final class LoanProductDataValidator {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
// TEMPORARILY DISABLED while the legacy "Account Type Creation" fields are being wired through this
|
||||
// endpoint. SUPPORTED_PARAMETERS above already lists them, so re-enabling this is a one-line revert.
|
||||
//
|
||||
// Note what is lost until then: an unrecognised parameter is now accepted and silently ignored
|
||||
// instead of returning 400. A misspelt field name will therefore look like it saved and simply not
|
||||
// appear, so check the column actually changed rather than trusting a 200.
|
||||
// final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
// this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(LOANPRODUCT);
|
||||
@@ -1349,9 +1336,8 @@ public final class LoanProductDataValidator {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
// TEMPORARILY DISABLED -- see the same note on validateForCreate above.
|
||||
// final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
// this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, SUPPORTED_PARAMETERS);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource(LOANPRODUCT);
|
||||
|
||||
-2117
File diff suppressed because it is too large
Load Diff
-14
@@ -97,7 +97,6 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
||||
private final CreditAllocationsJsonParser creditAllocationsJsonParser;
|
||||
private final LoanProductAssembler loanProductAssembler;
|
||||
private final LoanProductUpdateUtil loanProductUpdateUtil;
|
||||
private final LoanProductCbsExtService loanProductCbsExtService;
|
||||
private final LoanProductPaymentAllocationRuleMerger loanProductPaymentAllocationRuleMerger = new LoanProductPaymentAllocationRuleMerger();
|
||||
private final LoanProductCreditAllocationRuleMerger loanProductCreditAllocationRuleMerger = new LoanProductCreditAllocationRuleMerger();
|
||||
|
||||
@@ -142,11 +141,6 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
||||
|
||||
this.loanProductRepository.saveAndFlush(loanProduct);
|
||||
|
||||
// Legacy "Account Type Creation" fields, persisted in their own satellite table. Called after the
|
||||
// flush because the satellite row is keyed on the product's generated id. A request carrying none
|
||||
// of those parameters writes nothing.
|
||||
this.loanProductCbsExtService.saveOrUpdate(loanProduct, command);
|
||||
|
||||
// save accounting mappings
|
||||
this.accountMappingWritePlatformService.createLoanProductToGLAccountMapping(loanProduct.getId(), command);
|
||||
// check if the office specific products are enabled. If yes, then
|
||||
@@ -309,14 +303,6 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
||||
this.loanProductRepository.saveAndFlush(product);
|
||||
}
|
||||
|
||||
// Legacy "Account Type Creation" fields. Deliberately outside the changes check above: those
|
||||
// changes only track the standard product columns, so an edit that touched nothing but a legacy
|
||||
// field leaves the map empty and would otherwise be dropped.
|
||||
//
|
||||
// What it changed is folded into the same changes map, so the audit trail shows a per-field
|
||||
// diff for these exactly as it does for the standard ones rather than an empty change set.
|
||||
changes.putAll(this.loanProductCbsExtService.saveOrUpdate(product, command));
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withCommandId(command.commandId()) //
|
||||
.withEntityId(loanProductId) //
|
||||
|
||||
+2
-4
@@ -40,7 +40,6 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
|
||||
import org.apache.fineract.portfolio.loanproduct.serialization.LoanProductDataValidator;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformService;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanDropdownReadPlatformServiceImpl;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductCbsExtService;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformServiceImpl;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanProductWritePlatformService;
|
||||
@@ -83,12 +82,11 @@ public class LoanProductConfiguration {
|
||||
DelinquencyBucketRepository delinquencyBucketRepository,
|
||||
LoanRepaymentScheduleTransactionProcessorFactory loanRepaymentScheduleTransactionProcessorFactory,
|
||||
AdvancedPaymentAllocationsJsonParser advancedPaymentJsonParser, CreditAllocationsJsonParser creditAllocationsJsonParser,
|
||||
LoanProductAssembler loanProductAssembler, LoanProductUpdateUtil loanProductUpdateUtil,
|
||||
LoanProductCbsExtService loanProductCbsExtService) {
|
||||
LoanProductAssembler loanProductAssembler, LoanProductUpdateUtil loanProductUpdateUtil) {
|
||||
return new LoanProductWritePlatformServiceJpaRepositoryImpl(context, fromApiJsonDeserializer, loanProductRepository, aprCalculator,
|
||||
fundRepository, chargeRepository, rateRepository, accountMappingWritePlatformService, fineractEntityAccessUtil,
|
||||
floatingRateRepository, loanRepositoryWrapper, businessEventNotifierService, delinquencyBucketRepository,
|
||||
loanRepaymentScheduleTransactionProcessorFactory, advancedPaymentJsonParser, creditAllocationsJsonParser,
|
||||
loanProductAssembler, loanProductUpdateUtil, loanProductCbsExtService);
|
||||
loanProductAssembler, loanProductUpdateUtil);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -440,6 +440,9 @@ public class FixedDepositAccountsApiResource {
|
||||
} else if (is(commandParam, "prematureClose")) {
|
||||
final CommandWrapper commandRequest = builder.prematureCloseFixedDepositAccount(accountId).build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "payment")) {
|
||||
final CommandWrapper commandRequest = builder.paymentFixedDepositAccount(accountId).build();
|
||||
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
|
||||
} else if (is(commandParam, "calculatePrematureAmount")) {
|
||||
final JsonElement parsedQuery = this.fromJsonHelper.parse(apiRequestBodyAsJson);
|
||||
final JsonQuery query = JsonQuery.from(apiRequestBodyAsJson, parsedQuery, this.fromJsonHelper);
|
||||
@@ -453,7 +456,7 @@ public class FixedDepositAccountsApiResource {
|
||||
if (result == null) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam,
|
||||
new Object[] { "reject", "withdrawnByApplicant", "approve", "undoapproval", "activate", "calculateInterest",
|
||||
"postInterest", "close", "prematureClose", "calculatePrematureAmount" });
|
||||
"postInterest", "close", "prematureClose", "payment", "calculatePrematureAmount" });
|
||||
}
|
||||
|
||||
return this.toApiJsonSerializer.serialize(result);
|
||||
@@ -489,6 +492,8 @@ public class FixedDepositAccountsApiResource {
|
||||
DepositAccountData account = null;
|
||||
if (is(commandParam, "close")) {
|
||||
account = this.depositAccountReadPlatformService.retrieveOneWithClosureTemplate(DepositAccountType.FIXED_DEPOSIT, accountId);
|
||||
} else if (is(commandParam, "payment")) {
|
||||
account = this.depositAccountReadPlatformService.retrieveOneWithPaymentTemplate(DepositAccountType.FIXED_DEPOSIT, accountId);
|
||||
}
|
||||
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
|
||||
+18
@@ -366,6 +366,15 @@ public class DepositAccountDataValidator {
|
||||
"Withdraw Deposit is not a valid maturity instruction -- choose Transfer to Savings or a Reinvest option.");
|
||||
}
|
||||
|
||||
// Partial Reinvest needs a specific kept-amount decided at the moment of closure -- there is
|
||||
// nothing sensible to pre-commit to years in advance as a standing instruction, so it is only
|
||||
// ever chosen manually via the Payment action, never set here.
|
||||
if (depositRolloverId.equals(DepositAccountOnClosureType.PARTIAL_REINVEST.getValue())) {
|
||||
baseDataValidator.reset().parameter(maturityInstructionIdParamName).value(depositRolloverId).failWithCodeAndMessage(
|
||||
"maturity.instruction.partial.reinvest.not.allowed",
|
||||
"Partial Re-Invest is not a valid standing maturity instruction -- it can only be chosen manually at closure time.");
|
||||
}
|
||||
|
||||
if (depositRolloverId.equals(DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getValue())) {
|
||||
final Long transferToSavingsId = this.fromApiJsonHelper.extractLongNamed(transferToSavingsIdParamName, element);
|
||||
baseDataValidator.reset().parameter(transferToSavingsIdParamName).value(transferToSavingsId).notNull()
|
||||
@@ -529,6 +538,15 @@ public class DepositAccountDataValidator {
|
||||
"Withdraw Deposit is not a valid maturity instruction -- choose Transfer to Savings or a Reinvest option.");
|
||||
}
|
||||
|
||||
// Partial Reinvest needs a specific kept-amount decided at the moment of closure -- there is
|
||||
// nothing sensible to pre-commit to years in advance as a standing instruction, so it is only
|
||||
// ever chosen manually via the Payment action, never set here.
|
||||
if (depositRolloverId.equals(DepositAccountOnClosureType.PARTIAL_REINVEST.getValue())) {
|
||||
baseDataValidator.reset().parameter(maturityInstructionIdParamName).value(depositRolloverId).failWithCodeAndMessage(
|
||||
"maturity.instruction.partial.reinvest.not.allowed",
|
||||
"Partial Re-Invest is not a valid standing maturity instruction -- it can only be chosen manually at closure time.");
|
||||
}
|
||||
|
||||
if (depositRolloverId.equals(DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getValue())) {
|
||||
final Long transferToSavingsId = this.fromApiJsonHelper.extractLongNamed(transferToSavingsIdParamName, element);
|
||||
baseDataValidator.reset().parameter(transferToSavingsIdParamName).value(transferToSavingsId).notNull()
|
||||
|
||||
+83
-1
@@ -82,6 +82,13 @@ public class DepositAccountTransactionDataValidator {
|
||||
private static final Set<String> DEPOSIT_ACCOUNT_PRE_MATURE_CALCULATION_REQUEST_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(DepositsApiConstants.localeParamName, DepositsApiConstants.dateFormatParamName, closedOnDateParamName));
|
||||
|
||||
private static final Set<String> DEPOSIT_ACCOUNT_PAYMENT_REQUEST_DATA_PARAMETERS = new HashSet<>(
|
||||
Arrays.asList(DepositsApiConstants.localeParamName, DepositsApiConstants.dateFormatParamName, closedOnDateParamName,
|
||||
DepositsApiConstants.noteParamName, onAccountClosureIdParamName, paymentTypeIdParamName,
|
||||
transactionAccountNumberParamName, checkNumberParamName, routingCodeParamName, receiptNumberParamName,
|
||||
bankNumberParamName, DepositsApiConstants.transferDescriptionParamName, toSavingsAccountIdParamName,
|
||||
DepositsApiConstants.reinvestAmountParamName));
|
||||
|
||||
@Autowired
|
||||
public DepositAccountTransactionDataValidator(final FromJsonHelper fromApiJsonHelper) {
|
||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||
@@ -222,7 +229,15 @@ public class DepositAccountTransactionDataValidator {
|
||||
|
||||
if (onAccountClosureId != null) {
|
||||
final DepositAccountOnClosureType accountOnClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||
if (accountOnClosureType.isTransferToSavings()) {
|
||||
if (accountOnClosureType.isPartialReinvest()) {
|
||||
// Partial Re-Invest needs a kept-amount and a destination account that only the Payment
|
||||
// command collects, and only its handler implements. Neither the FD nor the RD closure
|
||||
// handler has a branch for it, so without this it would fall through to their terminal
|
||||
// "withdraw the whole balance" case and silently pay the deposit out in cash.
|
||||
baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId).failWithCode(
|
||||
"partial.reinvest.not.allowed",
|
||||
"Partial Re-Invest is only supported through the Payment action, not account closure");
|
||||
} else if (accountOnClosureType.isTransferToSavings()) {
|
||||
final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element);
|
||||
baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId)
|
||||
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName,
|
||||
@@ -247,6 +262,73 @@ public class DepositAccountTransactionDataValidator {
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the FD "Payment" command -- kept independent of {@link #validateClosing}, which stays exactly as-is
|
||||
* for Close/Premature Close, so this never changes either of their existing behavior. Unlike
|
||||
* {@code validateClosing}, reinvest is always allowed here (there is no {@code isPreMatureClose} restriction --
|
||||
* Payment is meant to work on an Active account too), and a new Partial Reinvest closure type needs its own
|
||||
* amount and destination-account rules.
|
||||
*/
|
||||
public void validatePayment(final JsonCommand command) {
|
||||
final String json = command.json();
|
||||
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, DEPOSIT_ACCOUNT_PAYMENT_REQUEST_DATA_PARAMETERS);
|
||||
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(DepositAccountType.FIXED_DEPOSIT.resourceName());
|
||||
|
||||
final JsonElement element = command.parsedJson();
|
||||
|
||||
final LocalDate closedOnDate = this.fromApiJsonHelper.extractLocalDateNamed(closedOnDateParamName, element);
|
||||
baseDataValidator.reset().parameter(closedOnDateParamName).value(closedOnDate).notNull();
|
||||
|
||||
final Integer onAccountClosureId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(onAccountClosureIdParamName, element);
|
||||
baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId).notBlank()
|
||||
.isOneOfTheseValues(DepositAccountOnClosureType.integerValues());
|
||||
|
||||
if (onAccountClosureId != null) {
|
||||
final DepositAccountOnClosureType accountOnClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||
if (accountOnClosureType.isWithdarwDeposit()) {
|
||||
baseDataValidator.reset().parameter(onAccountClosureIdParamName).value(onAccountClosureId).failWithCodeAndMessage(
|
||||
"withdraw.deposit.not.allowed.for.payment",
|
||||
"Withdraw Deposit is not supported via Payment -- choose Transfer to Savings or a Reinvest option.");
|
||||
}
|
||||
// Interest earned under Reinvest Principal Only has to leave the deposit somewhere -- the same
|
||||
// destination-account rule Transfer to Savings and Partial Reinvest already need.
|
||||
if (accountOnClosureType.isTransferToSavings() || accountOnClosureType.isPartialReinvest()
|
||||
|| accountOnClosureType.isReinvestPrincipal()) {
|
||||
final Long toSavingsAccountId = this.fromApiJsonHelper.extractLongNamed(toSavingsAccountIdParamName, element);
|
||||
baseDataValidator.reset().parameter(toSavingsAccountIdParamName).value(toSavingsAccountId)
|
||||
.cantBeBlankWhenParameterProvidedIs(onAccountClosureIdParamName, accountOnClosureType.getCode());
|
||||
}
|
||||
if (accountOnClosureType.isPartialReinvest()) {
|
||||
final BigDecimal reinvestAmount = this.fromApiJsonHelper
|
||||
.extractBigDecimalWithLocaleNamed(DepositsApiConstants.reinvestAmountParamName, element);
|
||||
baseDataValidator.reset().parameter(DepositsApiConstants.reinvestAmountParamName).value(reinvestAmount).notNull()
|
||||
.positiveAmount();
|
||||
}
|
||||
}
|
||||
|
||||
// Validate all string payment detail fields for max length
|
||||
final Integer paymentTypeId = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paymentTypeIdParamName, element);
|
||||
baseDataValidator.reset().parameter(paymentTypeIdParamName).value(paymentTypeId).ignoreIfNull().integerGreaterThanZero();
|
||||
final Set<String> paymentDetailParameters = new HashSet<>(Arrays.asList(transactionAccountNumberParamName, checkNumberParamName,
|
||||
routingCodeParamName, receiptNumberParamName, bankNumberParamName));
|
||||
for (final String paymentDetailParameterName : paymentDetailParameters) {
|
||||
final String paymentDetailParameterValue = this.fromApiJsonHelper.extractStringNamed(paymentDetailParameterName, element);
|
||||
baseDataValidator.reset().parameter(paymentDetailParameterName).value(paymentDetailParameterValue).ignoreIfNull()
|
||||
.notExceedingLengthOf(50);
|
||||
}
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
//
|
||||
|
||||
+29
-1
@@ -87,6 +87,7 @@ import org.apache.fineract.portfolio.group.exception.CenterNotActiveException;
|
||||
import org.apache.fineract.portfolio.group.exception.ClientNotInGroupException;
|
||||
import org.apache.fineract.portfolio.group.exception.GroupNotActiveException;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartFields;
|
||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetailAssembler;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType;
|
||||
@@ -97,9 +98,11 @@ import org.apache.fineract.portfolio.savings.SavingsInterestCalculationType;
|
||||
import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType;
|
||||
import org.apache.fineract.portfolio.savings.SavingsPostingInterestPeriodType;
|
||||
import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionDTO;
|
||||
import org.apache.fineract.portfolio.savings.data.FdInterestRateEffectiveData;
|
||||
import org.apache.fineract.portfolio.savings.exception.FixedDepositProductNotFoundException;
|
||||
import org.apache.fineract.portfolio.savings.exception.RecurringDepositProductNotFoundException;
|
||||
import org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException;
|
||||
import org.apache.fineract.portfolio.savings.service.FdBaseInterestRateReadPlatformService;
|
||||
import org.apache.fineract.useradministration.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -123,6 +126,7 @@ public class DepositAccountAssembler {
|
||||
|
||||
private final ExternalIdFactory externalIdFactory;
|
||||
private final SavingsAccountAssembler savingsAccountAssembler;
|
||||
private final FdBaseInterestRateReadPlatformService fdBaseInterestRateReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public DepositAccountAssembler(final SavingsAccountTransactionSummaryWrapper savingsAccountTransactionSummaryWrapper,
|
||||
@@ -134,7 +138,8 @@ public class DepositAccountAssembler {
|
||||
final RecurringDepositProductRepository recurringDepositProductRepository,
|
||||
final AccountTransfersReadPlatformService accountTransfersReadPlatformService, final PlatformSecurityContext context,
|
||||
final PaymentDetailAssembler paymentDetailAssembler, ExternalIdFactory externalIdFactory,
|
||||
final SavingsAccountAssembler savingsAccountAssembler) {
|
||||
final SavingsAccountAssembler savingsAccountAssembler,
|
||||
final FdBaseInterestRateReadPlatformService fdBaseInterestRateReadPlatformService) {
|
||||
|
||||
this.savingsAccountTransactionSummaryWrapper = savingsAccountTransactionSummaryWrapper;
|
||||
this.clientRepository = clientRepository;
|
||||
@@ -151,6 +156,7 @@ public class DepositAccountAssembler {
|
||||
this.paymentDetailAssembler = paymentDetailAssembler;
|
||||
this.externalIdFactory = externalIdFactory;
|
||||
this.savingsAccountAssembler = savingsAccountAssembler;
|
||||
this.fdBaseInterestRateReadPlatformService = fdBaseInterestRateReadPlatformService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,6 +328,28 @@ public class DepositAccountAssembler {
|
||||
accountChart = DepositAccountInterestRateChart.from(productChart);
|
||||
}
|
||||
|
||||
// A new FD priced from its product's own chart never carries a senior-citizen premium -- that
|
||||
// concept exists only on the CBS Base Interest Rate master. So whenever staff hasn't picked a
|
||||
// specific chart, price the account from that master's currently active version instead (the same
|
||||
// one the Base Interest Rates screen shows and renewals already use), so a senior-citizen FD shows
|
||||
// its premium from day one rather than only after its first renewal. RD is unaffected: this only
|
||||
// runs when depositAccountType.isFixedDeposit(), and it's a no-op wherever no active base-rate
|
||||
// version exists for the product's FD type, in which case the product's own chart above stands.
|
||||
if (depositAccountType.isFixedDeposit() && accountChart != null && !command.parameterExists(chartIdParamName)
|
||||
&& product instanceof FixedDepositProduct) {
|
||||
final String fdType = ((FixedDepositProduct) product).getFdType();
|
||||
if (fdType != null) {
|
||||
final FdInterestRateEffectiveData activeBaseRates = this.fdBaseInterestRateReadPlatformService
|
||||
.retrieveActiveInterestRatesByType(fdType).stream().findFirst().orElse(null);
|
||||
if (activeBaseRates != null && activeBaseRates.getSlabs() != null && !activeBaseRates.getSlabs().isEmpty()) {
|
||||
final InterestRateChartFields baseChartFields = DepositAccountDomainServiceJpa.baseChartFieldsOf(activeBaseRates);
|
||||
final Collection<DepositAccountInterestRateChart.SlabSnapshot> baseChartSlabs = DepositAccountDomainServiceJpa
|
||||
.baseChartSlabsOf(activeBaseRates, product.currency().getCode());
|
||||
accountChart.refreshFromSlabSnapshots(baseChartFields, baseChartSlabs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean withHoldTax = product.withHoldTax();
|
||||
if (command.parameterExists(withHoldTaxParamName)) {
|
||||
withHoldTax = command.booleanPrimitiveValueOfParameterNamed(withHoldTaxParamName);
|
||||
|
||||
+11
@@ -35,6 +35,14 @@ public interface DepositAccountDomainService {
|
||||
SavingsAccountTransaction handleFDDeposit(FixedDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
|
||||
BigDecimal transactionAmount, PaymentDetail paymentDetail);
|
||||
|
||||
/**
|
||||
* As above, but lets the caller declare the deposit as an internal account-to-account movement rather
|
||||
* than cash taken over the counter. Used by reinvestment on maturity, where the funds come straight
|
||||
* from the matured deposit and must post against the transfer-suspense GL instead of cash/vault.
|
||||
*/
|
||||
SavingsAccountTransaction handleFDDeposit(FixedDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
|
||||
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isAccountTransfer);
|
||||
|
||||
SavingsAccountTransaction handleRDDeposit(RecurringDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
|
||||
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction);
|
||||
|
||||
@@ -56,4 +64,7 @@ public interface DepositAccountDomainService {
|
||||
|
||||
Long handleRDAccountPreMatureClosure(RecurringDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
|
||||
Map<String, Object> changes);
|
||||
|
||||
Long handleFDAccountPayment(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
|
||||
Map<String, Object> changes);
|
||||
}
|
||||
|
||||
+617
-17
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.portfolio.savings.domain;
|
||||
|
||||
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.onAccountClosureIdParamName;
|
||||
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.reinvestAmountParamName;
|
||||
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.toSavingsAccountIdParamName;
|
||||
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.transferDescriptionParamName;
|
||||
|
||||
@@ -26,6 +27,9 @@ import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -55,12 +59,18 @@ import org.apache.fineract.portfolio.calendar.domain.CalendarInstanceRepository;
|
||||
import org.apache.fineract.portfolio.calendar.domain.CalendarType;
|
||||
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
|
||||
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartFields;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabFields;
|
||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountType;
|
||||
import org.apache.fineract.portfolio.savings.DepositsApiConstants;
|
||||
import org.apache.fineract.portfolio.savings.SavingsApiConstants;
|
||||
import org.apache.fineract.portfolio.savings.SavingsPeriodFrequencyType;
|
||||
import org.apache.fineract.portfolio.savings.SavingsTransactionBooleanValues;
|
||||
import org.apache.fineract.portfolio.savings.data.FdInterestRateEffectiveData;
|
||||
import org.apache.fineract.portfolio.savings.data.FdInterestRateSlabData;
|
||||
import org.apache.fineract.portfolio.savings.service.FdBaseInterestRateReadPlatformService;
|
||||
import org.apache.fineract.portfolio.savings.service.SavingsAccountDomainService;
|
||||
import org.apache.fineract.useradministration.domain.AppUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -80,13 +90,28 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
private final AccountNumberFormatRepositoryWrapper accountNumberFormatRepository;
|
||||
private final CalendarInstanceRepository calendarInstanceRepository;
|
||||
private final ExternalIdFactory externalIdFactory;
|
||||
private final FixedDepositRenewalHistoryRepository fixedDepositRenewalHistoryRepository;
|
||||
private final FixedDepositRenewalChartSlabHistoryRepository fixedDepositRenewalChartSlabHistoryRepository;
|
||||
private final FdBaseInterestRateReadPlatformService fdBaseInterestRateReadPlatformService;
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public SavingsAccountTransaction handleWithdrawal(final SavingsAccount account, final DateTimeFormatter fmt,
|
||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
||||
final boolean applyWithdrawFee, final boolean isRegularTransaction) {
|
||||
boolean isAccountTransfer = false;
|
||||
final boolean isAccountTransfer = false;
|
||||
return handleWithdrawal(account, fmt, transactionDate, transactionAmount, paymentDetail, applyWithdrawFee, isRegularTransaction,
|
||||
isAccountTransfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* As above, but lets the caller declare the withdrawal as an internal account-to-account movement
|
||||
* rather than cash paid out over the counter. Used by reinvestment on maturity, where the balance
|
||||
* moves straight into the new deposit and must post against the transfer-suspense GL, not cash/vault.
|
||||
*/
|
||||
private SavingsAccountTransaction handleWithdrawal(final SavingsAccount account, final DateTimeFormatter fmt,
|
||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
||||
final boolean applyWithdrawFee, final boolean isRegularTransaction, final boolean isAccountTransfer) {
|
||||
boolean isInterestTransfer = false;
|
||||
boolean isWithdrawBalance = false;
|
||||
final boolean backdatedTxnsAllowedTill = false;
|
||||
@@ -100,7 +125,15 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
@Override
|
||||
public SavingsAccountTransaction handleFDDeposit(final FixedDepositAccount account, final DateTimeFormatter fmt,
|
||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail) {
|
||||
boolean isAccountTransfer = false;
|
||||
final boolean isAccountTransfer = false;
|
||||
return handleFDDeposit(account, fmt, transactionDate, transactionAmount, paymentDetail, isAccountTransfer);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public SavingsAccountTransaction handleFDDeposit(final FixedDepositAccount account, final DateTimeFormatter fmt,
|
||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
||||
final boolean isAccountTransfer) {
|
||||
boolean isRegularTransaction = false;
|
||||
final boolean backdatedTxnsAllowedTill = false;
|
||||
return this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate, transactionAmount, paymentDetail,
|
||||
@@ -200,16 +233,26 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
|
||||
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||
if (onClosureType.isReinvest()) {
|
||||
// Captured before the withdrawal below empties the account, so the renewal history can
|
||||
// record what this term actually matured at.
|
||||
final BigDecimal maturedBalance = account.getAccountBalance();
|
||||
ExternalId externalId = this.externalIdFactory.create();
|
||||
FixedDepositAccount reinvestedDeposit = account.reInvest(account.getAccountBalance(), externalId);
|
||||
FixedDepositAccount reinvestedDeposit = account.reInvest(maturedBalance, externalId);
|
||||
this.depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
|
||||
reinvestedDeposit.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure,
|
||||
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||
this.savingsAccountRepository.saveAndFlush(reinvestedDeposit);
|
||||
autoGenerateAccountNumber(reinvestedDeposit);
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
|
||||
paymentDetail, false, isRegularTransaction);
|
||||
// Renewal is an internal movement into the new deposit, not cash paid out -- post it
|
||||
// against the transfer-suspense GL rather than crediting cash/vault.
|
||||
final boolean isInternalTransferLeg = true;
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, maturedBalance, paymentDetail,
|
||||
false, isRegularTransaction, isInternalTransferLeg);
|
||||
savingsTransactionId = withdrawal.getId();
|
||||
// Reached when a user closes the account with a re-invest instruction, rather than the
|
||||
// maturity job acting on a standing instruction.
|
||||
recordRenewal(account, reinvestedDeposit, maturedBalance, maturedBalance, closedDate,
|
||||
FixedDepositRenewalHistory.RENEWAL_TYPE_MANUAL, user);
|
||||
} else if (onClosureType.isTransferToSavings()) {
|
||||
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
|
||||
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
|
||||
@@ -260,13 +303,58 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
account.postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||
account.setClosedOnDate(closedDate);
|
||||
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||
if (onClosureType.isReinvest()) {
|
||||
BigDecimal reInvestAmount;
|
||||
if (onClosureType.isReinvestPrincipal()) {
|
||||
reInvestAmount = account.getDepositAmount();
|
||||
} else {
|
||||
reInvestAmount = account.getAccountBalance();
|
||||
}
|
||||
if (onClosureType.isReinvestPrincipalAndInterest()) {
|
||||
// Renews on the SAME account, so the customer keeps one account number however many times
|
||||
// the deposit rolls over. Nothing moves: the whole matured balance simply becomes the new
|
||||
// term's principal, so there is no withdrawal, no deposit and no journal entry for the
|
||||
// rollover itself -- which also removes the transfer-suspense round trip the old
|
||||
// close-and-reopen flow needed.
|
||||
final BigDecimal closingPrincipal = account.getDepositAmount();
|
||||
final BigDecimal maturedBalance = account.getAccountBalance();
|
||||
final BigDecimal interestEarned = maturedBalance == null || closingPrincipal == null ? null
|
||||
: maturedBalance.subtract(closingPrincipal);
|
||||
|
||||
// The active CBS base interest-rate version for this FD type: the same rate card the Base
|
||||
// Interest Rates screen shows and the account-opening wizard prices from. Used for both the
|
||||
// new term's slabs and its senior-citizen premium, so screen and account agree.
|
||||
final FdInterestRateEffectiveData activeBaseRates = account.fdType() == null ? null
|
||||
: this.fdBaseInterestRateReadPlatformService.retrieveActiveInterestRatesByType(account.fdType()).stream().findFirst()
|
||||
.orElse(null);
|
||||
|
||||
final BigDecimal currentSeniorCitizenRate = account.isSeniorCitizen()
|
||||
? seniorCitizenRateFor(activeBaseRates, account.depositPeriod(), account.depositPeriodFrequency())
|
||||
: null;
|
||||
|
||||
// Captured before renewInPlace overwrites the account's chart, so the closing term's full
|
||||
// rate-by-tenure chart (including its senior-citizen premiums) can be archived rather than lost
|
||||
// -- renewInPlace mutates the same chart row every time, it does not create a new one.
|
||||
final String closingChartName = account.currentChartName();
|
||||
final List<DepositAccountInterestRateChart.SlabSnapshot> closingChartSlabs = account.currentChartSlabFields();
|
||||
// Likewise captured before renewInPlace overwrites the account's own rate/tenure with the new
|
||||
// term's -- needed only if this is the closing term's first-ever history row (see
|
||||
// recordInPlaceRenewal), so that row records what this term actually ran at instead of blank.
|
||||
final BigDecimal closingInterestRate = account.getNominalAnnualInterestRate();
|
||||
final Integer closingTenure = account.depositPeriod();
|
||||
final Integer closingTenureFrequencyEnum = account.depositPeriodFrequency();
|
||||
|
||||
account.renewInPlace(maturedBalance, closedDate, currentSeniorCitizenRate, baseChartFieldsOf(activeBaseRates),
|
||||
baseChartSlabsOf(activeBaseRates, account.getCurrency().getCode()));
|
||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
financialYearBeginningMonth);
|
||||
this.savingsAccountRepository.save(account);
|
||||
|
||||
recordInPlaceRenewal(account, closingPrincipal, interestEarned, maturedBalance, maturedBalance, closedDate,
|
||||
FixedDepositRenewalHistory.RENEWAL_TYPE_AUTO, user, closingChartName, closingChartSlabs, closingInterestRate,
|
||||
closingTenure, closingTenureFrequencyEnum);
|
||||
changes.put("renewedInPlace", Boolean.TRUE);
|
||||
changes.put("renewalCycleNo", account.renewalCycleNo());
|
||||
|
||||
} else if (onClosureType.isReinvest()) {
|
||||
// "Re-invest principal only" still closes and reopens, because only the principal carries
|
||||
// forward and the interest has to leave the deposit -- which needs a payout destination that
|
||||
// an in-place renewal has nowhere to send. Left on the original flow rather than guessing.
|
||||
final BigDecimal maturedBalance = account.getAccountBalance();
|
||||
final BigDecimal reInvestAmount = account.getDepositAmount();
|
||||
ExternalId externalId = this.externalIdFactory.create();
|
||||
|
||||
FixedDepositAccount reinvestedDeposit = account.reInvest(reInvestAmount, externalId);
|
||||
@@ -276,18 +364,26 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
|
||||
this.savingsAccountRepository.saveAndFlush(reinvestedDeposit);
|
||||
autoGenerateAccountNumber(reinvestedDeposit);
|
||||
// Renewal moves the balance internally into the new deposit -- no cash leaves the branch --
|
||||
// so this leg is posted as an account transfer (against the transfer-suspense GL) rather
|
||||
// than as a counter withdrawal, which would wrongly credit the cash/vault account.
|
||||
final boolean isInternalTransferLeg = true;
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, reInvestAmount, paymentDetail,
|
||||
false, isRegularTransaction);
|
||||
false, isRegularTransaction, isInternalTransferLeg);
|
||||
savingsTransactionId = withdrawal.getId();
|
||||
// handleWithdrawal() posts this withdrawal's own journal entries, so it has to be marked as
|
||||
// already accounted for -- exactly as the transfer-to-savings branch below does -- or the
|
||||
// postJournalEntries() call at the end of this method posts it a second time.
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
|
||||
if (onClosureType.isReinvestPrincipalAndInterest()) {
|
||||
account.updateClosedStatus();
|
||||
account.updateOnAccountClosureStatus(onClosureType);
|
||||
}
|
||||
changes.put("reinvestedDepositId", reinvestedDeposit.getId());
|
||||
reinvestedDeposit.approveAndActivateApplication(closedDate, user);
|
||||
this.savingsAccountRepository.save(reinvestedDeposit);
|
||||
|
||||
// Reached from the maturity job processing the account's standing maturity instruction.
|
||||
recordRenewal(account, reinvestedDeposit, maturedBalance, reInvestAmount, closedDate,
|
||||
FixedDepositRenewalHistory.RENEWAL_TYPE_AUTO, user);
|
||||
|
||||
} else if (onClosureType.isTransferToSavings()) {
|
||||
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
|
||||
DepositAccountType.SAVINGS_DEPOSIT);
|
||||
@@ -304,6 +400,7 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
|
||||
paymentDetail, false, isRegularTransaction);
|
||||
savingsTransactionId = withdrawal.getId();
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
}
|
||||
|
||||
// if(!processMaturityInstructionOnly)
|
||||
@@ -429,6 +526,274 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the closing term's full rate-by-tenure chart -- each slab together with its senior-citizen premium --
|
||||
* against its {@link FixedDepositRenewalHistory} row.
|
||||
* <p>
|
||||
* Slabs missing a rate or a from-period are skipped -- they cannot describe a tenure band. Writes nothing when the
|
||||
* closing term had no chart (e.g. a plain flat-rate deposit), rather than persisting an empty, meaningless archive.
|
||||
*/
|
||||
private void archiveChartSlabs(final Long fdRenewalHistoryId, final String chartName,
|
||||
final List<DepositAccountInterestRateChart.SlabSnapshot> snapshots, final String currencyCode) {
|
||||
if (snapshots == null || snapshots.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (final DepositAccountInterestRateChart.SlabSnapshot snapshot : snapshots) {
|
||||
final InterestRateChartSlabFields fields = snapshot.getFields();
|
||||
if (fields.annualInterestRate() == null || fields.fromPeriod() == null) {
|
||||
continue;
|
||||
}
|
||||
this.fixedDepositRenewalChartSlabHistoryRepository
|
||||
.save(FixedDepositRenewalChartSlabHistory.create(fdRenewalHistoryId, chartName, fields.description(),
|
||||
fields.periodType(), fields.fromPeriod(), fields.toPeriod(), fields.getAmountRangeFrom(),
|
||||
fields.getAmountRangeTo(), fields.annualInterestRate(), currencyCode, snapshot.getSeniorCitizenRate()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Chart identity for the account snapshot, so it names the base rate version it was priced from. Package-private
|
||||
* and static (no instance state used) so {@link DepositAccountAssembler} can reuse the exact same mapping when a
|
||||
* new FD account is first priced from this master, instead of duplicating the logic.
|
||||
*/
|
||||
static InterestRateChartFields baseChartFieldsOf(final FdInterestRateEffectiveData baseRates) {
|
||||
// name and from_date are NOT NULL on the embeddable. A base version missing either would abort the
|
||||
// whole renewal (or account creation) with a constraint violation, so treat it as "no identity to
|
||||
// apply" instead: refreshFromSlabSnapshots keeps the chart's existing fields when handed null, and
|
||||
// the slabs -- the part that actually prices the deposit -- still get applied.
|
||||
if (baseRates == null || baseRates.getVersionLabel() == null || baseRates.getEffectiveFromDate() == null) {
|
||||
return null;
|
||||
}
|
||||
final boolean isPrimaryGroupingByAmount = false; // the base rate card bands by tenure, never by amount
|
||||
return InterestRateChartFields.createNew(baseRates.getVersionLabel(), baseRates.getRemarks(), baseRates.getEffectiveFromDate(),
|
||||
baseRates.getEffectiveToDate(), isPrimaryGroupingByAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates the base rate card's slabs into the shape an account chart stores, each paired with its senior-citizen
|
||||
* premium so that figure is persisted on the account (and later archived) rather than only ever being looked up live.
|
||||
* <p>
|
||||
* The base master bands purely by tenure, so amount ranges are left unset -- which
|
||||
* {@code InterestRateChartSlabFields.isAmountBetween} then treats as "any amount", exactly the intent. Slabs with no
|
||||
* from-period are dropped, since a slab that does not say where it starts cannot be matched against a tenure.
|
||||
*/
|
||||
static Collection<DepositAccountInterestRateChart.SlabSnapshot> baseChartSlabsOf(final FdInterestRateEffectiveData baseRates,
|
||||
final String currencyCode) {
|
||||
if (baseRates == null || baseRates.getSlabs() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final List<DepositAccountInterestRateChart.SlabSnapshot> snapshots = new ArrayList<>();
|
||||
for (final FdInterestRateSlabData slab : baseRates.getSlabs()) {
|
||||
if (slab.getFromPeriod() == null || slab.getAnnualInterestRate() == null) {
|
||||
continue;
|
||||
}
|
||||
final InterestRateChartSlabFields fields = InterestRateChartSlabFields.createNew(slab.getDescription(),
|
||||
SavingsPeriodFrequencyType.fromInt(slab.getPeriodTypeEnum()), slab.getFromPeriod(), slab.getToPeriod(), null, null,
|
||||
slab.getAnnualInterestRate(), currencyCode);
|
||||
snapshots.add(new DepositAccountInterestRateChart.SlabSnapshot(fields, slab.getSeniorCitizenRate()));
|
||||
}
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* The senior-citizen premium from the active base rate card for a given tenure.
|
||||
* <p>
|
||||
* The tenure and the slab bounds are converted to a common unit before comparing, so a rate card published in years
|
||||
* still matches a deposit taken for a number of months. Conversion stays inside a unit family -- days/weeks, or
|
||||
* months/years -- because only those are exact; a days-based card is therefore still never matched against a
|
||||
* months-based tenure, since "1 month" is not a fixed number of days and guessing would land the deposit in the
|
||||
* wrong band. Null when no slab covers the tenure or the matching slab carries no premium, which leaves the
|
||||
* account's existing rate untouched rather than silently dropping the depositor's premium.
|
||||
*/
|
||||
private BigDecimal seniorCitizenRateFor(final FdInterestRateEffectiveData baseRates, final Integer tenure,
|
||||
final Integer tenurePeriodTypeEnum) {
|
||||
if (baseRates == null || baseRates.getSlabs() == null || tenure == null) {
|
||||
return null;
|
||||
}
|
||||
final Integer tenureInBaseUnit = inFamilyBaseUnit(tenure, tenurePeriodTypeEnum);
|
||||
if (tenureInBaseUnit == null) {
|
||||
return null;
|
||||
}
|
||||
for (final FdInterestRateSlabData slab : baseRates.getSlabs()) {
|
||||
if (!sameUnitFamily(tenurePeriodTypeEnum, slab.getPeriodTypeEnum())) {
|
||||
continue;
|
||||
}
|
||||
final Integer slabFrom = inFamilyBaseUnit(slab.getFromPeriod(), slab.getPeriodTypeEnum());
|
||||
if (slabFrom == null || tenureInBaseUnit < slabFrom) {
|
||||
continue;
|
||||
}
|
||||
if (slab.getToPeriod() != null) {
|
||||
final Integer slabTo = inFamilyBaseUnit(slab.getToPeriod(), slab.getPeriodTypeEnum());
|
||||
if (slabTo == null || tenureInBaseUnit > slabTo) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
final BigDecimal rate = slab.getSeniorCitizenRate();
|
||||
if (rate != null && rate.compareTo(BigDecimal.ZERO) > 0) {
|
||||
return rate;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code value} restated in the finest unit of its own family -- days for DAYS/WEEKS, months for MONTHS/YEARS -- so
|
||||
* two periods written in different but related units can be compared without losing precision. Null for an unknown
|
||||
* unit. Enum codes are {@link SavingsPeriodFrequencyType}: DAYS(0), WEEKS(1), MONTHS(2), YEARS(3).
|
||||
*/
|
||||
private Integer inFamilyBaseUnit(final Integer value, final Integer periodTypeEnum) {
|
||||
if (value == null || periodTypeEnum == null) {
|
||||
return null;
|
||||
}
|
||||
return switch (SavingsPeriodFrequencyType.fromInt(periodTypeEnum)) {
|
||||
case DAYS, MONTHS -> value;
|
||||
case WEEKS -> value * 7;
|
||||
case YEARS -> value * 12;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether two period types convert exactly into one another. Days and weeks do; months and years do. Across those
|
||||
* two families they do not, because a month is not a fixed number of days -- so a days-based rate card is never
|
||||
* matched against a months-based tenure rather than guessing and landing the deposit in the wrong band.
|
||||
*/
|
||||
private boolean sameUnitFamily(final Integer firstPeriodTypeEnum, final Integer secondPeriodTypeEnum) {
|
||||
if (firstPeriodTypeEnum == null || secondPeriodTypeEnum == null) {
|
||||
return false;
|
||||
}
|
||||
return isDayFamily(firstPeriodTypeEnum) == isDayFamily(secondPeriodTypeEnum);
|
||||
}
|
||||
|
||||
private boolean isDayFamily(final Integer periodTypeEnum) {
|
||||
final SavingsPeriodFrequencyType type = SavingsPeriodFrequencyType.fromInt(periodTypeEnum);
|
||||
return type == SavingsPeriodFrequencyType.DAYS || type == SavingsPeriodFrequencyType.WEEKS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Records a renewal that happened on the SAME account, where there is no second account row to describe the new term.
|
||||
* <p>
|
||||
* Called after {@link FixedDepositAccount#renewInPlace}, which has already advanced the account's cycle number,
|
||||
* principal and maturity date -- so the closing term's figures have to be passed in rather than read back off the
|
||||
* account, where they no longer exist. Every row for one FD shares that FD's single account id and account number;
|
||||
* they are told apart by renewal_no, which is what makes this a one-to-many history of one account.
|
||||
*
|
||||
* @param closingChartName
|
||||
* the name of the chart the closing term was priced on, captured before renewInPlace overwrote it; null if
|
||||
* unavailable
|
||||
* @param closingChartSlabs
|
||||
* the closing term's full rate-by-tenure chart, likewise captured before it was overwritten. Archived
|
||||
* against the closing term's row so its whole rate card remains queryable, not only the single effective
|
||||
* rate {@link FixedDepositRenewalHistory} records.
|
||||
* @param closingInterestRate
|
||||
* the closing term's own {@code nominalAnnualInterestRate}, captured before renewInPlace overwrote it --
|
||||
* needed only when this term has no existing row yet (see below), since the account itself no longer
|
||||
* carries it once renewInPlace has run.
|
||||
* @param closingTenure
|
||||
* the closing term's own deposit period, captured the same way and needed for the same reason.
|
||||
* @param closingTenureFrequencyEnum
|
||||
* the closing term's own deposit period frequency, captured the same way and needed for the same reason.
|
||||
*/
|
||||
private void recordInPlaceRenewal(final FixedDepositAccount account, final BigDecimal closingPrincipal,
|
||||
final BigDecimal closingInterestEarned, final BigDecimal maturedBalance, final BigDecimal renewedAmount,
|
||||
final LocalDate renewedOn, final String renewalType, final AppUser user, final String closingChartName,
|
||||
final List<DepositAccountInterestRateChart.SlabSnapshot> closingChartSlabs, final BigDecimal closingInterestRate,
|
||||
final Integer closingTenure, final Integer closingTenureFrequencyEnum) {
|
||||
|
||||
// The CHAIN's number, not this account's own. They differ for an FD that was renewed under the old
|
||||
// close-and-reopen model before renewing in place: its rows are keyed on the original account's
|
||||
// number, so keying new rows on this account's number would split the history in two and re-create
|
||||
// a duplicate row for the term that already has one. fdAccountNumber() falls back to this account's
|
||||
// own number when there is no chain, which is what the read side resolves to as well.
|
||||
final String fdAccountNumber = account.fdAccountNumber();
|
||||
final int newCycleNo = account.renewalCycleNo();
|
||||
final Long createdById = user == null ? null : user.getId();
|
||||
|
||||
final List<FixedDepositRenewalHistory> existingRows = this.fixedDepositRenewalHistoryRepository
|
||||
.findByFdAccountNumberOrderByRenewalNoAsc(fdAccountNumber);
|
||||
FixedDepositRenewalHistory closingRow = existingRows.stream()
|
||||
.filter(row -> Integer.valueOf(newCycleNo - 1).equals(row.getRenewalNo())).findFirst().orElse(null);
|
||||
|
||||
// The term that just closed has no row when this FD renews for the first time since the history
|
||||
// table existed. Written now, from the figures captured before the rollover, so the history
|
||||
// always begins with the term the customer originally opened -- rate and tenure included, rather
|
||||
// than left blank, since the caller captured them before renewInPlace overwrote the account with
|
||||
// the new term's own values.
|
||||
if (closingRow == null) {
|
||||
closingRow = this.fixedDepositRenewalHistoryRepository.saveAndFlush(FixedDepositRenewalHistory.create(fdAccountNumber,
|
||||
account.getId(), account.getId(), null, null, newCycleNo - 1, closingPrincipal, null, maturedBalance,
|
||||
closingPrincipal, closingInterestRate, account.getActivationDate(), renewedOn, closingTenure,
|
||||
closingTenureFrequencyEnum, renewalType, account.getActivationDate(), createdById));
|
||||
}
|
||||
closingRow.recordOutcome(closingInterestEarned, maturedBalance);
|
||||
closingRow.markMatured();
|
||||
this.fixedDepositRenewalHistoryRepository.save(closingRow);
|
||||
|
||||
archiveChartSlabs(closingRow.getId(), closingChartName, closingChartSlabs, account.getCurrency().getCode());
|
||||
|
||||
// The new term's own interest/maturity stay unset until it closes in turn.
|
||||
this.fixedDepositRenewalHistoryRepository.save(FixedDepositRenewalHistory.create(fdAccountNumber, account.getId(),
|
||||
account.getId(), null, closingRow.getId(), newCycleNo, renewedAmount, null, null, renewedAmount,
|
||||
account.getNominalAnnualInterestRate(), renewedOn, account.maturityDate(), account.depositPeriod(),
|
||||
account.depositPeriodFrequency(), renewalType, renewedOn, createdById));
|
||||
}
|
||||
|
||||
/**
|
||||
* Records the renewal that started {@code newTerm}, and closes off the previous term's history row.
|
||||
* <p>
|
||||
* Each term of an FD runs as its own deposit instance so it keeps an immutable ledger, which means the rollover event
|
||||
* itself -- what the previous term earned, what carried forward, at what rate, automatically or by whom -- is not
|
||||
* recoverable from the account rows alone. This writes it down explicitly.
|
||||
* <p>
|
||||
* The chain's first term is backfilled here too when it has no row yet: an FD opened before this table existed only
|
||||
* gets discovered at its first renewal, and without its opening row the history would start at "Renewal 1" with no
|
||||
* original.
|
||||
*/
|
||||
private void recordRenewal(final FixedDepositAccount previousTerm, final FixedDepositAccount newTerm,
|
||||
final BigDecimal maturityAmount, final BigDecimal renewedAmount, final LocalDate renewedOn, final String renewalType,
|
||||
final AppUser user) {
|
||||
|
||||
final String fdAccountNumber = previousTerm.fdAccountNumber();
|
||||
final Long originalAccountId = this.fixedDepositRenewalHistoryRepository
|
||||
.findByFdAccountNumberOrderByRenewalNoAsc(fdAccountNumber).stream().findFirst()
|
||||
.map(FixedDepositRenewalHistory::getOriginalSavingsAccountId)
|
||||
.orElseGet(() -> previousTerm.reinvestedFromSavingsId() == null ? previousTerm.getId() : null);
|
||||
|
||||
FixedDepositRenewalHistory previousRow = this.fixedDepositRenewalHistoryRepository
|
||||
.findBySavingsAccountIdOrderByRenewalNoDesc(previousTerm.getId()).stream().findFirst().orElse(null);
|
||||
|
||||
// Backfill the opening term when the chain started before this table existed, so the history
|
||||
// always begins with the account the customer actually opened.
|
||||
if (previousRow == null && originalAccountId != null && originalAccountId.equals(previousTerm.getId())) {
|
||||
previousRow = this.fixedDepositRenewalHistoryRepository.saveAndFlush(FixedDepositRenewalHistory.create(fdAccountNumber,
|
||||
originalAccountId, previousTerm.getId(), null, null, previousTerm.renewalCycleNo(),
|
||||
previousTerm.getDepositAmount(), null, previousTerm.maturityAmount(), previousTerm.getDepositAmount(),
|
||||
previousTerm.getNominalAnnualInterestRate(), previousTerm.getActivationDate(), previousTerm.maturityDate(),
|
||||
previousTerm.depositPeriod(), previousTerm.depositPeriodFrequency(), renewalType, previousTerm.getActivationDate(),
|
||||
user == null ? null : user.getId()));
|
||||
}
|
||||
|
||||
// What the closing term actually earned. maturityAmount is passed in rather than read off the
|
||||
// account because the caller has already withdrawn the balance out of it by this point, which
|
||||
// would make it read as zero. Recorded on the CLOSING term's own row -- every row states its own
|
||||
// term's outcome, so a reader never has to look at the next row to find out how one term did.
|
||||
final BigDecimal previousPrincipal = previousTerm.getDepositAmount();
|
||||
final BigDecimal interestEarned = maturityAmount == null || previousPrincipal == null ? null
|
||||
: maturityAmount.subtract(previousPrincipal);
|
||||
|
||||
if (previousRow != null) {
|
||||
previousRow.recordOutcome(interestEarned, maturityAmount);
|
||||
previousRow.markMatured();
|
||||
this.fixedDepositRenewalHistoryRepository.save(previousRow);
|
||||
}
|
||||
|
||||
// The new term's own interest/maturity stay unset until it closes in turn.
|
||||
this.fixedDepositRenewalHistoryRepository.save(FixedDepositRenewalHistory.create(fdAccountNumber,
|
||||
originalAccountId == null ? previousTerm.getId() : originalAccountId, newTerm.getId(), previousTerm.getId(),
|
||||
previousRow == null ? null : previousRow.getId(), newTerm.renewalCycleNo(), renewedAmount, null, null, renewedAmount,
|
||||
newTerm.getNominalAnnualInterestRate(), renewedOn, newTerm.maturityDate(), newTerm.depositPeriod(),
|
||||
newTerm.depositPeriodFrequency(), renewalType, renewedOn, user == null ? null : user.getId()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Long handleFDAccountPreMatureClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
||||
@@ -474,6 +839,9 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
|
||||
paymentDetail, false, isRegularTransaction);
|
||||
savingsTransactionId = withdrawal.getId();
|
||||
// handleWithdrawal() posts this withdrawal's journal entries itself, so mark it as already
|
||||
// accounted for or the postJournalEntries() call below posts it a second time.
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
}
|
||||
|
||||
account.prematureClosure(user, command, changes);
|
||||
@@ -484,6 +852,238 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
||||
return savingsTransactionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* A staff-triggered, always-available alternative to Premature Close (Active-only, no reinvest) and Close
|
||||
* (Matured-only): works on an FD in either state, and adds a Partial Reinvest option neither of those two support
|
||||
* -- part of the matured amount renews on this same account via {@link FixedDepositAccount#renewInPlace}, the rest
|
||||
* transfers out to a savings account picked at the moment of the request. Full reinvest here also goes through
|
||||
* {@code renewInPlace} rather than the legacy close-and-reopen {@link FixedDepositAccount#reInvest}, which is what
|
||||
* the existing manual Close command still uses today.
|
||||
* <p>
|
||||
* Deliberately independent of {@link #handleFDAccountClosure} and {@link #handleFDAccountPreMatureClosure} --
|
||||
* neither of those two methods is touched, so the existing Close/Premature Close buttons keep behaving exactly as
|
||||
* before.
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public Long handleFDAccountPayment(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
||||
final JsonCommand command, final Map<String, Object> changes) {
|
||||
|
||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||
final Integer financialYearBeginningMonth = this.configurationDomainService.retrieveFinancialYearBeginningMonth();
|
||||
|
||||
boolean isRegularTransaction = false;
|
||||
boolean isAccountTransfer = false;
|
||||
final boolean isPreMatureClosure = false;
|
||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
|
||||
final MathContext mc = MathContext.DECIMAL64;
|
||||
final Locale locale = command.extractLocale();
|
||||
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
|
||||
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
||||
Long savingsTransactionId = null;
|
||||
|
||||
// account.isMatured() only reflects whether the overnight scheduler has already flipped this
|
||||
// account's status -- not whether the customer actually showed up before or after the maturity
|
||||
// date. A customer walking in ON the maturity date (or any day after) is not premature just
|
||||
// because that job hasn't run yet today, so the real test is the date, not the status flag.
|
||||
if (!account.isMatured()) {
|
||||
if (!DateUtils.isBefore(closedDate, account.maturityDate())) {
|
||||
// Genuinely due, the scheduler just hasn't caught up yet -- do exactly what it would:
|
||||
// flip to Matured and post final interest at the full contracted rate, no penalty.
|
||||
account.updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||
} else {
|
||||
// The three closing closure types re-check this themselves inside prematureClosure()
|
||||
// below, but the two reinvest branches never call it (they keep the account open on the
|
||||
// same term), so it is enforced once, up front, for every genuinely-premature Payment --
|
||||
// a locked-in FD (e.g. a Tax Saver with its statutory lock-in) cannot be touched early via
|
||||
// this action either.
|
||||
if (account.isLockedOnDate(closedDate)) {
|
||||
throw new GeneralPlatformDomainRuleException("error.msg.fixeddeposit.payment.lockin.period.not.elapsed",
|
||||
"This account is still within its lock-in period and cannot be processed before it elapses.", closedDate);
|
||||
}
|
||||
// Same penalty-aware interest calculation prematureClosure() already relies on, so a
|
||||
// genuinely early Payment settles interest exactly as a Premature Close would.
|
||||
account.postPreMaturityInterest(closedDate, true, isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||
}
|
||||
} else {
|
||||
account.postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||
}
|
||||
|
||||
// Same as the closure and maturity paths do: the legacy reinvest branch's reInvest() reads
|
||||
// getClosedOnDate() to pick the new account's chart and submitted date, so it has to be set
|
||||
// before branching. renewInPlace() clears it again for the branches that keep the account open.
|
||||
account.setClosedOnDate(closedDate);
|
||||
|
||||
// Re-read after the block above: updateMaturityStatus() may just have flipped it, so this now
|
||||
// correctly decides close() (needs Matured) vs prematureClosure() (needs Active) either way.
|
||||
final boolean alreadyMatured = account.isMatured();
|
||||
|
||||
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
|
||||
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||
|
||||
if (onClosureType.isReinvestPrincipalAndInterest() || onClosureType.isPartialReinvest()) {
|
||||
// These two branches keep the account open, so they never reach close()/prematureClosure() and
|
||||
// would otherwise accept any date at all -- including one behind already-posted interest, which
|
||||
// the renewal would then turn into a pivot that reverses and re-posts it.
|
||||
account.validateRenewalDate(closedDate);
|
||||
|
||||
final BigDecimal closingPrincipal = account.getDepositAmount();
|
||||
final BigDecimal maturedBalance = account.getAccountBalance();
|
||||
final BigDecimal interestEarned = maturedBalance == null || closingPrincipal == null ? null
|
||||
: maturedBalance.subtract(closingPrincipal);
|
||||
|
||||
final BigDecimal renewedAmount;
|
||||
if (onClosureType.isPartialReinvest()) {
|
||||
renewedAmount = command.bigDecimalValueOfParameterNamed(reinvestAmountParamName);
|
||||
if (renewedAmount == null || renewedAmount.compareTo(BigDecimal.ZERO) <= 0
|
||||
|| renewedAmount.compareTo(maturedBalance) >= 0) {
|
||||
throw new GeneralPlatformDomainRuleException("error.msg.fixeddeposit.partial.reinvest.amount.invalid",
|
||||
"The reinvest amount must be greater than zero and less than the matured balance.", renewedAmount);
|
||||
}
|
||||
} else {
|
||||
renewedAmount = maturedBalance;
|
||||
}
|
||||
|
||||
final FdInterestRateEffectiveData activeBaseRates = account.fdType() == null ? null
|
||||
: this.fdBaseInterestRateReadPlatformService.retrieveActiveInterestRatesByType(account.fdType()).stream().findFirst()
|
||||
.orElse(null);
|
||||
final BigDecimal currentSeniorCitizenRate = account.isSeniorCitizen()
|
||||
? seniorCitizenRateFor(activeBaseRates, account.depositPeriod(), account.depositPeriodFrequency())
|
||||
: null;
|
||||
|
||||
final String closingChartName = account.currentChartName();
|
||||
final List<DepositAccountInterestRateChart.SlabSnapshot> closingChartSlabs = account.currentChartSlabFields();
|
||||
// Likewise captured before renewInPlace overwrites the account's own rate/tenure with the new
|
||||
// term's -- needed only if this is the closing term's first-ever history row (see
|
||||
// recordInPlaceRenewal), so that row records what this term actually ran at instead of blank.
|
||||
final BigDecimal closingInterestRate = account.getNominalAnnualInterestRate();
|
||||
final Integer closingTenure = account.depositPeriod();
|
||||
final Integer closingTenureFrequencyEnum = account.depositPeriodFrequency();
|
||||
|
||||
account.renewInPlace(renewedAmount, closedDate, currentSeniorCitizenRate, baseChartFieldsOf(activeBaseRates),
|
||||
baseChartSlabsOf(activeBaseRates, account.getCurrency().getCode()));
|
||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
financialYearBeginningMonth);
|
||||
this.savingsAccountRepository.save(account);
|
||||
|
||||
recordInPlaceRenewal(account, closingPrincipal, interestEarned, maturedBalance, renewedAmount, closedDate,
|
||||
FixedDepositRenewalHistory.RENEWAL_TYPE_MANUAL, user, closingChartName, closingChartSlabs, closingInterestRate,
|
||||
closingTenure, closingTenureFrequencyEnum);
|
||||
changes.put("renewedInPlace", Boolean.TRUE);
|
||||
changes.put("renewalCycleNo", account.renewalCycleNo());
|
||||
|
||||
if (onClosureType.isPartialReinvest()) {
|
||||
// The kept portion never left the account -- renewInPlace() just relabels it as the new
|
||||
// term's principal -- so only the remainder is an actual money movement, posted the same
|
||||
// way the Transfer to Savings branch below posts its full-balance transfer.
|
||||
final BigDecimal remainder = maturedBalance.subtract(renewedAmount);
|
||||
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
|
||||
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
|
||||
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
|
||||
DepositAccountType.SAVINGS_DEPOSIT);
|
||||
final boolean isExceptionForBalanceCheck = false;
|
||||
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, remainder, PortfolioAccountType.SAVINGS,
|
||||
PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null, null, null, null,
|
||||
AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, ExternalId.empty(), null, toSavingsAccount, account,
|
||||
isAccountTransfer, isExceptionForBalanceCheck);
|
||||
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
}
|
||||
|
||||
} else if (onClosureType.isReinvestPrincipal()) {
|
||||
// Legacy close-and-reopen, same shape as handleFDAccountClosure()'s isReinvest() branch --
|
||||
// the interest has to leave the deposit, which needs a payout destination an in-place renewal
|
||||
// has nowhere to send.
|
||||
final BigDecimal maturedBalance = account.getAccountBalance();
|
||||
final BigDecimal reInvestAmount = account.getDepositAmount();
|
||||
final ExternalId externalId = this.externalIdFactory.create();
|
||||
|
||||
final FixedDepositAccount reinvestedDeposit = account.reInvest(reInvestAmount, externalId);
|
||||
this.depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
|
||||
reinvestedDeposit.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure,
|
||||
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||
|
||||
this.savingsAccountRepository.saveAndFlush(reinvestedDeposit);
|
||||
autoGenerateAccountNumber(reinvestedDeposit);
|
||||
final boolean isInternalTransferLeg = true;
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, reInvestAmount, paymentDetail,
|
||||
false, isRegularTransaction, isInternalTransferLeg);
|
||||
savingsTransactionId = withdrawal.getId();
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
|
||||
changes.put("reinvestedDepositId", reinvestedDeposit.getId());
|
||||
reinvestedDeposit.approveAndActivateApplication(closedDate, user);
|
||||
this.savingsAccountRepository.save(reinvestedDeposit);
|
||||
|
||||
recordRenewal(account, reinvestedDeposit, maturedBalance, reInvestAmount, closedDate,
|
||||
FixedDepositRenewalHistory.RENEWAL_TYPE_MANUAL, user);
|
||||
|
||||
// Only the principal moved into the new deposit -- the interest earned on this term is still
|
||||
// sitting in this account's balance. Pay it out to the chosen savings account now, before
|
||||
// closing, rather than stranding it here with nowhere left to go.
|
||||
final BigDecimal interestRemainder = maturedBalance.subtract(reInvestAmount);
|
||||
if (interestRemainder.compareTo(BigDecimal.ZERO) > 0) {
|
||||
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
|
||||
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
|
||||
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
|
||||
DepositAccountType.SAVINGS_DEPOSIT);
|
||||
final boolean isExceptionForBalanceCheck = false;
|
||||
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, interestRemainder,
|
||||
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null,
|
||||
null, null, null, null, AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, ExternalId.empty(), null,
|
||||
toSavingsAccount, account, isAccountTransfer, isExceptionForBalanceCheck);
|
||||
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
}
|
||||
|
||||
if (alreadyMatured) {
|
||||
account.close(user, command, changes);
|
||||
} else {
|
||||
account.prematureClosure(user, command, changes);
|
||||
}
|
||||
|
||||
} else if (onClosureType.isTransferToSavings()) {
|
||||
final Long toSavingsId = command.longValueOfParameterNamed(toSavingsAccountIdParamName);
|
||||
final String transferDescription = command.stringValueOfParameterNamed(transferDescriptionParamName);
|
||||
final SavingsAccount toSavingsAccount = this.depositAccountAssembler.assembleFrom(toSavingsId,
|
||||
DepositAccountType.SAVINGS_DEPOSIT);
|
||||
final boolean isExceptionForBalanceCheck = false;
|
||||
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(closedDate, account.getAccountBalance(),
|
||||
PortfolioAccountType.SAVINGS, PortfolioAccountType.SAVINGS, null, null, transferDescription, locale, fmt, null, null,
|
||||
null, null, null, AccountTransferType.ACCOUNT_TRANSFER.getValue(), null, null, ExternalId.empty(), null,
|
||||
toSavingsAccount, account, isAccountTransfer, isExceptionForBalanceCheck);
|
||||
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
|
||||
if (alreadyMatured) {
|
||||
account.close(user, command, changes);
|
||||
} else {
|
||||
account.prematureClosure(user, command, changes);
|
||||
}
|
||||
|
||||
} else {
|
||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
|
||||
paymentDetail, false, isRegularTransaction);
|
||||
savingsTransactionId = withdrawal.getId();
|
||||
updateAlreadyPostedTransactions(existingTransactionIds, account);
|
||||
|
||||
if (alreadyMatured) {
|
||||
account.close(user, command, changes);
|
||||
} else {
|
||||
account.prematureClosure(user, command, changes);
|
||||
}
|
||||
}
|
||||
|
||||
this.savingsAccountRepository.save(account);
|
||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
|
||||
|
||||
return savingsTransactionId;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public Long handleRDAccountPreMatureClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail,
|
||||
|
||||
+284
-20
@@ -53,6 +53,7 @@ import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
|
||||
import org.apache.fineract.portfolio.client.domain.Client;
|
||||
import org.apache.fineract.portfolio.group.domain.Group;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartFields;
|
||||
import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartAssembler;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountOnClosureType;
|
||||
import org.apache.fineract.portfolio.savings.DepositAccountType;
|
||||
@@ -276,7 +277,9 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
|
||||
public LocalDate calculateMaturityDate() {
|
||||
|
||||
final LocalDate startDate = accountSubmittedOrActivationDate();
|
||||
// The CURRENT term's start, not the account's activation date -- on a renewed FD these differ,
|
||||
// and measuring the term from activation would put maturity in the past.
|
||||
final LocalDate startDate = depositStartDate();
|
||||
LocalDate maturityDate = null;
|
||||
final Integer depositPeriod = this.accountTermAndPreClosure.depositPeriod();
|
||||
switch (this.accountTermAndPreClosure.depositPeriodFrequencyType()) {
|
||||
@@ -312,13 +315,19 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
.fromInt(this.interestCalculationDaysInYearType);
|
||||
List<LocalDate> postedAsOnTransactionDates = getManualPostingDates();
|
||||
|
||||
// Scoped to the current term, so a renewed FD's projection covers only the term now running --
|
||||
// matching what postInterest() will actually post -- rather than replaying the whole account.
|
||||
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
||||
accountSubmittedOrActivationDate(), maturityDate, postingPeriodType, financialYearBeginningMonth,
|
||||
postedAsOnTransactionDates);
|
||||
depositStartDate(), maturityDate, postingPeriodType, financialYearBeginningMonth, postedAsOnTransactionDates);
|
||||
|
||||
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
||||
|
||||
Money periodStartingBalance = Money.zero(currency);
|
||||
// On a first term the opening deposit falls inside the first posting period, so the period can
|
||||
// start from zero and pick the balance up from that transaction. On a renewed term that deposit
|
||||
// is BEFORE the period range and would be missed, leaving the term to earn interest on nothing,
|
||||
// so the term's own principal seeds the opening balance instead.
|
||||
Money periodStartingBalance = isRenewedTerm() ? Money.of(currency, this.accountTermAndPreClosure.depositAmount())
|
||||
: Money.zero(currency);
|
||||
|
||||
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
|
||||
final BigDecimal interestRateAsFraction = getEffectiveInterestRateAsFraction(mc, maturityDate, isPreMatureClosure);
|
||||
@@ -686,6 +695,60 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
return this.accountTermAndPreClosure.maturityAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* The stable customer-facing FD number: the account number of the first account in this renewal chain. Falls back to
|
||||
* this account's own number when it has never been renewed, so callers always get a usable FD number.
|
||||
*/
|
||||
public String fdAccountNumber() {
|
||||
final String carried = this.accountTermAndPreClosure.getFdAccountNumber();
|
||||
return carried != null ? carried : getAccountNumber();
|
||||
}
|
||||
|
||||
/** 0 for the originally opened term, 1 for the first renewal, and so on. */
|
||||
public Integer renewalCycleNo() {
|
||||
return this.accountTermAndPreClosure.getRenewalCycleNo();
|
||||
}
|
||||
|
||||
public Integer depositPeriod() {
|
||||
return this.accountTermAndPreClosure.depositPeriod();
|
||||
}
|
||||
|
||||
public Integer depositPeriodFrequency() {
|
||||
return this.accountTermAndPreClosure.depositPeriodFrequency();
|
||||
}
|
||||
|
||||
public Long reinvestedFromSavingsId() {
|
||||
return this.accountTermAndPreClosure.getReinvestedFromSavingsId();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the chart currently priced on this account. Read before a renewal overwrites it, so the closing term's
|
||||
* chart identity can be archived rather than lost.
|
||||
*/
|
||||
public String currentChartName() {
|
||||
return this.chart == null ? null : this.chart.chartFields().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* The slabs of the chart currently priced on this account -- each paired with its senior-citizen premium -- detached
|
||||
* from the chart's own persistence lifecycle.
|
||||
* <p>
|
||||
* Read before a renewal overwrites the account's chart in place ({@link #renewInPlace}), so the closing term's full
|
||||
* rate-by-tenure breakdown (including the premium) can be archived -- not just the single effective rate the renewal
|
||||
* history records -- rather than being silently deleted when the new term's slabs replace it.
|
||||
*/
|
||||
public List<DepositAccountInterestRateChart.SlabSnapshot> currentChartSlabFields() {
|
||||
return this.chart == null ? java.util.Collections.emptyList() : this.chart.currentSlabSnapshots();
|
||||
}
|
||||
|
||||
/**
|
||||
* This deposit's FD type (SINGLE / DOUBLE / SPECIAL), which lives on the product rather than the account. Null when
|
||||
* the product is not a Fixed Deposit product or has no type set.
|
||||
*/
|
||||
public String fdType() {
|
||||
return this.product instanceof FixedDepositProduct ? ((FixedDepositProduct) this.product).getFdType() : null;
|
||||
}
|
||||
|
||||
private Money totalInterestPosted() {
|
||||
Money interestPostedToDate = Money.zero(this.currency);
|
||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
||||
@@ -715,11 +778,26 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
return actualChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* The start of the term currently running, which is what the deposit's tenure and rate must be measured from.
|
||||
* <p>
|
||||
* For an FD that has never been renewed this is the activation date, exactly as before. A renewal advances
|
||||
* startInterestCalculationDate to the renewal date, so from then on the interest-rate chart slab is chosen by THIS
|
||||
* term's tenure rather than the cumulative tenure since the account was opened, and maturity is measured from the
|
||||
* renewal rather than from the original activation.
|
||||
*/
|
||||
private LocalDate depositStartDate() {
|
||||
// TODO: Support to add deposit start date which can be a date after
|
||||
// account activation date.
|
||||
final LocalDate depositStartDate = accountSubmittedOrActivationDate();
|
||||
return depositStartDate;
|
||||
final LocalDate currentTermStartDate = getStartInterestCalculationDate();
|
||||
return currentTermStartDate != null ? currentTermStartDate : accountSubmittedOrActivationDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* True once this FD has been renewed at least once, i.e. the term now running started later than the account did.
|
||||
* Everything keyed off this keeps its original, pre-renewal behaviour for an FD still on its first term.
|
||||
*/
|
||||
private boolean isRenewedTerm() {
|
||||
final LocalDate termStart = getStartInterestCalculationDate();
|
||||
return termStart != null && getActivationDate() != null && !termStart.equals(getActivationDate());
|
||||
}
|
||||
|
||||
private LocalDate interestCalculatedUpto() {
|
||||
@@ -814,28 +892,142 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
return this.accountTermAndPreClosure.getTransferToSavingsAccountId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rolls this FD into a new term on the SAME account, so the customer keeps one account number however many times it
|
||||
* renews. No new account is opened and no money moves: the balance simply carries into the next term.
|
||||
* <p>
|
||||
* What changes is the term itself. startInterestCalculationDate advances to the renewal date, which is what confines
|
||||
* interest posting to the new term and thereby leaves the closing term's postings untouched -- they fall outside the
|
||||
* posting periods the engine now generates, so nothing recalculates or reverses them. The term's principal becomes
|
||||
* {@code renewedAmount}, and every interest-mechanics setting plus the rate chart is re-taken from the product as it
|
||||
* stands today, so a renewal is priced on current terms rather than the ones frozen at account opening.
|
||||
* <p>
|
||||
* The caller must have posted the closing term's interest first, and must record the renewal in the FD's renewal
|
||||
* history so each term's own figures remain reportable.
|
||||
*
|
||||
* @param renewedAmount
|
||||
* what carries into the new term: the full maturity amount, or the principal only
|
||||
* @param renewedOn
|
||||
* the renewal date, which becomes the new term's start
|
||||
* @param currentSeniorCitizenRate
|
||||
* the senior-citizen premium the bank publishes on the renewal date for this FD type and tenure, or null to
|
||||
* keep the rate the account already holds. Only applied to an account already flagged senior-citizen; the
|
||||
* renewal never turns that flag on or off.
|
||||
* @param baseChartFields
|
||||
* identity of the CBS base rate version being applied, or null to keep the existing chart's
|
||||
* @param baseChartSlabs
|
||||
* the slabs of the active CBS base interest-rate version, each paired with its senior-citizen premium -- the
|
||||
* rate card staff maintain and see on the Base Interest Rates screen. When empty or null the account falls
|
||||
* back to the product's own chart, so a product with no base rate version still renews on something.
|
||||
*/
|
||||
public void renewInPlace(final BigDecimal renewedAmount, final LocalDate renewedOn, final BigDecimal currentSeniorCitizenRate,
|
||||
final InterestRateChartFields baseChartFields, final Collection<DepositAccountInterestRateChart.SlabSnapshot> baseChartSlabs) {
|
||||
|
||||
final SavingsProduct product = this.product;
|
||||
|
||||
// Confines interest posting to the new term. Set before recomputing maturity, since maturity is
|
||||
// measured from the current term's start.
|
||||
setStartInterestCalculationDate(renewedOn);
|
||||
|
||||
this.accountTermAndPreClosure.updateDepositAmount(renewedAmount);
|
||||
this.accountTermAndPreClosure.setRenewalCycleNo(this.accountTermAndPreClosure.getRenewalCycleNo() + 1);
|
||||
// Pin the chain number now that this account has renewed at least once, so a non-zero cycle number
|
||||
// is never paired with a blank FD number. fdAccountNumber() resolves to the chain's original number
|
||||
// if there is one and to this account's own otherwise, which is the same value every reader derives.
|
||||
this.accountTermAndPreClosure.setFdAccountNumber(fdAccountNumber());
|
||||
|
||||
// Re-price off the CURRENT product, exactly as opening a fresh deposit today would.
|
||||
this.nominalAnnualInterestRate = product.nominalAnnualInterestRate();
|
||||
this.interestCompoundingPeriodType = product.interestCompoundingPeriodType().getValue();
|
||||
this.interestPostingPeriodType = product.interestPostingPeriodType().getValue();
|
||||
this.interestCalculationType = product.interestCalculationType().getValue();
|
||||
this.interestCalculationDaysInYearType = product.interestCalculationDaysInYearType().getValue();
|
||||
this.withHoldTax = product.withHoldTax();
|
||||
|
||||
// Lock-in is re-taken from the product and re-measured from this renewal, exactly as the legacy
|
||||
// close-and-reopen reInvest() does for the account it creates. Left alone, a renewed term would
|
||||
// carry the lock-in window computed at the original activation -- long expired -- so a product with
|
||||
// a statutory lock-in (a Tax Saver, say) would hold the customer for the first term only.
|
||||
final SavingsPeriodFrequencyType renewedLockinPeriodFrequencyType = product.lockinPeriodFrequencyType();
|
||||
this.lockinPeriodFrequency = product.lockinPeriodFrequency();
|
||||
this.lockinPeriodFrequencyType = renewedLockinPeriodFrequencyType == null ? null
|
||||
: renewedLockinPeriodFrequencyType.getValue();
|
||||
this.lockedInUntilDate = this.lockinPeriodFrequencyType == null || this.lockinPeriodFrequency == null ? null
|
||||
: calculateDateAccountIsLockedUntil(renewedOn);
|
||||
|
||||
// The new term is priced off the CBS base interest-rate master -- the rate card staff maintain on
|
||||
// the Base Interest Rates screen, per FD type, with its own active version. That master is what
|
||||
// the bank publishes and what the account-opening wizard already shows, so pricing a renewal off
|
||||
// anything else would put the deposit on rates nobody chose.
|
||||
if (this.chart != null && baseChartSlabs != null && !baseChartSlabs.isEmpty()) {
|
||||
this.chart.refreshFromSlabSnapshots(baseChartFields, baseChartSlabs);
|
||||
} else if (this.chart != null) {
|
||||
// No active base version for this FD type: fall back to the product's own chart so the
|
||||
// renewal still gets current product rates rather than the ones frozen at opening.
|
||||
// activeChart, not applicableChart -- the latter treats a chart with no end date as valid only
|
||||
// up to today's business date, so a renewal dated in the future would find nothing.
|
||||
final InterestRateChart productChart = product instanceof FixedDepositProduct
|
||||
? ((FixedDepositProduct) product).activeChart(renewedOn)
|
||||
: null;
|
||||
if (productChart != null) {
|
||||
this.chart.refreshFrom(productChart);
|
||||
}
|
||||
}
|
||||
|
||||
// The senior-citizen premium is stored per account and takes priority over the chart in
|
||||
// getEffectiveInterestRateAsFraction(), so leaving it alone would price every future term of a
|
||||
// senior-citizen deposit at the rate captured when the account was opened. Only overwritten when
|
||||
// the caller found a currently published rate -- otherwise the existing one stands, so a missing
|
||||
// rate version can never silently drop the depositor's premium.
|
||||
if (isSeniorCitizen() && currentSeniorCitizenRate != null && currentSeniorCitizenRate.compareTo(BigDecimal.ZERO) > 0) {
|
||||
setSeniorCitizenInterestRate(currentSeniorCitizenRate);
|
||||
}
|
||||
|
||||
// The account never left ACTIVE, but updateMaturityStatus() flipped it to MATURED just before
|
||||
// this ran, so the new term has to put it back.
|
||||
this.status = SavingsAccountStatusType.ACTIVE.getValue();
|
||||
setClosedOnDate(null);
|
||||
}
|
||||
|
||||
public FixedDepositAccount reInvest(BigDecimal depositAmount, ExternalId externalId) {
|
||||
|
||||
final DepositAccountTermAndPreClosure newAccountTermAndPreClosure = this.accountTermAndPreClosure.copy(depositAmount);
|
||||
final SavingsProduct product = this.product;
|
||||
final InterestRateChart productChart = product.applicableChart(getClosedOnDate());
|
||||
// Effective-dated pick, same as renewInPlace: an open-ended chart stays valid past today's
|
||||
// business date, and the most recently effective chart wins when more than one covers the date.
|
||||
// Falls back to applicableChart so a product whose charts have no usable from-date still resolves
|
||||
// as it did before.
|
||||
InterestRateChart productChart = product instanceof FixedDepositProduct
|
||||
? ((FixedDepositProduct) product).activeChart(getClosedOnDate())
|
||||
: null;
|
||||
if (productChart == null) {
|
||||
productChart = product.applicableChart(getClosedOnDate());
|
||||
}
|
||||
final DepositAccountInterestRateChart newChart = DepositAccountInterestRateChart.from(productChart);
|
||||
|
||||
final AccountType accountType = AccountType.fromInt(this.accountType);
|
||||
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
|
||||
final SavingsCompoundingInterestPeriodType compoundingPeriodType = SavingsCompoundingInterestPeriodType
|
||||
.fromInt(this.interestCompoundingPeriodType);
|
||||
final SavingsInterestCalculationType interestCalculationType = SavingsInterestCalculationType.fromInt(this.interestCalculationType);
|
||||
final SavingsInterestCalculationDaysInYearType daysInYearType = SavingsInterestCalculationDaysInYearType
|
||||
.fromInt(this.interestCalculationDaysInYearType);
|
||||
// Re-price every interest-mechanics setting off the CURRENT product, not this (old) account's
|
||||
// frozen-at-opening snapshot -- same reasoning as interestRate/newChart below. Without this, a
|
||||
// renewed FD kept running on whatever compounding/posting/calculation-type/lock-in/tax setting
|
||||
// was in force when the ORIGINAL account was opened, silently ignoring every product edit made
|
||||
// since (e.g. Daily->Quarterly compounding, or a lock-in added later).
|
||||
final SavingsPostingInterestPeriodType postingPeriodType = product.interestPostingPeriodType();
|
||||
final SavingsCompoundingInterestPeriodType compoundingPeriodType = product.interestCompoundingPeriodType();
|
||||
final SavingsInterestCalculationType interestCalculationType = product.interestCalculationType();
|
||||
final SavingsInterestCalculationDaysInYearType daysInYearType = product.interestCalculationDaysInYearType();
|
||||
final BigDecimal minRequiredOpeningBalance = null;
|
||||
final BigDecimal interestRate = BigDecimal.ZERO;
|
||||
// Falls back to the product's own flat rate -- same fallback DepositAccountAssembler uses
|
||||
// for a brand-new account -- so a product with no chart slab covering this tenure/amount
|
||||
// doesn't silently reinvest the customer at 0%. getEffectiveInterestRateAsFraction() still
|
||||
// re-prices off newChart (the product's CURRENT chart, reflecting any edits made since the
|
||||
// original account was opened) whenever a matching slab exists.
|
||||
final BigDecimal interestRate = product.nominalAnnualInterestRate();
|
||||
final Set<SavingsAccountCharge> savingsAccountCharges = null;
|
||||
final SavingsPeriodFrequencyType lockinPeriodFrequencyType = SavingsPeriodFrequencyType.fromInt(this.lockinPeriodFrequencyType);
|
||||
final Integer lockinPeriodFrequency = this.lockinPeriodFrequency;
|
||||
final SavingsPeriodFrequencyType lockinPeriodFrequencyType = product.lockinPeriodFrequencyType();
|
||||
final Integer lockinPeriodFrequency = product.lockinPeriodFrequency();
|
||||
final boolean withdrawalFeeApplicableForTransfer = false;
|
||||
final String accountNumber = null;
|
||||
final boolean withHoldTax = this.withHoldTax;
|
||||
final boolean withHoldTax = product.withHoldTax();
|
||||
final FixedDepositAccount reInvestedAccount = FixedDepositAccount.createNewApplicationForSubmittal(client, group, product,
|
||||
savingsOfficer, accountNumber, externalId, accountType, getClosedOnDate(), closedBy, interestRate, compoundingPeriodType,
|
||||
postingPeriodType, interestCalculationType, daysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency,
|
||||
@@ -845,6 +1037,30 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
newAccountTermAndPreClosure.updateAccountReference(reInvestedAccount);
|
||||
newChart.updateDepositAccountReference(reInvestedAccount);
|
||||
|
||||
// Carry the senior-citizen premium forward -- without this, a senior-citizen depositor's
|
||||
// reinvested FD silently drops back to the standard rate on the new term.
|
||||
reInvestedAccount.setSeniorCitizen(this.isSeniorCitizen());
|
||||
reInvestedAccount.setSeniorCitizenInterestRate(this.getSeniorCitizenInterestRate());
|
||||
|
||||
// Track which account this was reinvested from, so staff/UI can trace the two accounts to
|
||||
// each other instead of the link disappearing the moment the old one closes.
|
||||
newAccountTermAndPreClosure.setReinvestedFromSavingsId(this.getId());
|
||||
|
||||
// Carry the ORIGINAL account's number forward across every renewal, so the customer keeps
|
||||
// seeing one recognisable FD number even though each term is its own account/ledger row.
|
||||
final String rootFdAccountNumber = this.accountTermAndPreClosure.getFdAccountNumber() != null
|
||||
? this.accountTermAndPreClosure.getFdAccountNumber()
|
||||
: this.getAccountNumber();
|
||||
newAccountTermAndPreClosure.setFdAccountNumber(rootFdAccountNumber);
|
||||
|
||||
// Number this term within the chain, so the UI can label it "Renewal 2 of FD ...048".
|
||||
newAccountTermAndPreClosure.setRenewalCycleNo(this.accountTermAndPreClosure.getRenewalCycleNo() + 1);
|
||||
|
||||
// Without this the renewed deposit has no maturity instruction, so it would mature once more and
|
||||
// then sit idle rather than rolling over again as the customer asked. Done here rather than in
|
||||
// the shared copy(), which Recurring Deposit renewal also uses.
|
||||
newAccountTermAndPreClosure.carryForwardStandingInstructionsFrom(this.accountTermAndPreClosure);
|
||||
|
||||
return reInvestedAccount;
|
||||
|
||||
}
|
||||
@@ -886,7 +1102,9 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
@Override
|
||||
public void loadLazyCollections() {
|
||||
super.loadLazyCollections();
|
||||
this.chart.getId();
|
||||
if (this.chart != null) {
|
||||
this.chart.getId();
|
||||
}
|
||||
}
|
||||
|
||||
public BigDecimal getDepositAmount() {
|
||||
@@ -902,6 +1120,52 @@ public class FixedDepositAccount extends SavingsAccount {
|
||||
return SavingsAccountStatusType.MATURED.getValue().equals(this.status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposes the parent class's protected lock-in check to callers outside this class hierarchy. Needed by the
|
||||
* Payment action's domain-service method, which enforces this itself for its reinvest branches rather than going
|
||||
* through {@link #prematureClosure}, since those branches keep the account open on the same term instead of
|
||||
* closing it.
|
||||
*/
|
||||
public boolean isLockedOnDate(final LocalDate transactionDate) {
|
||||
return isAccountLocked(transactionDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* The date guards {@link #close} and {@link #prematureClosure} apply, minus the maturity-date bound, for a Payment
|
||||
* that renews the deposit instead of closing it and so never reaches either of those methods.
|
||||
* <p>
|
||||
* Dropping the maturity bound is the point: Payment is allowed on an already-matured deposit. The other three
|
||||
* matter more here than they do on a closure, because a renewal turns this date into the new term's interest
|
||||
* pivot -- backdate it behind interest that has already been posted and the engine regenerates those posting
|
||||
* periods, reverses the settled postings and re-posts them, which is exactly what the pivot exists to prevent.
|
||||
*/
|
||||
public void validateRenewalDate(final LocalDate renewedOn) {
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + DepositsApiConstants.preMatureCloseAction);
|
||||
|
||||
if (DateUtils.isAfterBusinessDate(renewedOn)) {
|
||||
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(renewedOn)
|
||||
.failWithCode("cannot.be.a.future.date");
|
||||
}
|
||||
if (DateUtils.isBefore(renewedOn, getActivationDate())) {
|
||||
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(renewedOn)
|
||||
.failWithCode("must.be.after.activation.date");
|
||||
}
|
||||
final List<SavingsAccountTransaction> savingsAccountTransactions = retrieveListOfTransactions();
|
||||
if (!savingsAccountTransactions.isEmpty()) {
|
||||
final SavingsAccountTransaction lastTransaction = savingsAccountTransactions.get(savingsAccountTransactions.size() - 1);
|
||||
if (lastTransaction.isAfter(renewedOn)) {
|
||||
baseDataValidator.reset().parameter(SavingsApiConstants.closedOnDateParamName).value(renewedOn)
|
||||
.failWithCode("must.be.after.last.transaction.date");
|
||||
}
|
||||
}
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public void setClosedOnDate(final LocalDate closedOnDate) {
|
||||
this.closedOnDate = closedOnDate;
|
||||
}
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* One slab of the full tenure-by-rate chart a term of an FD was priced on, archived against that term's
|
||||
* {@link FixedDepositRenewalHistory} row.
|
||||
* <p>
|
||||
* {@code renewInPlace} reuses the same account row across renewals, overwriting the account's own interest-rate chart in
|
||||
* place at every renewal. {@code FixedDepositRenewalHistory} preserves the single effective rate that resulted, but not
|
||||
* the chart it came from -- this table is what lets a later query answer "what did the whole rate card look like during
|
||||
* term 2", not just "what rate applied".
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "m_fd_renewal_chart_slab_history")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class FixedDepositRenewalChartSlabHistory {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "fd_renewal_history_id", nullable = false)
|
||||
private Long fdRenewalHistoryId;
|
||||
|
||||
@Column(name = "chart_name", length = 100)
|
||||
private String chartName;
|
||||
|
||||
@Column(name = "description", length = 200)
|
||||
private String description;
|
||||
|
||||
@Column(name = "period_type_enum")
|
||||
private Integer periodTypeEnum;
|
||||
|
||||
@Column(name = "from_period")
|
||||
private Integer fromPeriod;
|
||||
|
||||
@Column(name = "to_period")
|
||||
private Integer toPeriod;
|
||||
|
||||
@Column(name = "amount_range_from", scale = 6, precision = 19)
|
||||
private BigDecimal amountRangeFrom;
|
||||
|
||||
@Column(name = "amount_range_to", scale = 6, precision = 19)
|
||||
private BigDecimal amountRangeTo;
|
||||
|
||||
@Column(name = "annual_interest_rate", scale = 6, precision = 19)
|
||||
private BigDecimal annualInterestRate;
|
||||
|
||||
@Column(name = "currency_code", length = 3)
|
||||
private String currencyCode;
|
||||
|
||||
/**
|
||||
* The senior-citizen premium published for this tenure band at the time this term was priced, carried through from the
|
||||
* CBS Base Interest Rates screen rather than looked up live against whatever is published now. Null when the term was
|
||||
* priced off the product's own chart (which has no senior-citizen concept) or predates this column.
|
||||
*/
|
||||
@Column(name = "senior_citizen_rate", scale = 6, precision = 19)
|
||||
private BigDecimal seniorCitizenRate;
|
||||
|
||||
public static FixedDepositRenewalChartSlabHistory create(final Long fdRenewalHistoryId, final String chartName,
|
||||
final String description, final Integer periodTypeEnum, final Integer fromPeriod, final Integer toPeriod,
|
||||
final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo, final BigDecimal annualInterestRate,
|
||||
final String currencyCode, final BigDecimal seniorCitizenRate) {
|
||||
final FixedDepositRenewalChartSlabHistory slab = new FixedDepositRenewalChartSlabHistory();
|
||||
slab.fdRenewalHistoryId = fdRenewalHistoryId;
|
||||
slab.chartName = chartName;
|
||||
slab.description = description;
|
||||
slab.periodTypeEnum = periodTypeEnum;
|
||||
slab.fromPeriod = fromPeriod;
|
||||
slab.toPeriod = toPeriod;
|
||||
slab.amountRangeFrom = amountRangeFrom;
|
||||
slab.amountRangeTo = amountRangeTo;
|
||||
slab.annualInterestRate = annualInterestRate;
|
||||
slab.currencyCode = currencyCode;
|
||||
slab.seniorCitizenRate = seniorCitizenRate;
|
||||
return slab;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.domain;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface FixedDepositRenewalChartSlabHistoryRepository extends JpaRepository<FixedDepositRenewalChartSlabHistory, Long> {
|
||||
|
||||
/** The full chart a term was priced on, unordered -- callers typically sort by fromPeriod for display. */
|
||||
List<FixedDepositRenewalChartSlabHistory> findByFdRenewalHistoryId(Long fdRenewalHistoryId);
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.domain;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* One row per term of one logical Fixed Deposit, recording the renewal event that started it.
|
||||
* <p>
|
||||
* Each term runs as its own deposit instance (its own {@code m_savings_account} row) so that term keeps an immutable
|
||||
* ledger, interest postings and GL entries, while {@link #fdAccountNumber} stays the same across the whole chain and is
|
||||
* what the customer sees. What that structure alone cannot tell you is the intent and outcome of each rollover, which is
|
||||
* what this table captures: the previous term's principal and interest earned, what it matured at, how much was carried
|
||||
* forward, the rate applied to the new term, whether the renewal ran automatically at maturity or was performed by a
|
||||
* user, and by whom.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "m_fd_renewal_history")
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public class FixedDepositRenewalHistory {
|
||||
|
||||
/** Renewal ran automatically when the maturity job processed the account's maturity instruction. */
|
||||
public static final String RENEWAL_TYPE_AUTO = "AUTO";
|
||||
/** A user closed the account with a re-invest instruction. */
|
||||
public static final String RENEWAL_TYPE_MANUAL = "MANUAL";
|
||||
|
||||
public static final String STATUS_ACTIVE = "ACTIVE";
|
||||
public static final String STATUS_MATURED = "MATURED";
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
/** The stable customer-facing FD number, shared by every term in the chain. */
|
||||
@Column(name = "fd_account_number", length = 20, nullable = false)
|
||||
private String fdAccountNumber;
|
||||
|
||||
/** The account the customer originally opened, i.e. the anchor of the chain. */
|
||||
@Column(name = "original_savings_account_id", nullable = false)
|
||||
private Long originalSavingsAccountId;
|
||||
|
||||
/** The deposit instance this term runs on. */
|
||||
@Column(name = "savings_account_id", nullable = false)
|
||||
private Long savingsAccountId;
|
||||
|
||||
/** The term this one was renewed from; null on the chain's first row. */
|
||||
@Column(name = "previous_savings_account_id")
|
||||
private Long previousSavingsAccountId;
|
||||
|
||||
@Column(name = "previous_renewal_id")
|
||||
private Long previousRenewalId;
|
||||
|
||||
/** 0 for the originally opened term, 1 for the first renewal, and so on. */
|
||||
@Column(name = "renewal_no", nullable = false)
|
||||
private Integer renewalNo;
|
||||
|
||||
@Column(name = "previous_principal", scale = 6, precision = 19)
|
||||
private BigDecimal previousPrincipal;
|
||||
|
||||
@Column(name = "interest_earned", scale = 6, precision = 19)
|
||||
private BigDecimal interestEarned;
|
||||
|
||||
@Column(name = "maturity_amount", scale = 6, precision = 19)
|
||||
private BigDecimal maturityAmount;
|
||||
|
||||
/** What actually carried into this term: the full maturity amount, or principal only. */
|
||||
@Column(name = "renewed_amount", scale = 6, precision = 19)
|
||||
private BigDecimal renewedAmount;
|
||||
|
||||
@Column(name = "interest_rate", scale = 6, precision = 19)
|
||||
private BigDecimal interestRate;
|
||||
|
||||
@Column(name = "start_date")
|
||||
private LocalDate startDate;
|
||||
|
||||
@Column(name = "maturity_date")
|
||||
private LocalDate maturityDate;
|
||||
|
||||
@Column(name = "tenure")
|
||||
private Integer tenure;
|
||||
|
||||
@Column(name = "tenure_frequency_enum")
|
||||
private Integer tenureFrequencyEnum;
|
||||
|
||||
@Column(name = "renewal_type", length = 10)
|
||||
private String renewalType;
|
||||
|
||||
@Column(name = "renewal_status", length = 20)
|
||||
private String renewalStatus;
|
||||
|
||||
@Column(name = "renewed_on")
|
||||
private LocalDate renewedOn;
|
||||
|
||||
@Column(name = "created_by_id")
|
||||
private Long createdById;
|
||||
|
||||
public static FixedDepositRenewalHistory create(final String fdAccountNumber, final Long originalSavingsAccountId,
|
||||
final Long savingsAccountId, final Long previousSavingsAccountId, final Long previousRenewalId, final Integer renewalNo,
|
||||
final BigDecimal previousPrincipal, final BigDecimal interestEarned, final BigDecimal maturityAmount,
|
||||
final BigDecimal renewedAmount, final BigDecimal interestRate, final LocalDate startDate, final LocalDate maturityDate,
|
||||
final Integer tenure, final Integer tenureFrequencyEnum, final String renewalType, final LocalDate renewedOn,
|
||||
final Long createdById) {
|
||||
final FixedDepositRenewalHistory history = new FixedDepositRenewalHistory();
|
||||
history.fdAccountNumber = fdAccountNumber;
|
||||
history.originalSavingsAccountId = originalSavingsAccountId;
|
||||
history.savingsAccountId = savingsAccountId;
|
||||
history.previousSavingsAccountId = previousSavingsAccountId;
|
||||
history.previousRenewalId = previousRenewalId;
|
||||
history.renewalNo = renewalNo;
|
||||
history.previousPrincipal = previousPrincipal;
|
||||
history.interestEarned = interestEarned;
|
||||
history.maturityAmount = maturityAmount;
|
||||
history.renewedAmount = renewedAmount;
|
||||
history.interestRate = interestRate;
|
||||
history.startDate = startDate;
|
||||
history.maturityDate = maturityDate;
|
||||
history.tenure = tenure;
|
||||
history.tenureFrequencyEnum = tenureFrequencyEnum;
|
||||
history.renewalType = renewalType;
|
||||
history.renewalStatus = STATUS_ACTIVE;
|
||||
history.renewedOn = renewedOn;
|
||||
history.createdById = createdById;
|
||||
return history;
|
||||
}
|
||||
|
||||
/** Called on the previous term's row once its successor takes over. */
|
||||
public void markMatured() {
|
||||
this.renewalStatus = STATUS_MATURED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills in what this term actually earned and matured at, which is only known once it closes. Written on the term's
|
||||
* own row so each term reports its own outcome rather than that of its predecessor.
|
||||
*/
|
||||
public void recordOutcome(final BigDecimal interestEarned, final BigDecimal maturityAmount) {
|
||||
this.interestEarned = interestEarned;
|
||||
this.maturityAmount = maturityAmount;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.domain;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface FixedDepositRenewalHistoryRepository extends JpaRepository<FixedDepositRenewalHistory, Long> {
|
||||
|
||||
/** One FD's whole history, oldest term first. */
|
||||
List<FixedDepositRenewalHistory> findByFdAccountNumberOrderByRenewalNoAsc(String fdAccountNumber);
|
||||
|
||||
/**
|
||||
* An account's terms, newest first.
|
||||
* <p>
|
||||
* Deliberately a list, not a single row: an FD that renews on the same account has one row per term all pointing at
|
||||
* that one account, so callers wanting the term currently running take the first element. Empty for an account that
|
||||
* pre-dates this table or was never renewed.
|
||||
*/
|
||||
List<FixedDepositRenewalHistory> findBySavingsAccountIdOrderByRenewalNoDesc(Long savingsAccountId);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.handler;
|
||||
|
||||
import org.apache.fineract.commands.annotation.CommandType;
|
||||
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.portfolio.savings.service.DepositAccountWritePlatformService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@CommandType(entity = "FIXEDDEPOSITACCOUNT", action = "PAYMENT")
|
||||
public class PaymentFixedDepositAccountCommandHandler implements NewCommandSourceHandler {
|
||||
|
||||
private final DepositAccountWritePlatformService depositAccountWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
public PaymentFixedDepositAccountCommandHandler(final DepositAccountWritePlatformService depositAccountWritePlatformService) {
|
||||
this.depositAccountWritePlatformService = depositAccountWritePlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||
return this.depositAccountWritePlatformService.processFdPayment(command.entityId(), command);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -189,6 +189,7 @@ public class DepositAccountInterestRateChartReadPlatformServiceImpl implements D
|
||||
.append("ircd.id as ircdId, ircd.description as ircdDescription, ircd.period_type_enum ircdPeriodTypeId, ")
|
||||
.append("ircd.from_period as ircdFromPeriod, ircd.to_period as ircdToPeriod, ircd.amount_range_from as ircdAmountRangeFrom, ")
|
||||
.append("ircd.amount_range_to as ircdAmountRangeTo, ircd.annual_interest_rate as ircdAnnualInterestRate, ")
|
||||
.append("ircd.senior_citizen_rate as ircdSeniorCitizenRate, ")
|
||||
.append("curr.code as currencyCode, curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, ")
|
||||
.append("curr.display_symbol as currencyDisplaySymbol, curr.decimal_places as currencyDigits, curr.currency_multiplesof as inMultiplesOf, ")
|
||||
.append("sa.id as accountId, sa.account_no as accountNumber, ").append("iri.id as iriId, ")
|
||||
@@ -346,6 +347,7 @@ public class DepositAccountInterestRateChartReadPlatformServiceImpl implements D
|
||||
final BigDecimal amountRangeFrom = rs.getBigDecimal("ircdAmountRangeFrom");
|
||||
final BigDecimal amountRangeTo = rs.getBigDecimal("ircdAmountRangeTo");
|
||||
final BigDecimal annualInterestRate = rs.getBigDecimal("ircdAnnualInterestRate");
|
||||
final BigDecimal seniorCitizenRate = rs.getBigDecimal("ircdSeniorCitizenRate");
|
||||
|
||||
// currency Slabs
|
||||
final String currencyCode = rs.getString("currencyCode");
|
||||
@@ -359,7 +361,7 @@ public class DepositAccountInterestRateChartReadPlatformServiceImpl implements D
|
||||
currencyNameCode);
|
||||
|
||||
return DepositAccountInterestRateChartSlabData.instance(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom,
|
||||
amountRangeTo, annualInterestRate, currency);
|
||||
amountRangeTo, annualInterestRate, currency, seniorCitizenRate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -46,6 +46,12 @@ public interface DepositAccountReadPlatformService {
|
||||
|
||||
DepositAccountData retrieveOneWithClosureTemplate(DepositAccountType depositAccountType, Long accountId);
|
||||
|
||||
/**
|
||||
* As {@link #retrieveOneWithClosureTemplate}, but for the FD Payment action -- so its option list also carries
|
||||
* PARTIAL_REINVEST, which the closure commands deliberately exclude because only Payment implements it.
|
||||
*/
|
||||
DepositAccountData retrieveOneWithPaymentTemplate(DepositAccountType depositAccountType, Long accountId);
|
||||
|
||||
DepositAccountData retrieveOneWithChartSlabs(DepositAccountType depositAccountType, Long productId);
|
||||
|
||||
Collection<SavingsAccountTransactionData> retrieveAllTransactions(DepositAccountType depositAccountType, Long accountId);
|
||||
|
||||
+180
-1
@@ -321,6 +321,9 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
((org.apache.fineract.portfolio.savings.data.RecurringDepositAccountData) account).setJointHolders(jointHolders);
|
||||
}
|
||||
}
|
||||
if (account instanceof org.apache.fineract.portfolio.savings.data.FixedDepositAccountData) {
|
||||
applyReinvestmentLinks((org.apache.fineract.portfolio.savings.data.FixedDepositAccountData) account, accountId);
|
||||
}
|
||||
}
|
||||
return account;
|
||||
|
||||
@@ -329,6 +332,158 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the "reinvested from" / "reinvested into" links on a Fixed Deposit account, so the
|
||||
* account-view page can show either direction of a "Re-Invest Maturity Amount"/"Re-Invest
|
||||
* Principal Only" closure. There is only one column (reinvested_from_savings_id, set on the NEW
|
||||
* account) -- "reinvested into" is found on the OLD account by reverse-looking up whichever row
|
||||
* points at it.
|
||||
*/
|
||||
private void applyReinvestmentLinks(final org.apache.fineract.portfolio.savings.data.FixedDepositAccountData result,
|
||||
final Long accountId) {
|
||||
final String fromSql = "select src.id as id, src.account_no as accountNo "
|
||||
+ "from m_deposit_account_term_and_preclosure t "
|
||||
+ "join m_savings_account src on src.id = t.reinvested_from_savings_id " + "where t.savings_account_id = ?";
|
||||
final String intoSql = "select dest.id as id, dest.account_no as accountNo "
|
||||
+ "from m_deposit_account_term_and_preclosure t " + "join m_savings_account dest on dest.id = t.savings_account_id "
|
||||
+ "where t.reinvested_from_savings_id = ?";
|
||||
|
||||
Long fromId = null;
|
||||
String fromNo = null;
|
||||
final java.util.List<java.util.Map<String, Object>> fromRows = this.jdbcTemplate.queryForList(fromSql, accountId);
|
||||
if (!fromRows.isEmpty()) {
|
||||
fromId = ((Number) fromRows.get(0).get("id")).longValue();
|
||||
fromNo = (String) fromRows.get(0).get("accountNo");
|
||||
}
|
||||
|
||||
Long intoId = null;
|
||||
String intoNo = null;
|
||||
final java.util.List<java.util.Map<String, Object>> intoRows = this.jdbcTemplate.queryForList(intoSql, accountId);
|
||||
if (!intoRows.isEmpty()) {
|
||||
intoId = ((Number) intoRows.get(0).get("id")).longValue();
|
||||
intoNo = (String) intoRows.get(0).get("accountNo");
|
||||
}
|
||||
|
||||
if (fromId != null || intoId != null) {
|
||||
result.setReinvestmentLinks(fromId, fromNo, intoId, intoNo);
|
||||
}
|
||||
|
||||
// The number to actually show as "the FD account number" -- the original account's account_no
|
||||
// if this account has been through a renewal, otherwise this account's own account_no.
|
||||
final String termSql = "select fd_account_number, renewal_cycle_no from m_deposit_account_term_and_preclosure "
|
||||
+ "where savings_account_id = ?";
|
||||
final java.util.List<java.util.Map<String, Object>> termRows = this.jdbcTemplate.queryForList(termSql, accountId);
|
||||
final String fdAccountNumber = termRows.isEmpty() ? null : (String) termRows.get(0).get("fd_account_number");
|
||||
final Object cycleNo = termRows.isEmpty() ? null : termRows.get(0).get("renewal_cycle_no");
|
||||
final String rootFdAccountNumber = fdAccountNumber != null ? fdAccountNumber : result.getAccountNo();
|
||||
result.setFdAccountNumber(rootFdAccountNumber);
|
||||
result.setRenewalCycleNo(cycleNo == null ? 0 : ((Number) cycleNo).intValue());
|
||||
result.setRenewalHistory(retrieveRenewalHistory(rootFdAccountNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* Every term of one logical FD, oldest first.
|
||||
* <p>
|
||||
* Driven by m_fd_renewal_history, which records each rollover event -- interest the closing term earned, what it
|
||||
* matured at, how much carried forward, the rate applied, automatic or by a user -- rather than deriving the chain by
|
||||
* joining account rows, which cannot express any of that. The account row is joined in for its number and live
|
||||
* status. Returns an empty list for an FD that has never been renewed, so callers can treat "has renewal history" as
|
||||
* simply a non-empty list.
|
||||
*/
|
||||
private java.util.List<java.util.Map<String, Object>> retrieveRenewalHistory(final String fdAccountNumber) {
|
||||
// Every row states its own term's figures, so this is a straight read: interest_earned and
|
||||
// maturity_amount are filled in when that term closes, and stay null on the term still running,
|
||||
// which the caller renders as its projected maturity instead.
|
||||
final String sql = "select h.id as historyId, h.renewal_no as renewalCycleNo, h.savings_account_id as accountId, "
|
||||
+ "sa.account_no as accountNo, h.renewed_amount as depositAmount, h.interest_rate as interestRate, "
|
||||
+ "h.start_date as activatedOnDate, h.maturity_date as maturityDate, h.tenure as tenure, "
|
||||
+ "h.tenure_frequency_enum as tenureFrequencyEnum, "
|
||||
+ "h.renewal_type as renewalType, h.renewal_status as renewalStatus, sa.status_enum as statusEnum, "
|
||||
+ "h.interest_earned as interestEarned, h.maturity_amount as maturedAmount, "
|
||||
+ "t.maturity_amount as projectedMaturityAmount " + "from m_fd_renewal_history h "
|
||||
+ "join m_savings_account sa on sa.id = h.savings_account_id "
|
||||
+ "left join m_deposit_account_term_and_preclosure t on t.savings_account_id = sa.id "
|
||||
+ "where h.fd_account_number = ? " + "order by h.renewal_no asc";
|
||||
final java.util.List<java.util.Map<String, Object>> rows = this.jdbcTemplate.queryForList(sql, fdAccountNumber);
|
||||
// Any row here is a renewal event that was actually recorded, so even one is worth returning --
|
||||
// discarding a lone row used to hide a genuine renewal (and its interest figure) behind the
|
||||
// account-derived fallback, which then returned nothing at all for it.
|
||||
if (!rows.isEmpty()) {
|
||||
attachArchivedChartSlabs(rows);
|
||||
return rows;
|
||||
}
|
||||
// Chains that renewed before m_fd_renewal_history existed have no rows to read, so fall back to
|
||||
// reconstructing what the account rows alone can tell us. The per-term interest/renewal-type
|
||||
// columns are simply absent for those, which the UI renders as blanks rather than wrong values.
|
||||
return retrieveRenewalHistoryFromAccounts(fdAccountNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches each term's archived rate-by-tenure chart (as a "chartSlabs" list) onto its own row.
|
||||
* <p>
|
||||
* A term's chart is only archived when it closes via an in-place renewal (see
|
||||
* {@code DepositAccountDomainServiceJpa#archiveChartSlabs}), so the currently-running term and any term from before
|
||||
* that archiving existed simply get an empty list here -- callers should fall back to the account's live
|
||||
* accountChart.chartSlabs for those. Fetched in one batched query keyed by history id, not one query per row, since
|
||||
* this runs once per FD account view.
|
||||
*/
|
||||
private void attachArchivedChartSlabs(final java.util.List<java.util.Map<String, Object>> rows) {
|
||||
final java.util.List<Long> historyIds = new java.util.ArrayList<>();
|
||||
for (final java.util.Map<String, Object> row : rows) {
|
||||
final Object id = row.get("historyId");
|
||||
if (id != null) {
|
||||
historyIds.add(((Number) id).longValue());
|
||||
}
|
||||
}
|
||||
if (historyIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final String placeholders = String.join(",", java.util.Collections.nCopies(historyIds.size(), "?"));
|
||||
final String sql = "select fd_renewal_history_id as historyId, chart_name as chartName, description, "
|
||||
+ "period_type_enum as periodTypeEnum, from_period as fromPeriod, to_period as toPeriod, "
|
||||
+ "annual_interest_rate as annualInterestRate, senior_citizen_rate as seniorCitizenRate "
|
||||
+ "from m_fd_renewal_chart_slab_history " + "where fd_renewal_history_id in (" + placeholders + ") "
|
||||
+ "order by from_period asc";
|
||||
final java.util.List<java.util.Map<String, Object>> slabRows = this.jdbcTemplate.queryForList(sql, historyIds.toArray());
|
||||
|
||||
final java.util.Map<Long, java.util.List<java.util.Map<String, Object>>> slabsByHistoryId = new java.util.HashMap<>();
|
||||
for (final java.util.Map<String, Object> slabRow : slabRows) {
|
||||
final Long historyId = ((Number) slabRow.remove("historyId")).longValue();
|
||||
slabsByHistoryId.computeIfAbsent(historyId, key -> new java.util.ArrayList<>()).add(slabRow);
|
||||
}
|
||||
|
||||
for (final java.util.Map<String, Object> row : rows) {
|
||||
final Object id = row.get("historyId");
|
||||
final Long historyId = id == null ? null : ((Number) id).longValue();
|
||||
row.put("chartSlabs", slabsByHistoryId.getOrDefault(historyId, java.util.Collections.emptyList()));
|
||||
}
|
||||
}
|
||||
|
||||
private java.util.List<java.util.Map<String, Object>> retrieveRenewalHistoryFromAccounts(final String fdAccountNumber) {
|
||||
// Deliberately emits the SAME column labels as retrieveRenewalHistory above, so a caller never has
|
||||
// to know which path produced the rows. What the account rows genuinely cannot tell us -- each
|
||||
// term's interest earned, and whether the rollover was automatic or done by staff -- is returned as
|
||||
// an explicit null rather than omitted, so those render as blanks instead of the previous behaviour
|
||||
// where a missing renewalStatus made every term, including the running one, look matured.
|
||||
final String sql = "select null as historyId, coalesce(t.renewal_cycle_no, 0) as renewalCycleNo, "
|
||||
+ "sa.id as accountId, sa.account_no as accountNo, t.deposit_amount as depositAmount, "
|
||||
+ "sa.nominal_annual_interest_rate as interestRate, sa.activatedon_date as activatedOnDate, "
|
||||
+ "t.maturity_date as maturityDate, t.deposit_period as tenure, "
|
||||
+ "t.deposit_period_frequency_enum as tenureFrequencyEnum, null as renewalType, "
|
||||
+ "case when sa.status_enum = 300 then 'ACTIVE' else 'MATURED' end as renewalStatus, "
|
||||
+ "sa.status_enum as statusEnum, null as interestEarned, "
|
||||
+ "case when sa.status_enum = 300 then null else t.maturity_amount end as maturedAmount, "
|
||||
+ "case when sa.status_enum = 300 then t.maturity_amount else null end as projectedMaturityAmount "
|
||||
+ "from m_savings_account sa "
|
||||
+ "join m_deposit_account_term_and_preclosure t on t.savings_account_id = sa.id "
|
||||
+ "where sa.account_no = ? or t.fd_account_number = ? " + "order by coalesce(t.renewal_cycle_no, 0) asc";
|
||||
final java.util.List<java.util.Map<String, Object>> rows = this.jdbcTemplate.queryForList(sql, fdAccountNumber,
|
||||
fdAccountNumber);
|
||||
// A single row here means this FD simply never renewed -- one account, one term -- so there is no
|
||||
// history to show. Unlike the primary path, where even one recorded row is a real renewal event.
|
||||
return rows.size() > 1 ? rows : java.util.Collections.emptyList();
|
||||
}
|
||||
|
||||
private java.util.List<java.util.Map<String, Object>> retrieveJointHolders(final Long accountId) {
|
||||
final String sql = "SELECT jh.id, jh.client_id, jh.cif_number, jh.display_name, "
|
||||
+ "jh.share_percentage, jh.signing_authority, jh.role, jh.is_primary, jh.is_mandatory "
|
||||
@@ -349,8 +504,30 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
}, accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closure options for the {@code close} and {@code prematureClose} commands. PARTIAL_REINVEST is excluded: only the
|
||||
* Payment command's handler implements it, and only its dialog collects the kept-amount and destination account it
|
||||
* needs. Offered here it would appear in the FD and RD close dialogs, where the closure handlers have no branch for
|
||||
* it and would fall through to paying the whole balance out in cash.
|
||||
*/
|
||||
@Override
|
||||
public DepositAccountData retrieveOneWithClosureTemplate(final DepositAccountType depositAccountType, final Long accountId) {
|
||||
final boolean includePartialReinvest = false;
|
||||
return retrieveOneWithClosureTemplate(depositAccountType, accountId, includePartialReinvest);
|
||||
}
|
||||
|
||||
/**
|
||||
* The same template, but including PARTIAL_REINVEST -- for the Payment command, which is the one action that
|
||||
* implements it.
|
||||
*/
|
||||
@Override
|
||||
public DepositAccountData retrieveOneWithPaymentTemplate(final DepositAccountType depositAccountType, final Long accountId) {
|
||||
final boolean includePartialReinvest = true;
|
||||
return retrieveOneWithClosureTemplate(depositAccountType, accountId, includePartialReinvest);
|
||||
}
|
||||
|
||||
private DepositAccountData retrieveOneWithClosureTemplate(final DepositAccountType depositAccountType, final Long accountId,
|
||||
final boolean includePartialReinvest) {
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
@@ -367,7 +544,9 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
DepositAccountData account = this.jdbcTemplate.queryForObject(sqlBuilder.toString(), depositAccountMapper, accountId,
|
||||
depositAccountType.getValue());
|
||||
Collection<EnumOptionData> onAccountClosureOptions = SavingsEnumerations
|
||||
.depositAccountOnClosureType(DepositAccountOnClosureType.values());
|
||||
.depositAccountOnClosureType(Arrays.stream(DepositAccountOnClosureType.values())
|
||||
.filter(type -> includePartialReinvest || !type.isPartialReinvest())
|
||||
.toArray(DepositAccountOnClosureType[]::new));
|
||||
final Collection<PaymentTypeData> paymentTypeOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
|
||||
final Collection<SavingsAccountData> savingsAccountDatas = this.savingsAccountReadPlatformService
|
||||
.retrieveActiveForLookup(account.getClientId(), DepositAccountType.SAVINGS_DEPOSIT);
|
||||
|
||||
+74
-2
@@ -48,6 +48,7 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
||||
import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformServiceUnavailableException;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
@@ -912,6 +913,67 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult processFdPayment(final Long savingsId, final JsonCommand command) {
|
||||
final AppUser user = this.context.authenticatedUser();
|
||||
|
||||
this.depositAccountTransactionDataValidator.validatePayment(command);
|
||||
|
||||
final Map<String, Object> changes = new LinkedHashMap<>();
|
||||
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
|
||||
|
||||
// Payment intentionally spans both states -- unlike Close (Matured only) and Premature Close
|
||||
// (Active only) -- but it must still be one of those two. Without this, a closed or
|
||||
// pre-maturely-closed deposit could be reopened: the reinvest branches put the account back to
|
||||
// ACTIVE and never reach the close()/prematureClosure() calls that would otherwise reject it.
|
||||
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
||||
DepositAccountType.FIXED_DEPOSIT);
|
||||
if (!account.isActive() && !account.isMatured()) {
|
||||
throw new GeneralPlatformDomainRuleException("error.msg.fixeddeposit.payment.account.not.active.or.matured",
|
||||
"Payment can only be processed on an active or matured fixed deposit account.", savingsId);
|
||||
}
|
||||
checkClientOrGroupActive(account);
|
||||
|
||||
this.depositAccountDomainService.handleFDAccountPayment(account, paymentDetail, user, command, changes);
|
||||
|
||||
// Reinvest Principal Only opens a second account and the domain method withdrew the principal out
|
||||
// of this one against the transfer-suspense GL. Post the matching credit leg so the funds actually
|
||||
// land in the new deposit -- same sequence updateMaturityDetails() uses for the automated path.
|
||||
if (changes.get("reinvestedDepositId") != null) {
|
||||
final Long reinvestedDepositId = (Long) changes.get("reinvestedDepositId");
|
||||
final FixedDepositAccount reinvestAccount = (FixedDepositAccount) this.depositAccountAssembler
|
||||
.assembleFrom(reinvestedDepositId, DepositAccountType.FIXED_DEPOSIT);
|
||||
Money amountForDeposit = Money.of(reinvestAccount.getCurrency(), reinvestAccount.getDepositAmount());
|
||||
final Money activationChargeAmount = getActivationCharge(reinvestAccount);
|
||||
if (activationChargeAmount.isGreaterThanZero()) {
|
||||
payActivationCharge(reinvestAccount);
|
||||
amountForDeposit = amountForDeposit.plus(activationChargeAmount);
|
||||
}
|
||||
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(command.extractLocale());
|
||||
final LocalDate closedOnDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
||||
final boolean isInternalTransferLeg = true;
|
||||
this.depositAccountDomainService.handleFDDeposit(reinvestAccount, fmt, closedOnDate, amountForDeposit.getAmount(), null,
|
||||
isInternalTransferLeg);
|
||||
}
|
||||
|
||||
final String noteText = command.stringValueOfParameterNamed("note");
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
final Note note = Note.savingNote(account, noteText);
|
||||
changes.put("note", noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
.withEntityId(savingsId) //
|
||||
.withOfficeId(account.officeId()) //
|
||||
.withClientId(account.clientId()) //
|
||||
.withGroupId(account.groupId()) //
|
||||
.withSavingsId(savingsId) //
|
||||
.with(changes)//
|
||||
.build();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult prematureCloseRDAccount(final Long savingsId, final JsonCommand command) {
|
||||
final AppUser user = this.context.authenticatedUser();
|
||||
@@ -1404,16 +1466,26 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
|
||||
if (changes.get("reinvestedDepositId") != null) {
|
||||
Long reinvestedDepositId = (Long) changes.get("reinvestedDepositId");
|
||||
Money amountForDeposit = account.activateWithBalance();
|
||||
final FixedDepositAccount reinvestAccount = (FixedDepositAccount) this.depositAccountAssembler
|
||||
.assembleFrom(reinvestedDepositId, DepositAccountType.FIXED_DEPOSIT);
|
||||
// activateWithBalance() always returns zero here -- it exists to stop a manually
|
||||
// opened FD from auto-crediting itself at activation (funding is supposed to be a
|
||||
// separate, clerk-posted deposit). A reinvestment isn't that: the balance was just
|
||||
// withdrawn from the matured account and needs to land in the new one as part of
|
||||
// this same automated closure, so it has to come from what reInvest() actually
|
||||
// carried over onto the new account, not from that unrelated activation guard.
|
||||
Money amountForDeposit = Money.of(reinvestAccount.getCurrency(), reinvestAccount.getDepositAmount());
|
||||
Money activationChargeAmount = getActivationCharge(reinvestAccount);
|
||||
if (activationChargeAmount.isGreaterThanZero()) {
|
||||
payActivationCharge(reinvestAccount);
|
||||
amountForDeposit = amountForDeposit.plus(activationChargeAmount);
|
||||
}
|
||||
// Matching internal-transfer leg for the withdrawal the closure just made on the
|
||||
// matured account: the funds never touch cash, so this posts against the
|
||||
// transfer-suspense GL instead of debiting cash/vault.
|
||||
final boolean isInternalTransferLeg = true;
|
||||
this.depositAccountDomainService.handleFDDeposit(reinvestAccount, fmt, fdAccount.maturityDate(),
|
||||
amountForDeposit.getAmount(), null);
|
||||
amountForDeposit.getAmount(), null, isInternalTransferLeg);
|
||||
}
|
||||
}
|
||||
} else if (depositAccountType.isRecurringDeposit()) {
|
||||
|
||||
@@ -537,5 +537,13 @@
|
||||
<include file="parts/0467_add_welcome_kit_return_tracking.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0468_add_address_id_to_welcome_kit_dispatch.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0469_create_database_export_request.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0470_create_loan_product_cbs_ext.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0470_add_reinvested_from_to_deposit_term.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0471_add_fd_account_number_to_deposit_term.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0472_add_renewal_cycle_no_to_deposit_term.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0473_create_fd_renewal_history.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0474_add_is_active_to_interest_rate_chart.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0475_create_fd_renewal_chart_slab_history.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0476_add_senior_citizen_rate_to_account_chart_slab.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0477_add_senior_citizen_rate_to_fd_renewal_chart_slab_history.xml" relativeToChangelogFile="true"/>
|
||||
<include file="parts/0478_add_fd_payment_permission.xml" relativeToChangelogFile="true"/>
|
||||
</databaseChangeLog>
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- On "Re-Invest Maturity Amount"/"Re-Invest Principal Only" closure, a brand new FD/RD account is
|
||||
auto-created with no visible link back to the matured account it came from, so staff had no way
|
||||
to trace one from the other. This column, set on the NEW account, points at the OLD one; the OLD
|
||||
account's own "reinvested into" side is derived by looking up whichever row has this account's id
|
||||
here, so only one column is needed to track the relationship in both directions. -->
|
||||
<changeSet id="0470_add_reinvested_from_to_deposit_term" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<columnExists tableName="m_deposit_account_term_and_preclosure" columnName="reinvested_from_savings_id"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<addColumn tableName="m_deposit_account_term_and_preclosure">
|
||||
<column name="reinvested_from_savings_id" type="BIGINT"/>
|
||||
</addColumn>
|
||||
<createIndex indexName="reinvested_from_savings_id" tableName="m_deposit_account_term_and_preclosure">
|
||||
<column name="reinvested_from_savings_id"/>
|
||||
</createIndex>
|
||||
<addForeignKeyConstraint baseColumnNames="reinvested_from_savings_id"
|
||||
baseTableName="m_deposit_account_term_and_preclosure"
|
||||
constraintName="m_deposit_account_term_and_preclosure_reinvested_from_ibfk"
|
||||
deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT"
|
||||
referencedColumnNames="id" referencedTableName="m_savings_account" validate="true"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
-377
@@ -1,377 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- The legacy "Account Type Creation" screen carries a large block of product configuration that
|
||||
Fineract's own loan product schema has no home for - cheque book rules, channel and transaction
|
||||
limits, credit bureau account types, the older interest parameters, and a set of extra GL
|
||||
mappings. Those fields were being collected by the create/edit form and then dropped before the
|
||||
request was sent, so nothing survived a page reload.
|
||||
|
||||
They live in a satellite table keyed 1:1 on the loan product rather than as more columns on
|
||||
m_product_loan: the set is specific to this deployment, and keeping it separate means an upstream
|
||||
Fineract change to m_product_loan will never collide with it. Typed columns rather than a JSON
|
||||
blob because loan account creation reads these at origination time, so they need to be queryable
|
||||
and compile-checked, not string-keyed. -->
|
||||
<changeSet id="0470_create_loan_product_cbs_ext" author="CBS" runOnChange="false">
|
||||
<createTable tableName="m_product_loan_cbs_ext">
|
||||
<column name="loan_product_id" type="BIGINT">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
|
||||
<!-- classification & legacy header fields (24) -->
|
||||
<column name="product_type_group" type="VARCHAR(20)"/>
|
||||
<column name="product_type_sub_group" type="VARCHAR(30)"/>
|
||||
<column name="debit_int_calculation" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="separate_penal_interest" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="credit_int_calculation" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="sub_account_type_balance" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="final_int_rounding" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="rounding_up_to" type="INTEGER"/>
|
||||
<column name="account_type_code" type="VARCHAR(10)"/>
|
||||
<column name="micr_transaction_code" type="VARCHAR(100)"/>
|
||||
<column name="reserved_ecs_serial_number" type="VARCHAR(100)"/>
|
||||
<column name="reverse_ecs_number" type="VARCHAR(100)"/>
|
||||
<column name="lock_cheque_info_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="lock_page_two_info_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="computerization_date" type="DATE"/>
|
||||
<column name="cheque_print_description" type="VARCHAR(100)"/>
|
||||
<column name="pos_account_type_description" type="VARCHAR(100)"/>
|
||||
<column name="pfms_account_type" type="VARCHAR(100)"/>
|
||||
<column name="renewal_date_add_months" type="INTEGER"/>
|
||||
<column name="document_renewal_date_add_months" type="INTEGER"/>
|
||||
<column name="pps_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="is_write_off_account_type" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="write_off_account_type_code" type="VARCHAR(100)"/>
|
||||
<column name="renewal_grace_days" type="INTEGER"/>
|
||||
|
||||
<!-- Cheque Book Settings (10) -->
|
||||
<column name="cheque_book_issue_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="cheque_validation_required" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_first_cheque_book_free" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="cheque_printing_account_type" type="VARCHAR(30)"/>
|
||||
<column name="allow_withdrawal_slip_usage" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="maintain_cheque_book_stock_registry" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="free_cheque_books_per_year" type="DECIMAL(19,6)"/>
|
||||
<column name="allow_credit_by_cheque_number" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="credit_cheque_validation_required" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="grace_days_for_stock_statement" type="INTEGER"/>
|
||||
|
||||
<!-- Additional Product Settings (37) -->
|
||||
<column name="account_type_active_for_transactions" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="sub_type_activity_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="account_opening_charges" type="INTEGER"/>
|
||||
<column name="maximum_gold_loan_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="last_account_number_opened" type="VARCHAR(100)"/>
|
||||
<column name="customer_termination_allowed" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="charges_for_cash_credit_above_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="death_interest_gl_account" type="VARCHAR(100)"/>
|
||||
<column name="starting_ledger_number" type="INTEGER"/>
|
||||
<column name="ending_ledger_number" type="INTEGER"/>
|
||||
<column name="current_ledger_number" type="INTEGER"/>
|
||||
<column name="remittance_account_number" type="VARCHAR(100)"/>
|
||||
<column name="is_non_resident_indian_account" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="debit_clearing_gl_account" type="VARCHAR(100)"/>
|
||||
<column name="missed_call_alert_service_active" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="standing_instruction_charge_gl_account" type="VARCHAR(100)"/>
|
||||
<column name="standing_instruction_debit_charge_skip_option" type="VARCHAR(50)"/>
|
||||
<column name="opening_balance_multiplier_for_remittance_charges" type="DECIMAL(19,6)"/>
|
||||
<column name="gold_loan_packet_number_with_year_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="account_move_to_inoperative_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="generate_gl_diff_entry_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="sub_type_wise_gl_balance_generation_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="validate_before_deleting_debit_entry_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="rc_file_concept_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="account_close_zero_balance_in_open_day_process" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="account_close_zero_balance_at_subledger_tran_entry" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="limit_enhancement_against_clearing_screen_display_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="advance_interest_parameter_in_ledger_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="vehicle_detail_in_master_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="deleted_cheque_issue_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="dp_reduce_in_document_renewal_date_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="dp_reduce_in_renewal_date_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="auto_close_at_day_end_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="loan_rate_from_master_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="cheque_short_name" type="VARCHAR(100)"/>
|
||||
<column name="statement_print_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="nesl_code" type="VARCHAR(100)"/>
|
||||
|
||||
<!-- Interest Related Parameters (53) -->
|
||||
<column name="drawing_power_and_limit_generation_procedure" type="VARCHAR(100)"/>
|
||||
<column name="advances_interest_calculation_method" type="VARCHAR(100)"/>
|
||||
<column name="against_interest_calculation_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="day_wise_against_clearing_interest_rounding" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="interest_calculation_one_fourth_method" type="VARCHAR(20)"/>
|
||||
<column name="against_clearing_interest_procedure_type" type="VARCHAR(50)"/>
|
||||
<column name="consider_debit_closing_amount_for_against_clearing" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="interest_rounding_method" type="VARCHAR(30)"/>
|
||||
<column name="penalty_interest_calculation_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="penalty_interest_calculation_method" type="VARCHAR(30)"/>
|
||||
<column name="penalty_interest_procedure_number" type="VARCHAR(100)"/>
|
||||
<column name="overdrawn_interest_calculation_method" type="VARCHAR(50)"/>
|
||||
<column name="calculate_overdrawn_interest_after_renewal" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="interest_on_credit_balance" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="penalty_interest_date_different_than_regular_interest" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="fixed_deposit_overdraft_certificate_sort_order" type="VARCHAR(50)"/>
|
||||
<column name="use_document_submission_date_for_interest" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="loan_management_system_renewal_penalty_active" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="minimum_normal_interest_amount" type="DECIMAL(19,6)"/>
|
||||
<column name="minimum_interest_calculation_method" type="VARCHAR(50)"/>
|
||||
<column name="minimum_against_clearing_interest_amount" type="DECIMAL(19,6)"/>
|
||||
<column name="limit_increase_upto_interest_amount_in_interest_calculation" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="minimum_penalty_interest_amount" type="DECIMAL(19,6)"/>
|
||||
<column name="days_for_limit_increase_upto_interest_amount" type="INTEGER"/>
|
||||
<column name="additional_interest_rate_for_fixed_deposit_overdraft" type="DECIMAL(19,6)"/>
|
||||
<column name="consider_dd_payorder_in_against_clearing_interest_calculation" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="grace_days_after_renew_date" type="INTEGER"/>
|
||||
<column name="apply_undebited_interest_concept_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="interest_register_print_format_type" type="VARCHAR(50)"/>
|
||||
<column name="normal_grace_days_after_overdue" type="INTEGER"/>
|
||||
<column name="allow_against_clearing_entry" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="allow_no_balance_entry" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="fd_od_penalty_interest_combined_with_normal_interest" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="allow_no_balance_entry_with_password" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="undebited_simple_interest_account_wise" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="daily_interest_calculation_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="daily_interest_calculation_start_date" type="VARCHAR(100)"/>
|
||||
<column name="non_performing_asset_penal_interest_rate_update" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="non_performing_asset_penal_interest_rate" type="DECIMAL(19,6)"/>
|
||||
<column name="fd_od_penal_interest_rate_update_in_branch_process" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="add_penal_interest_rate" type="DECIMAL(19,6)"/>
|
||||
<column name="atyp14_simple_interest_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="fixed_deposit_overdraft_margin_type" type="VARCHAR(100)"/>
|
||||
<column name="check_master_detail_edited_passing_pending_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="credit_debit_interest_calculation_separate_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="on_time_interest_provision_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="check_against_clearing_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="gst_on_penalty_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="penalty_interest_grace_days" type="INTEGER"/>
|
||||
<column name="overdrawn_interest_rate" type="DECIMAL(19,6)"/>
|
||||
<column name="calculate_daily_limit_enhancement_tod_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="fixed_deposit_overdraft_multiple_interest_rate_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="grace_days_after_overdue_for_moratorium" type="INTEGER"/>
|
||||
|
||||
<!-- Credit Bureau Settings (CIBIL) (8) -->
|
||||
<column name="cibil_account_type" type="VARCHAR(100)"/>
|
||||
<column name="cibil_commercial_account_type" type="VARCHAR(100)"/>
|
||||
<column name="highmark_account_type" type="VARCHAR(100)"/>
|
||||
<column name="highmark_commercial_account_type" type="VARCHAR(100)"/>
|
||||
<column name="experian_account_type" type="VARCHAR(100)"/>
|
||||
<column name="experian_commercial_account_type" type="VARCHAR(100)"/>
|
||||
<column name="equifax_account_type" type="VARCHAR(100)"/>
|
||||
<column name="equifax_commercial_account_type" type="VARCHAR(100)"/>
|
||||
|
||||
<!-- RBI Compliance & Product Category (6) -->
|
||||
<column name="loan_product_category" type="VARCHAR(30)"/>
|
||||
<column name="penal_charge_method" type="VARCHAR(50)"/>
|
||||
<column name="is_floating_rate" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="foreclosure_charges_applicable" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="key_fact_statement_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="annual_percentage_rate_calculation_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
|
||||
<!-- Channel & Transaction Limits (23) -->
|
||||
<column name="is_mobile_app_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_atm_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="atm_yearly_charge_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="atm_minimum_balance" type="DECIMAL(19,6)"/>
|
||||
<column name="email_active_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_imps_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_upi_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_pos_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_bbps_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="inter_bank_limit_per_day" type="DECIMAL(19,6)"/>
|
||||
<column name="inter_bank_limit_per_transaction" type="DECIMAL(19,6)"/>
|
||||
<column name="neft_rtgs_limit_per_day" type="DECIMAL(19,6)"/>
|
||||
<column name="neft_rtgs_limit_per_transaction" type="DECIMAL(19,6)"/>
|
||||
<column name="neft_cutoff_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="rtgs_cutoff_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="neft_rtgs_minimum_balance" type="DECIMAL(19,6)"/>
|
||||
<column name="is_charge_required_neft_rtgs_cbs" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="is_charge_required_neft_rtgs_mobile" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="imps_limit_per_day" type="DECIMAL(19,6)"/>
|
||||
<column name="imps_limit_per_transaction" type="DECIMAL(19,6)"/>
|
||||
<column name="imps_limit_per_month" type="DECIMAL(19,6)"/>
|
||||
<column name="imps_min_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="imps_monthly_transaction_count" type="INTEGER"/>
|
||||
|
||||
<!-- POS Facility & ATM CSV Settings (10) -->
|
||||
<column name="max_per_transaction_limit_atm" type="DECIMAL(19,6)"/>
|
||||
<column name="max_day_transaction_limit_atm" type="DECIMAL(19,6)"/>
|
||||
<column name="max_per_transaction_limit_pos" type="DECIMAL(19,6)"/>
|
||||
<column name="max_day_transaction_limit_pos" type="DECIMAL(19,6)"/>
|
||||
<column name="max_per_transaction_limit_ecom" type="DECIMAL(19,6)"/>
|
||||
<column name="max_day_transaction_limit_ecom" type="DECIMAL(19,6)"/>
|
||||
<column name="max_per_transaction_limit_upi" type="DECIMAL(19,6)"/>
|
||||
<column name="max_day_transaction_limit_upi" type="DECIMAL(19,6)"/>
|
||||
<column name="atm_csv_product_code" type="VARCHAR(100)"/>
|
||||
<column name="atm_csv_type_code" type="VARCHAR(100)"/>
|
||||
|
||||
<!-- Auto Interest Post Parameters (4) -->
|
||||
<column name="auto_interest_post_type" type="VARCHAR(30)"/>
|
||||
<column name="auto_interest_post_when" type="VARCHAR(20)"/>
|
||||
<column name="auto_interest_post_fix_day" type="INTEGER"/>
|
||||
<column name="auto_last_interest_date" type="VARCHAR(100)"/>
|
||||
|
||||
<!-- Foreclosure / Early Account Closure (3) -->
|
||||
<column name="calculate_early_account_close_charge" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="early_account_close_charge" type="INTEGER"/>
|
||||
<column name="early_account_close_period_in_months" type="INTEGER"/>
|
||||
|
||||
<!-- Terms step (3) -->
|
||||
<column name="debit_balance_allow" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="allow_debit_trans_after_due_date" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="branch_level_account_type" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
|
||||
<!-- legacy cheque / standing instruction / minimum balance charges (24) -->
|
||||
<column name="cheque_book_charge_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="cheque_return_charge_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="ic_charge_debit_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="cash_bundle_charge_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="cash_bundle_charge_with_pan_limit" type="DECIMAL(19,6)"/>
|
||||
<column name="per_cheque_entry_charge" type="DECIMAL(19,6)"/>
|
||||
<column name="per_cheque_entry_service_charge" type="DECIMAL(19,6)"/>
|
||||
<column name="per_inward_cheque_entry_charge" type="DECIMAL(19,6)"/>
|
||||
<column name="per_outward_cheque_entry_charge" type="DECIMAL(19,6)"/>
|
||||
<column name="creditor_standing_instruction_fail_charge" type="DECIMAL(19,6)"/>
|
||||
<column name="debtor_standing_instruction_fail_charge" type="DECIMAL(19,6)"/>
|
||||
<column name="minimum_balance_checking_type" type="VARCHAR(20)"/>
|
||||
<column name="auto_minimum_balance_charge" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="calculate_daily_minimum_balance_charges" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="minimum_balance_charge_enabled" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="minimum_balance_charge_amount" type="DECIMAL(19,6)"/>
|
||||
<column name="minimum_balance_charge_for_cheque_issue" type="DECIMAL(19,6)"/>
|
||||
<column name="minimum_balance_charge_method" type="VARCHAR(20)"/>
|
||||
<column name="months_after_min_balance_charge_calculate" type="INTEGER"/>
|
||||
<column name="for_cheque_issue" type="DECIMAL(19,6)"/>
|
||||
<column name="for_cheque_issue_avg" type="DECIMAL(19,6)"/>
|
||||
<column name="for_withdrawal_slip" type="DECIMAL(19,6)"/>
|
||||
<column name="for_withdrawal_slip_avg" type="DECIMAL(19,6)"/>
|
||||
<column name="calculate_daily_against_clearing_charge" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
|
||||
<!-- custom GL account mappings (14) -->
|
||||
<column name="int_receivables_gl_account_id" type="BIGINT"/>
|
||||
<column name="int_payable_gl_account_id" type="BIGINT"/>
|
||||
<column name="deaf_int_payable_gl_account_id" type="BIGINT"/>
|
||||
<column name="int_overdue_reserve_account_id" type="BIGINT"/>
|
||||
<column name="undebited_interest_account_id" type="BIGINT"/>
|
||||
<column name="penal_int_cr_gl_account_id" type="BIGINT"/>
|
||||
<column name="rd_matured_gl_account_id" type="BIGINT"/>
|
||||
<column name="gl_account_id" type="BIGINT"/>
|
||||
<column name="ic_charge_gl_account_id" type="BIGINT"/>
|
||||
<column name="inoperative_gl_account_id" type="BIGINT"/>
|
||||
<column name="credit_balance_liability_gl_account_id" type="BIGINT"/>
|
||||
<column name="credit_balance_asset_gl_account_id" type="BIGINT"/>
|
||||
<column name="overdue_accounts_gl_account_id" type="BIGINT"/>
|
||||
<column name="rebate_gl_account_id" type="BIGINT"/>
|
||||
</createTable>
|
||||
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="loan_product_id"
|
||||
constraintName="fk_mplce_loan_product"
|
||||
referencedTableName="m_product_loan" referencedColumnNames="id"
|
||||
onDelete="CASCADE"/>
|
||||
</changeSet>
|
||||
|
||||
<!-- The extra GL mappings hold real account ids, so they are constrained rather than left as loose
|
||||
numbers: deleting a GL account that a product still points at should fail, not leave the product
|
||||
holding a dangling id. -->
|
||||
<changeSet id="0470_loan_product_cbs_ext_gl_fks" author="CBS" runOnChange="false">
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="int_receivables_gl_account_id"
|
||||
constraintName="fk_mplce_int_receivables"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="int_payable_gl_account_id"
|
||||
constraintName="fk_mplce_int_payable"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="deaf_int_payable_gl_account_id"
|
||||
constraintName="fk_mplce_deaf_int_payable"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="int_overdue_reserve_account_id"
|
||||
constraintName="fk_mplce_int_overdue_reserve"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="undebited_interest_account_id"
|
||||
constraintName="fk_mplce_undebited_interest"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="penal_int_cr_gl_account_id"
|
||||
constraintName="fk_mplce_penal_int_cr"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="rd_matured_gl_account_id"
|
||||
constraintName="fk_mplce_rd_matured"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="gl_account_id"
|
||||
constraintName="fk_mplce_gl"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="ic_charge_gl_account_id"
|
||||
constraintName="fk_mplce_ic_charge"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="inoperative_gl_account_id"
|
||||
constraintName="fk_mplce_inoperative"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="credit_balance_liability_gl_account_id"
|
||||
constraintName="fk_mplce_credit_balance_liability"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="credit_balance_asset_gl_account_id"
|
||||
constraintName="fk_mplce_credit_balance_asset"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="overdue_accounts_gl_account_id"
|
||||
constraintName="fk_mplce_overdue_accounts"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_ext" baseColumnNames="rebate_gl_account_id"
|
||||
constraintName="fk_mplce_rebate"
|
||||
referencedTableName="acc_gl_account" referencedColumnNames="id"/>
|
||||
</changeSet>
|
||||
|
||||
<!-- The legacy Interest Rate Detail grid: four fixed interest types, each with a Normal and a Special
|
||||
min/max rate plus a period. A child table rather than twenty-four flat columns because the
|
||||
interest type reads far better as data than as part of a column name
|
||||
(against_clearing_special_max_rate and friends). -->
|
||||
<changeSet id="0470_create_loan_product_cbs_interest_rate" author="CBS" runOnChange="false">
|
||||
<createTable tableName="m_product_loan_cbs_interest_rate">
|
||||
<column name="id" type="BIGSERIAL">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="loan_product_id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<!-- Normal Debit | Normal Credit | Against Clearing | Penalty -->
|
||||
<column name="interest_type" type="VARCHAR(30)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="calculation" type="BOOLEAN" defaultValueBoolean="false"/>
|
||||
<column name="normal_min_rate" type="DECIMAL(9,6)"/>
|
||||
<column name="normal_max_rate" type="DECIMAL(9,6)"/>
|
||||
<column name="special_min_rate" type="DECIMAL(9,6)"/>
|
||||
<column name="special_max_rate" type="DECIMAL(9,6)"/>
|
||||
<!-- DAILY | MONTHLY | QUARTERLY | HALF YEARLY | YEARLY -->
|
||||
<column name="period" type="VARCHAR(20)"/>
|
||||
</createTable>
|
||||
|
||||
<addForeignKeyConstraint baseTableName="m_product_loan_cbs_interest_rate" baseColumnNames="loan_product_id"
|
||||
constraintName="fk_mplcir_loan_product"
|
||||
referencedTableName="m_product_loan" referencedColumnNames="id"
|
||||
onDelete="CASCADE"/>
|
||||
|
||||
<!-- One row per interest type per product; the grid is fixed, so this also stops a replayed
|
||||
save from doubling the rows. -->
|
||||
<addUniqueConstraint tableName="m_product_loan_cbs_interest_rate"
|
||||
columnNames="loan_product_id, interest_type"
|
||||
constraintName="mplcir_unq_product_interest_type"/>
|
||||
</changeSet>
|
||||
|
||||
<!-- Both of these are money, not counts, and were created as INTEGER by mistake - a charge of 250.75
|
||||
was rejected outright. Kept as a follow-on changeset rather than a correction to the two above,
|
||||
which have already run and whose checksums must not change. -->
|
||||
<changeSet id="0470_fix_charge_column_types" author="CBS" runOnChange="false">
|
||||
<modifyDataType tableName="m_product_loan_cbs_ext" columnName="account_opening_charges"
|
||||
newDataType="DECIMAL(19,6)"/>
|
||||
<modifyDataType tableName="m_product_loan_cbs_ext" columnName="early_account_close_charge"
|
||||
newDataType="DECIMAL(19,6)"/>
|
||||
</changeSet>
|
||||
|
||||
<!-- A count of cheque books, not an amount. Created as DECIMAL by the same name-based type guess
|
||||
that got the two charges above wrong, and stored "3.000000" for three books. -->
|
||||
<changeSet id="0470_free_cheque_books_is_a_count" author="CBS" runOnChange="false">
|
||||
<modifyDataType tableName="m_product_loan_cbs_ext" columnName="free_cheque_books_per_year"
|
||||
newDataType="INTEGER"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- FD renewal ("Re-Invest") always opens a brand new account with its own account_no, since
|
||||
account_no is unique and the matured account keeps its own row for audit history. Customers
|
||||
and staff still expect to recognise "their FD" by one number across renewals though, so this
|
||||
column carries the ORIGINAL account's account_no forward onto every account created by
|
||||
reinvesting it (and its reinvestments, and so on). Left null on an account that has never been
|
||||
reinvested; the read side falls back to that account's own account_no in that case, so only
|
||||
accounts past their first renewal need this populated. -->
|
||||
<changeSet id="0471_add_fd_account_number_to_deposit_term" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<columnExists tableName="m_deposit_account_term_and_preclosure" columnName="fd_account_number"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<addColumn tableName="m_deposit_account_term_and_preclosure">
|
||||
<column name="fd_account_number" type="VARCHAR(20)"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- Which renewal cycle of one logical FD this account row represents: 0 for the account the
|
||||
customer originally opened, 1 for the first renewal, and so on. Together with
|
||||
fd_account_number (the stable customer-facing number) this turns the chain of per-term
|
||||
account rows into an explicit "one FD, many cycles" model, so statements and the account
|
||||
list can present a single FD with numbered terms instead of unrelated accounts.
|
||||
Defaults to 0 so every pre-existing account reads as its own first cycle. -->
|
||||
<changeSet id="0472_add_renewal_cycle_no_to_deposit_term" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<columnExists tableName="m_deposit_account_term_and_preclosure" columnName="renewal_cycle_no"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<addColumn tableName="m_deposit_account_term_and_preclosure">
|
||||
<column name="renewal_cycle_no" type="INT" defaultValueNumeric="0"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- Audit trail of FD renewals, one row per term of one logical FD.
|
||||
|
||||
A renewal opens each term as its own deposit instance (its own m_savings_account row, so that
|
||||
term keeps its own immutable ledger, interest postings and GL entries), while the customer
|
||||
keeps seeing one FD number. That leaves the renewal EVENT itself unrecorded: how much
|
||||
interest the previous term earned, what it matured at, how much was carried forward, at what
|
||||
rate, whether the renewal was automatic or done by a teller, and who did it. Deriving that by
|
||||
joining account rows loses the intent; this table records it explicitly.
|
||||
|
||||
fd_account_number is the stable customer-facing number shared by every term, so one FD's
|
||||
whole history is one indexed lookup. -->
|
||||
<changeSet id="0473_create_fd_renewal_history" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="m_fd_renewal_history"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<createTable tableName="m_fd_renewal_history">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="fd_account_number" type="VARCHAR(20)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="original_savings_account_id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="savings_account_id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="previous_savings_account_id" type="BIGINT"/>
|
||||
<column name="previous_renewal_id" type="BIGINT"/>
|
||||
<column name="renewal_no" type="INT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="previous_principal" type="DECIMAL(19,6)"/>
|
||||
<column name="interest_earned" type="DECIMAL(19,6)"/>
|
||||
<column name="maturity_amount" type="DECIMAL(19,6)"/>
|
||||
<column name="renewed_amount" type="DECIMAL(19,6)"/>
|
||||
<column name="interest_rate" type="DECIMAL(19,6)"/>
|
||||
<column name="start_date" type="DATE"/>
|
||||
<column name="maturity_date" type="DATE"/>
|
||||
<column name="tenure" type="INT"/>
|
||||
<column name="tenure_frequency_enum" type="SMALLINT"/>
|
||||
<column name="renewal_type" type="VARCHAR(10)"/>
|
||||
<column name="renewal_status" type="VARCHAR(20)"/>
|
||||
<column name="renewed_on" type="DATE"/>
|
||||
<column name="created_by_id" type="BIGINT"/>
|
||||
<column name="created_date" type="TIMESTAMP" defaultValueComputed="CURRENT_TIMESTAMP"/>
|
||||
</createTable>
|
||||
|
||||
<createIndex indexName="idx_fd_renewal_history_fd_account_number" tableName="m_fd_renewal_history">
|
||||
<column name="fd_account_number"/>
|
||||
</createIndex>
|
||||
<createIndex indexName="idx_fd_renewal_history_savings_account_id" tableName="m_fd_renewal_history">
|
||||
<column name="savings_account_id"/>
|
||||
</createIndex>
|
||||
|
||||
<addForeignKeyConstraint baseColumnNames="original_savings_account_id"
|
||||
baseTableName="m_fd_renewal_history"
|
||||
constraintName="m_fd_renewal_history_original_account_ibfk"
|
||||
deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT"
|
||||
referencedColumnNames="id" referencedTableName="m_savings_account" validate="true"/>
|
||||
<addForeignKeyConstraint baseColumnNames="savings_account_id"
|
||||
baseTableName="m_fd_renewal_history"
|
||||
constraintName="m_fd_renewal_history_account_ibfk"
|
||||
deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT"
|
||||
referencedColumnNames="id" referencedTableName="m_savings_account" validate="true"/>
|
||||
<addForeignKeyConstraint baseColumnNames="previous_savings_account_id"
|
||||
baseTableName="m_fd_renewal_history"
|
||||
constraintName="m_fd_renewal_history_prev_account_ibfk"
|
||||
deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT"
|
||||
referencedColumnNames="id" referencedTableName="m_savings_account" validate="true"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- Explicit lifecycle flag on a product's interest-rate chart.
|
||||
|
||||
Which chart prices a deposit was previously inferred purely from its from/end dates, so
|
||||
retiring a rate version meant remembering to set an end date on it, and a version left
|
||||
open-ended was treated as valid only up to today. Staff think in terms of "these are the
|
||||
rates we currently offer", so the chart now says so directly and date ranges stay as the
|
||||
historical record.
|
||||
|
||||
Defaults to true so every existing chart keeps working; the changeset then retires any chart
|
||||
whose end date has already passed, since those were superseded by definition.
|
||||
|
||||
Deliberately on m_interest_rate_chart only, not on the shared InterestRateChartFields
|
||||
embeddable, which is also embedded into m_savings_account_interest_rate_chart (a per-account
|
||||
snapshot that has no lifecycle of its own). -->
|
||||
<changeSet id="0474_add_is_active_to_interest_rate_chart" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<columnExists tableName="m_interest_rate_chart" columnName="is_active"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<addColumn tableName="m_interest_rate_chart">
|
||||
<column name="is_active" type="BOOLEAN" defaultValueBoolean="true">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="0474_retire_expired_interest_rate_charts" author="CBS" runOnChange="false">
|
||||
<update tableName="m_interest_rate_chart">
|
||||
<column name="is_active" valueBoolean="false"/>
|
||||
<where>end_date IS NOT NULL AND end_date < CURRENT_DATE</where>
|
||||
</update>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- Archives the FULL tenure-by-rate chart of a term that is about to be superseded by an in-place FD
|
||||
renewal, not just the single effective rate m_fd_renewal_history already records.
|
||||
|
||||
renewInPlace() reuses the same account row across renewals, so the account's own interest-rate
|
||||
chart (m_savings_account_interest_rate_chart / _slab) is overwritten in place at every renewal;
|
||||
the closing term's full rate card would otherwise be gone with no way to answer "what did the
|
||||
whole chart look like during term 2", only "what rate applied". One row per slab, linked to the
|
||||
m_fd_renewal_history row for the term the chart belonged to. -->
|
||||
<changeSet id="0475_create_fd_renewal_chart_slab_history" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<tableExists tableName="m_fd_renewal_chart_slab_history"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<createTable tableName="m_fd_renewal_chart_slab_history">
|
||||
<column name="id" type="BIGINT" autoIncrement="true">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="fd_renewal_history_id" type="BIGINT">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="chart_name" type="VARCHAR(100)"/>
|
||||
<column name="description" type="VARCHAR(200)"/>
|
||||
<column name="period_type_enum" type="SMALLINT"/>
|
||||
<column name="from_period" type="INT"/>
|
||||
<column name="to_period" type="INT"/>
|
||||
<column name="amount_range_from" type="DECIMAL(19,6)"/>
|
||||
<column name="amount_range_to" type="DECIMAL(19,6)"/>
|
||||
<column name="annual_interest_rate" type="DECIMAL(19,6)"/>
|
||||
<column name="currency_code" type="VARCHAR(3)"/>
|
||||
<column name="created_date" type="TIMESTAMP" defaultValueComputed="CURRENT_TIMESTAMP"/>
|
||||
</createTable>
|
||||
|
||||
<createIndex indexName="idx_fd_renewal_chart_slab_history_renewal_id" tableName="m_fd_renewal_chart_slab_history">
|
||||
<column name="fd_renewal_history_id"/>
|
||||
</createIndex>
|
||||
|
||||
<addForeignKeyConstraint baseColumnNames="fd_renewal_history_id"
|
||||
baseTableName="m_fd_renewal_chart_slab_history"
|
||||
constraintName="m_fd_renewal_chart_slab_history_renewal_ibfk"
|
||||
deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="RESTRICT"
|
||||
referencedColumnNames="id" referencedTableName="m_fd_renewal_history" validate="true"/>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- The senior-citizen premium a slab of an FD's own chart carries, alongside its standard rate.
|
||||
|
||||
m_savings_account_interest_rate_slab is populated from InterestRateChartSlabFields, a shared
|
||||
embeddable also used by the product-level chart table (m_interest_rate_slab), which has no
|
||||
senior-citizen concept at all; only the CBS base interest-rate master does. Adding the column
|
||||
to the shared embeddable would have forced it onto that product table too, so it is added here
|
||||
instead, directly on this table only, and populated by application code independently of the
|
||||
embeddable. Column stays null for every Savings/RD account and for any FD term priced off a
|
||||
product chart rather than the base-rate master, which is the existing, unaffected behaviour for
|
||||
both. -->
|
||||
<changeSet id="0476_add_senior_citizen_rate_to_account_chart_slab" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<columnExists tableName="m_savings_account_interest_rate_slab" columnName="senior_citizen_rate"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<addColumn tableName="m_savings_account_interest_rate_slab">
|
||||
<column name="senior_citizen_rate" type="DECIMAL(19,6)"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- Carries the senior-citizen premium into the archived rate-chart history too, matching the column
|
||||
just added to the live account chart in 0476, so a matured term's true historical premium remains
|
||||
queryable rather than only ever being looked up against whatever the base rate card currently
|
||||
publishes. -->
|
||||
<changeSet id="0477_add_senior_citizen_rate_to_fd_renewal_chart_slab_history" author="CBS" runOnChange="false">
|
||||
<preConditions onFail="MARK_RAN">
|
||||
<not>
|
||||
<columnExists tableName="m_fd_renewal_chart_slab_history" columnName="senior_citizen_rate"/>
|
||||
</not>
|
||||
</preConditions>
|
||||
<addColumn tableName="m_fd_renewal_chart_slab_history">
|
||||
<column name="senior_citizen_rate" type="DECIMAL(19,6)"/>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
|
||||
|
||||
<!-- Permission for the new FD "Payment" command, mirroring PREMATURECLOSE_FIXEDDEPOSITACCOUNT's
|
||||
grouping and maker-checker setting exactly, so it slots into the same role-assignment screen. -->
|
||||
<changeSet id="0478_add_fd_payment_permission" author="CBS" runOnChange="false">
|
||||
<sql>
|
||||
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
|
||||
SELECT 'transaction_savings', 'PAYMENT_FIXEDDEPOSITACCOUNT', 'FIXEDDEPOSITACCOUNT', 'PAYMENT', true
|
||||
WHERE NOT EXISTS (SELECT 1 FROM m_permission WHERE code = 'PAYMENT_FIXEDDEPOSITACCOUNT');
|
||||
</sql>
|
||||
</changeSet>
|
||||
|
||||
<!-- The checker half of the pair above. Because that row is can_maker_checker = true, switching the
|
||||
global maker-checker setting on makes every FD Payment queue for approval, and approving one
|
||||
requires the _CHECKER permission by name. Without this row that permission cannot be granted to
|
||||
any role, so queued payments would be unapprovable by anyone but a super user. Every other
|
||||
maker-checker FD permission (APPROVE, CLOSE, PREMATURECLOSE, POSTINTEREST, ...) has this twin. -->
|
||||
<changeSet id="0478_add_fd_payment_checker_permission" author="CBS" runOnChange="false">
|
||||
<sql>
|
||||
INSERT INTO m_permission (grouping, code, entity_name, action_name, can_maker_checker)
|
||||
SELECT 'transaction_savings', 'PAYMENT_FIXEDDEPOSITACCOUNT_CHECKER', 'FIXEDDEPOSITACCOUNT', 'PAYMENT_CHECKER', false
|
||||
WHERE NOT EXISTS (SELECT 1 FROM m_permission WHERE code = 'PAYMENT_FIXEDDEPOSITACCOUNT_CHECKER');
|
||||
</sql>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
+23
@@ -32,6 +32,7 @@ import static org.apache.fineract.portfolio.interestratechart.InterestRateChartS
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -67,6 +68,28 @@ public class InterestRateChart extends AbstractPersistableCustom<Long> {
|
||||
@OneToMany(mappedBy = "interestRateChart", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
private Set<InterestRateChartSlab> chartSlabs = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Whether this is a rate version the product currently offers.
|
||||
* <p>
|
||||
* Kept as an explicit flag rather than inferred from the from/end dates, so retiring a rate version is a deliberate
|
||||
* act and the dates stay purely the historical record. New charts start active.
|
||||
*/
|
||||
@Column(name = "is_active", nullable = false)
|
||||
private boolean active = true;
|
||||
|
||||
public boolean isActive() {
|
||||
return this.active;
|
||||
}
|
||||
|
||||
/** Retires this rate version, so it stops being picked for new and renewing deposits. */
|
||||
public void deactivate() {
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
this.active = true;
|
||||
}
|
||||
|
||||
protected InterestRateChart() {
|
||||
//
|
||||
}
|
||||
|
||||
+4
@@ -123,6 +123,10 @@ public class InterestRateChartFields {
|
||||
return compare != null && DateUtils.isAfter(getFromDate(), compare);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public LocalDate getFromDate() {
|
||||
return this.fromDate;
|
||||
}
|
||||
|
||||
+4
@@ -177,6 +177,10 @@ public class InterestRateChartSlabFields {
|
||||
return isGreater;
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Integer periodType() {
|
||||
return this.periodType;
|
||||
}
|
||||
|
||||
+17
-5
@@ -43,6 +43,13 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
private final BigDecimal annualInterestRate;
|
||||
private final CurrencyData currency;
|
||||
|
||||
/**
|
||||
* The senior-citizen premium published on the CBS Base Interest Rate master for this tenure band, carried onto the
|
||||
* account's own chart slab so it survives independently of whatever the master shows today. Null for a slab priced
|
||||
* off the product's own chart (which has no senior-citizen concept) or for any Savings/RD slab.
|
||||
*/
|
||||
private final BigDecimal seniorCitizenRate;
|
||||
|
||||
// associations
|
||||
private Collection<DepositAccountInterestIncentiveData> incentives;
|
||||
|
||||
@@ -66,7 +73,7 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
|
||||
public static DepositAccountInterestRateChartSlabData instance(final Long id, final String description, final EnumOptionData periodType,
|
||||
final Integer fromPeriod, final Integer toPeriod, final BigDecimal amountRangeFrom, final BigDecimal amountRangeTo,
|
||||
final BigDecimal annualInterestRate, final CurrencyData currency) {
|
||||
final BigDecimal annualInterestRate, final CurrencyData currency, final BigDecimal seniorCitizenRate) {
|
||||
final Collection<EnumOptionData> periodTypes = null;
|
||||
final Collection<EnumOptionData> entityTypeOptions = null;
|
||||
final Collection<EnumOptionData> attributeNameOptions = null;
|
||||
@@ -78,7 +85,8 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
final Collection<DepositAccountInterestIncentiveData> incentives = null;
|
||||
return new DepositAccountInterestRateChartSlabData(id, description, periodType, fromPeriod, toPeriod, amountRangeFrom,
|
||||
amountRangeTo, annualInterestRate, incentives, currency, periodTypes, entityTypeOptions, attributeNameOptions,
|
||||
conditionTypeOptions, incentiveTypeOptions, genderOptions, clientTypeOptions, clientClassificationOptions);
|
||||
conditionTypeOptions, incentiveTypeOptions, genderOptions, clientTypeOptions, clientClassificationOptions,
|
||||
seniorCitizenRate);
|
||||
}
|
||||
|
||||
public static DepositAccountInterestRateChartSlabData from(final InterestRateChartSlabData chartSlabData) {
|
||||
@@ -90,12 +98,14 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
fromProdIncentives.add(DepositAccountInterestIncentiveData.from(incentive));
|
||||
}
|
||||
}
|
||||
// the product-level chart this comes from has no senior-citizen concept at all
|
||||
final BigDecimal seniorCitizenRate = null;
|
||||
return new DepositAccountInterestRateChartSlabData(id, chartSlabData.description(), chartSlabData.periodType(),
|
||||
chartSlabData.fromPeriod(), chartSlabData.toPeriod(), chartSlabData.amountRangeFrom(), chartSlabData.amountRangeTo(),
|
||||
chartSlabData.annualInterestRate(), fromProdIncentives, chartSlabData.currency(), chartSlabData.periodTypes(),
|
||||
chartSlabData.entityTypeOptions(), chartSlabData.attributeNameOptions(), chartSlabData.conditionTypeOptions(),
|
||||
chartSlabData.incentiveTypeOptions(), chartSlabData.genderOptions(), chartSlabData.clientTypeOptions(),
|
||||
chartSlabData.clientClassificationOptions());
|
||||
chartSlabData.clientClassificationOptions(), seniorCitizenRate);
|
||||
}
|
||||
|
||||
public static DepositAccountInterestRateChartSlabData withTemplate(final DepositAccountInterestRateChartSlabData chartSlab,
|
||||
@@ -106,7 +116,7 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
return new DepositAccountInterestRateChartSlabData(chartSlab.id, chartSlab.description, chartSlab.periodType, chartSlab.fromPeriod,
|
||||
chartSlab.toPeriod, chartSlab.amountRangeFrom, chartSlab.amountRangeTo, chartSlab.annualInterestRate, chartSlab.incentives,
|
||||
chartSlab.currency, periodTypes, entityTypeOptions, attributeNameOptions, conditionTypeOptions, incentiveTypeOptions,
|
||||
genderOptions, clientTypeOptions, clientClassificationOptions);
|
||||
genderOptions, clientTypeOptions, clientClassificationOptions, chartSlab.seniorCitizenRate);
|
||||
}
|
||||
|
||||
private DepositAccountInterestRateChartSlabData(final Long id, final String description, final EnumOptionData periodType,
|
||||
@@ -115,7 +125,8 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
final CurrencyData currency, final Collection<EnumOptionData> periodTypes, final Collection<EnumOptionData> entityTypeOptions,
|
||||
final Collection<EnumOptionData> attributeNameOptions, final Collection<EnumOptionData> conditionTypeOptions,
|
||||
final Collection<EnumOptionData> incentiveTypeOptions, final Collection<CodeValueData> genderOptions,
|
||||
final Collection<CodeValueData> clientTypeOptions, final Collection<CodeValueData> clientClassificationOptions) {
|
||||
final Collection<CodeValueData> clientTypeOptions, final Collection<CodeValueData> clientClassificationOptions,
|
||||
final BigDecimal seniorCitizenRate) {
|
||||
this.id = id;
|
||||
this.description = description;
|
||||
this.periodType = periodType;
|
||||
@@ -125,6 +136,7 @@ public final class DepositAccountInterestRateChartSlabData {
|
||||
this.amountRangeTo = amountRangeTo;
|
||||
this.annualInterestRate = annualInterestRate;
|
||||
this.currency = currency;
|
||||
this.seniorCitizenRate = seniorCitizenRate;
|
||||
this.periodTypes = periodTypes;
|
||||
this.incentives = incentivesData;
|
||||
this.attributeNameOptions = attributeNameOptions;
|
||||
|
||||
+51
@@ -138,6 +138,50 @@ public final class FixedDepositAccountData extends DepositAccountData {
|
||||
private Boolean isSeniorCitizen;
|
||||
private java.math.BigDecimal seniorCitizenInterestRate;
|
||||
|
||||
// Reinvestment trail: which account this one was reinvested FROM (set on the new account) and
|
||||
// which account it was reinvested INTO (derived by reverse lookup on the old account), so staff
|
||||
// can trace a "Re-Invest Maturity Amount"/"Re-Invest Principal Only" closure both directions
|
||||
// instead of the link disappearing once the old account closes.
|
||||
private Long reinvestedFromAccountId;
|
||||
private String reinvestedFromAccountNo;
|
||||
private Long reinvestedIntoAccountId;
|
||||
private String reinvestedIntoAccountNo;
|
||||
|
||||
public void setReinvestmentLinks(final Long reinvestedFromAccountId, final String reinvestedFromAccountNo,
|
||||
final Long reinvestedIntoAccountId, final String reinvestedIntoAccountNo) {
|
||||
this.reinvestedFromAccountId = reinvestedFromAccountId;
|
||||
this.reinvestedFromAccountNo = reinvestedFromAccountNo;
|
||||
this.reinvestedIntoAccountId = reinvestedIntoAccountId;
|
||||
this.reinvestedIntoAccountNo = reinvestedIntoAccountNo;
|
||||
}
|
||||
|
||||
// The account number the customer should keep seeing across renewals -- the ORIGINAL account's
|
||||
// account_no, carried forward onto every account created by reinvesting it. Falls back to this
|
||||
// account's own accountNo when it has never been reinvested (see DepositAccountReadPlatformServiceImpl).
|
||||
private String fdAccountNumber;
|
||||
|
||||
public void setFdAccountNumber(final String fdAccountNumber) {
|
||||
this.fdAccountNumber = fdAccountNumber;
|
||||
}
|
||||
|
||||
/** Which renewal cycle of that FD this account is: 0 = originally opened, 1 = first renewal, etc. */
|
||||
private Integer renewalCycleNo;
|
||||
|
||||
public void setRenewalCycleNo(final Integer renewalCycleNo) {
|
||||
this.renewalCycleNo = renewalCycleNo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every term of this FD, oldest first: one entry per account in the renewal chain, each carrying that term's own
|
||||
* account number, cycle number, dates, principal and maturity amount. Lets the account view and the deposit
|
||||
* certificate present "one FD, many terms" without the caller having to walk the chain itself.
|
||||
*/
|
||||
private java.util.List<java.util.Map<String, Object>> renewalHistory;
|
||||
|
||||
public void setRenewalHistory(final java.util.List<java.util.Map<String, Object>> renewalHistory) {
|
||||
this.renewalHistory = renewalHistory;
|
||||
}
|
||||
|
||||
// CBS account-level fields (stored per-account in m_savings_account)
|
||||
private String accountStatus;
|
||||
private String modeOfOperation;
|
||||
@@ -329,6 +373,13 @@ public final class FixedDepositAccountData extends DepositAccountData {
|
||||
this.jointHolders = src.jointHolders;
|
||||
this.isSeniorCitizen = src.isSeniorCitizen;
|
||||
this.seniorCitizenInterestRate = src.seniorCitizenInterestRate;
|
||||
this.reinvestedFromAccountId = src.reinvestedFromAccountId;
|
||||
this.reinvestedFromAccountNo = src.reinvestedFromAccountNo;
|
||||
this.reinvestedIntoAccountId = src.reinvestedIntoAccountId;
|
||||
this.reinvestedIntoAccountNo = src.reinvestedIntoAccountNo;
|
||||
this.fdAccountNumber = src.fdAccountNumber;
|
||||
this.renewalCycleNo = src.renewalCycleNo;
|
||||
this.renewalHistory = src.renewalHistory;
|
||||
this.subStatus = src.subStatus;
|
||||
this.reasonForBlock = src.reasonForBlock;
|
||||
this.lastActiveTransactionDate = src.lastActiveTransactionDate;
|
||||
|
||||
+86
@@ -28,12 +28,16 @@ import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
import org.apache.fineract.portfolio.client.domain.Client;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChart;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartFields;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabFields;
|
||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab;
|
||||
import org.apache.fineract.portfolio.interestratechart.incentive.AttributeIncentiveCalculation;
|
||||
import org.apache.fineract.portfolio.interestratechart.incentive.AttributeIncentiveCalculationFactory;
|
||||
@@ -156,4 +160,86 @@ public class DepositAccountInterestRateChart extends AbstractPersistableCustom<L
|
||||
public boolean isPrimaryGroupingByAmount() {
|
||||
return this.chartFields.isPrimaryGroupingByAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-snapshots this account's chart from the product's current chart, in place.
|
||||
* <p>
|
||||
* Used when an FD renews on the same account: the new term must be priced off whatever the product offers on the
|
||||
* renewal date, not the rates frozen when the account was first opened. This has to mutate the existing row rather
|
||||
* than swap in a new chart, because the account-to-chart mapping is one-to-one on the chart's savings_account_id, so
|
||||
* a second row for the same account would break loading it.
|
||||
*/
|
||||
public void refreshFrom(final InterestRateChart productChart) {
|
||||
this.chartFields = productChart.chartFields();
|
||||
// orphanRemoval on chartSlabs deletes the superseded slab rows.
|
||||
setOfChartSlabs().clear();
|
||||
for (final InterestRateChartSlab productSlab : productChart.setOfChartSlabs()) {
|
||||
this.chartSlabs.add(DepositAccountInterestRateChartSlabs.from(productSlab, this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A slab's rate-by-tenure fields plus its senior-citizen premium, travelling together.
|
||||
* <p>
|
||||
* The premium isn't part of {@link InterestRateChartSlabFields} because that embeddable is shared with the
|
||||
* product-level chart slab table, which has no CBS senior-citizen concept -- so it rides alongside as a plain pair
|
||||
* rather than being added to the shared type.
|
||||
*/
|
||||
public static final class SlabSnapshot {
|
||||
|
||||
private final InterestRateChartSlabFields fields;
|
||||
private final BigDecimal seniorCitizenRate;
|
||||
|
||||
public SlabSnapshot(final InterestRateChartSlabFields fields, final BigDecimal seniorCitizenRate) {
|
||||
this.fields = fields;
|
||||
this.seniorCitizenRate = seniorCitizenRate;
|
||||
}
|
||||
|
||||
public InterestRateChartSlabFields getFields() {
|
||||
return this.fields;
|
||||
}
|
||||
|
||||
public BigDecimal getSeniorCitizenRate() {
|
||||
return this.seniorCitizenRate;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This chart's slabs as they stand right now, each paired with its senior-citizen premium. Read before
|
||||
* {@link #refreshFromSlabSnapshots} overwrites them, so a renewing FD can archive the term that is closing rather than
|
||||
* losing its rate card the moment the new term's rates replace it.
|
||||
*/
|
||||
public List<SlabSnapshot> currentSlabSnapshots() {
|
||||
final List<SlabSnapshot> snapshots = new ArrayList<>();
|
||||
for (final DepositAccountInterestRateChartSlabs slab : setOfChartSlabs()) {
|
||||
snapshots.add(new SlabSnapshot(slab.slabFields(), slab.getSeniorCitizenRate()));
|
||||
}
|
||||
return snapshots;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-snapshots this account's chart from an explicit set of slabs (with their senior-citizen premiums), in place.
|
||||
* <p>
|
||||
* Used when the rates come from the CBS base interest-rate master rather than from the product's own chart -- that
|
||||
* master is the rate card staff maintain and see on screen, so a renewing deposit priced off anything else would
|
||||
* disagree with what the bank publishes. Mutates the existing row for the same reason
|
||||
* {@link #refreshFrom(InterestRateChart)} does: the account-to-chart mapping is one-to-one on the chart's
|
||||
* savings_account_id, so a second row for the same account would break loading it.
|
||||
* <p>
|
||||
* Does nothing when handed no slabs, leaving the account on the chart it already has, so a missing or empty rate
|
||||
* version can never leave a deposit with no rates at all.
|
||||
*/
|
||||
public void refreshFromSlabSnapshots(final InterestRateChartFields chartFields, final Collection<SlabSnapshot> snapshots) {
|
||||
if (snapshots == null || snapshots.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (chartFields != null) {
|
||||
this.chartFields = chartFields;
|
||||
}
|
||||
setOfChartSlabs().clear();
|
||||
for (final SlabSnapshot snapshot : snapshots) {
|
||||
this.chartSlabs
|
||||
.add(DepositAccountInterestRateChartSlabs.fromFields(snapshot.getFields(), this, snapshot.getSeniorCitizenRate()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+29
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.portfolio.savings.domain;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Embedded;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -26,6 +27,7 @@ import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
@@ -47,6 +49,16 @@ public class DepositAccountInterestRateChartSlabs extends AbstractPersistableCus
|
||||
@OneToMany(mappedBy = "depositAccountInterestRateChartSlabs", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
private Set<DepositAccountInterestIncentives> interestIncentives = new HashSet<>();
|
||||
|
||||
/**
|
||||
* The senior-citizen premium for this slab's tenure band, as published on the CBS Base Interest Rates screen at the
|
||||
* time this chart was set. Not part of {@link InterestRateChartSlabFields} because that embeddable is shared with the
|
||||
* product-level {@code m_interest_rate_slab} table, which has no CBS senior-citizen concept; kept as a column of its
|
||||
* own here instead, on the account-level table only. Null for a slab copied from a product chart (which never carries
|
||||
* one) or for a slab that predates this column.
|
||||
*/
|
||||
@Column(name = "senior_citizen_rate", scale = 6, precision = 19)
|
||||
private BigDecimal seniorCitizenRate;
|
||||
|
||||
protected DepositAccountInterestRateChartSlabs() {
|
||||
//
|
||||
}
|
||||
@@ -59,6 +71,10 @@ public class DepositAccountInterestRateChartSlabs extends AbstractPersistableCus
|
||||
this.interestIncentives = interestIncentives;
|
||||
}
|
||||
|
||||
public BigDecimal getSeniorCitizenRate() {
|
||||
return this.seniorCitizenRate;
|
||||
}
|
||||
|
||||
public void setDepositAccountInterestRateChart(DepositAccountInterestRateChart depositAccountInterestRateChart) {
|
||||
this.depositAccountInterestRateChart = depositAccountInterestRateChart;
|
||||
}
|
||||
@@ -71,6 +87,19 @@ public class DepositAccountInterestRateChartSlabs extends AbstractPersistableCus
|
||||
return this.slabFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a slab straight from its field values, for a chart taken from a source that is not a product
|
||||
* {@link InterestRateChartSlab} -- specifically the CBS base interest-rate master, which is the bank's published rate
|
||||
* card and carries no incentive rules.
|
||||
*/
|
||||
public static DepositAccountInterestRateChartSlabs fromFields(final InterestRateChartSlabFields slabFields,
|
||||
final DepositAccountInterestRateChart depositAccountInterestRateChart, final BigDecimal seniorCitizenRate) {
|
||||
final DepositAccountInterestRateChartSlabs slab = new DepositAccountInterestRateChartSlabs(slabFields,
|
||||
depositAccountInterestRateChart, new HashSet<>());
|
||||
slab.seniorCitizenRate = seniorCitizenRate;
|
||||
return slab;
|
||||
}
|
||||
|
||||
public static DepositAccountInterestRateChartSlabs from(InterestRateChartSlab interestRateChartSlab,
|
||||
DepositAccountInterestRateChart depositAccountInterestRateChart) {
|
||||
InterestRateChartSlabFields slabFields = interestRateChartSlab.slabFields();
|
||||
|
||||
+59
@@ -89,6 +89,49 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom<L
|
||||
@Column(name = "transfer_to_savings_account_id")
|
||||
private Long transferToSavingsAccountId;
|
||||
|
||||
// Set on the NEW account created by a "Re-Invest" maturity closure, pointing back at the account
|
||||
// it was reinvested from. There is no separate "reinvested into" column on the OLD account -- that
|
||||
// direction is derived by looking up whichever row has this account's id here (see
|
||||
// DepositAccountReadPlatformServiceImpl), so the relationship needs tracking in only one place.
|
||||
@Column(name = "reinvested_from_savings_id")
|
||||
private Long reinvestedFromSavingsId;
|
||||
|
||||
public Long getReinvestedFromSavingsId() {
|
||||
return this.reinvestedFromSavingsId;
|
||||
}
|
||||
|
||||
public void setReinvestedFromSavingsId(final Long reinvestedFromSavingsId) {
|
||||
this.reinvestedFromSavingsId = reinvestedFromSavingsId;
|
||||
}
|
||||
|
||||
// The account_no of the FIRST account in a renewal chain, carried forward onto every account
|
||||
// created by reinvesting it. Null on an account that has never been reinvested -- callers should
|
||||
// fall back to that account's own account_no in that case (see FixedDepositAccount.reInvest()).
|
||||
@Column(name = "fd_account_number", length = 20)
|
||||
private String fdAccountNumber;
|
||||
|
||||
public String getFdAccountNumber() {
|
||||
return this.fdAccountNumber;
|
||||
}
|
||||
|
||||
public void setFdAccountNumber(final String fdAccountNumber) {
|
||||
this.fdAccountNumber = fdAccountNumber;
|
||||
}
|
||||
|
||||
// Which renewal cycle of one logical FD this account represents: 0 = originally opened account,
|
||||
// 1 = first renewal, and so on. Lets the UI present "one FD, many terms" over what is physically
|
||||
// a chain of per-term account rows.
|
||||
@Column(name = "renewal_cycle_no")
|
||||
private Integer renewalCycleNo;
|
||||
|
||||
public Integer getRenewalCycleNo() {
|
||||
return this.renewalCycleNo == null ? 0 : this.renewalCycleNo;
|
||||
}
|
||||
|
||||
public void setRenewalCycleNo(final Integer renewalCycleNo) {
|
||||
this.renewalCycleNo = renewalCycleNo;
|
||||
}
|
||||
|
||||
protected DepositAccountTermAndPreClosure() {
|
||||
|
||||
}
|
||||
@@ -297,6 +340,19 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom<L
|
||||
this.onAccountClosureType = onClosureType.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies the standing instructions -- maturity instruction, its payout target and the interest-transfer flag -- from
|
||||
* the term being renewed.
|
||||
* <p>
|
||||
* These describe what the customer asked the deposit to do at every maturity, not a one-off choice for a single term,
|
||||
* so a renewed deposit that lost them would mature once more and then sit idle instead of rolling over again.
|
||||
*/
|
||||
public void carryForwardStandingInstructionsFrom(final DepositAccountTermAndPreClosure previousTerm) {
|
||||
this.onAccountClosureType = previousTerm.onAccountClosureType;
|
||||
this.transferToSavingsAccountId = previousTerm.transferToSavingsAccountId;
|
||||
this.transferInterestToLinkedAccount = previousTerm.transferInterestToLinkedAccount;
|
||||
}
|
||||
|
||||
public boolean isReinvestOnClosure() {
|
||||
return DepositAccountOnClosureType.fromInt(this.onAccountClosureType).isReinvest();
|
||||
}
|
||||
@@ -317,6 +373,9 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom<L
|
||||
final LocalDate expectedFirstDepositOnDate = null;
|
||||
final Boolean transferInterestToLinkedAccount = false;
|
||||
|
||||
// Left blank here on purpose: this method is shared with Recurring Deposit renewal, so carrying
|
||||
// standing instructions forward is done by the caller that wants it (see
|
||||
// FixedDepositAccount#reInvest) rather than changed for both product types at once.
|
||||
final DepositAccountOnClosureType accountOnClosureType = null;
|
||||
final Long transferToSavingsId = null;
|
||||
return DepositAccountTermAndPreClosure.createNew(preClosureDetail, depositTermDetail, account, actualDepositAmount, maturityAmount,
|
||||
|
||||
+36
@@ -324,6 +324,42 @@ public class FixedDepositProduct extends SavingsProduct {
|
||||
return applicableChart;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rate chart the product currently offers for a deposit priced on the given date: a chart flagged active, that has
|
||||
* come into force by that date and has not been superseded. Where more than one qualifies, the most recently effective
|
||||
* wins.
|
||||
* <p>
|
||||
* Differs from {@link #applicableChart} in three ways that matter when pricing a renewal. That method ignores the
|
||||
* active flag entirely; it treats an open-ended chart (no end date) as valid only up to today's business date, so a
|
||||
* deposit renewing on a future maturity date finds no chart at all; and it returns the first match from an unordered
|
||||
* set, so two charts covering the same date resolve arbitrarily.
|
||||
* <p>
|
||||
* Returns null when the product offers no active chart in force on that date.
|
||||
*/
|
||||
public InterestRateChart activeChart(final LocalDate target) {
|
||||
if (this.charts == null || target == null) {
|
||||
return null;
|
||||
}
|
||||
InterestRateChart activeChart = null;
|
||||
for (final InterestRateChart chart : this.charts) {
|
||||
if (!chart.isActive()) {
|
||||
continue; // retired rate version
|
||||
}
|
||||
final LocalDate fromDate = chart.getFromDate();
|
||||
final LocalDate endDate = chart.getEndDate();
|
||||
if (fromDate == null || fromDate.isAfter(target)) {
|
||||
continue; // not yet in force
|
||||
}
|
||||
if (endDate != null && endDate.isBefore(target)) {
|
||||
continue; // already superseded
|
||||
}
|
||||
if (activeChart == null || fromDate.isAfter(activeChart.getFromDate())) {
|
||||
activeChart = chart;
|
||||
}
|
||||
}
|
||||
return activeChart;
|
||||
}
|
||||
|
||||
public DepositProductTermAndPreClosure depositProductTermAndPreClosure() {
|
||||
return this.productTermAndPreClosure;
|
||||
}
|
||||
|
||||
+33
-11
@@ -605,19 +605,29 @@ public final class ProductPendingEditFieldMapper {
|
||||
|
||||
// ---- GL array mappings (1:many, satellite table) -----------------------------------------------
|
||||
|
||||
// The GL-account field is named differently per mapping array in the product payload -- payment
|
||||
// channels carry "fundSourceAccountId", fee/penalty arrays carry "incomeAccountId" (see
|
||||
// AccountingConstants.LoanProductAccountingParams). Reading the wrong name leaves gl_account_id
|
||||
// null, which the satellite table rejects, so each array declares its own field name here and the
|
||||
// same name is written back when the pending edit is rebuilt into a product-update payload.
|
||||
private static final String PAYMENT_CHANNEL_GL_FIELD = "fundSourceAccountId";
|
||||
private static final String INCOME_ACCOUNT_GL_FIELD = "incomeAccountId";
|
||||
|
||||
public static List<ProductPendingEditGlMapping> extractGlArrayMappings(final JsonCommand command, final ProductPendingEdit edit) {
|
||||
final List<ProductPendingEditGlMapping> mappings = new java.util.ArrayList<>();
|
||||
boolean any = false;
|
||||
any |= extractGlArray(command, edit, "paymentChannelToFundSourceMappings", ProductPendingEditGlMapping.TYPE_PAYMENT_CHANNEL,
|
||||
"paymentTypeId", mappings);
|
||||
any |= extractGlArray(command, edit, "feeToIncomeAccountMappings", ProductPendingEditGlMapping.TYPE_FEE, "chargeId", mappings);
|
||||
"paymentTypeId", PAYMENT_CHANNEL_GL_FIELD, mappings);
|
||||
any |= extractGlArray(command, edit, "feeToIncomeAccountMappings", ProductPendingEditGlMapping.TYPE_FEE, "chargeId",
|
||||
INCOME_ACCOUNT_GL_FIELD, mappings);
|
||||
any |= extractGlArray(command, edit, "penaltyToIncomeAccountMappings", ProductPendingEditGlMapping.TYPE_PENALTY, "chargeId",
|
||||
mappings);
|
||||
INCOME_ACCOUNT_GL_FIELD, mappings);
|
||||
return any ? mappings : null;
|
||||
}
|
||||
|
||||
private static boolean extractGlArray(final JsonCommand command, final ProductPendingEdit edit, final String paramName,
|
||||
final String mappingType, final String idFieldName, final List<ProductPendingEditGlMapping> out) {
|
||||
final String mappingType, final String idFieldName, final String glFieldName,
|
||||
final List<ProductPendingEditGlMapping> out) {
|
||||
if (!command.hasParameter(paramName)) {
|
||||
return false;
|
||||
}
|
||||
@@ -625,8 +635,13 @@ public final class ProductPendingEditFieldMapper {
|
||||
if (raw != null && raw.isJsonArray()) {
|
||||
for (final com.google.gson.JsonElement el : raw.getAsJsonArray()) {
|
||||
final JsonObject o = el.getAsJsonObject();
|
||||
final Long idFieldValue = o.has(idFieldName) ? o.get(idFieldName).getAsLong() : null;
|
||||
final Long glAccountId = o.has("glAccountId") ? o.get("glAccountId").getAsLong() : null;
|
||||
final Long idFieldValue = longOrNull(o, idFieldName);
|
||||
final Long glAccountId = longOrNull(o, glFieldName);
|
||||
// A mapping is only meaningful with both halves present; keeping a half-filled row
|
||||
// would fail the satellite table's NOT NULL constraint and abort the whole edit.
|
||||
if (idFieldValue == null || glAccountId == null) {
|
||||
continue;
|
||||
}
|
||||
final Long paymentTypeId = "paymentTypeId".equals(idFieldName) ? idFieldValue : null;
|
||||
final Long chargeId = "chargeId".equals(idFieldName) ? idFieldValue : null;
|
||||
out.add(new ProductPendingEditGlMapping(edit, mappingType, paymentTypeId, chargeId, glAccountId));
|
||||
@@ -635,15 +650,22 @@ public final class ProductPendingEditFieldMapper {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Long longOrNull(final JsonObject o, final String fieldName) {
|
||||
final com.google.gson.JsonElement el = o.get(fieldName);
|
||||
return el == null || el.isJsonNull() ? null : el.getAsLong();
|
||||
}
|
||||
|
||||
public static void writeGlArrayMappingsToJson(final JsonObject root, final List<ProductPendingEditGlMapping> mappings) {
|
||||
writeGlArrayGroup(root, mappings, ProductPendingEditGlMapping.TYPE_PAYMENT_CHANNEL, "paymentChannelToFundSourceMappings",
|
||||
"paymentTypeId");
|
||||
writeGlArrayGroup(root, mappings, ProductPendingEditGlMapping.TYPE_FEE, "feeToIncomeAccountMappings", "chargeId");
|
||||
writeGlArrayGroup(root, mappings, ProductPendingEditGlMapping.TYPE_PENALTY, "penaltyToIncomeAccountMappings", "chargeId");
|
||||
"paymentTypeId", PAYMENT_CHANNEL_GL_FIELD);
|
||||
writeGlArrayGroup(root, mappings, ProductPendingEditGlMapping.TYPE_FEE, "feeToIncomeAccountMappings", "chargeId",
|
||||
INCOME_ACCOUNT_GL_FIELD);
|
||||
writeGlArrayGroup(root, mappings, ProductPendingEditGlMapping.TYPE_PENALTY, "penaltyToIncomeAccountMappings", "chargeId",
|
||||
INCOME_ACCOUNT_GL_FIELD);
|
||||
}
|
||||
|
||||
private static void writeGlArrayGroup(final JsonObject root, final List<ProductPendingEditGlMapping> mappings, final String type,
|
||||
final String paramName, final String idFieldName) {
|
||||
final String paramName, final String idFieldName, final String glFieldName) {
|
||||
final JsonArray array = new JsonArray();
|
||||
for (final ProductPendingEditGlMapping mapping : mappings) {
|
||||
if (!type.equals(mapping.getMappingType())) {
|
||||
@@ -652,7 +674,7 @@ public final class ProductPendingEditFieldMapper {
|
||||
final JsonObject entry = new JsonObject();
|
||||
final Long idFieldValue = "paymentTypeId".equals(idFieldName) ? mapping.getPaymentTypeId() : mapping.getChargeId();
|
||||
entry.addProperty(idFieldName, idFieldValue);
|
||||
entry.addProperty("glAccountId", mapping.getGlAccountId());
|
||||
entry.addProperty(glFieldName, mapping.getGlAccountId());
|
||||
array.add(entry);
|
||||
}
|
||||
root.add(paramName, array);
|
||||
|
||||
+35
-3
@@ -828,6 +828,28 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
|
||||
return savingsTransaction;
|
||||
}
|
||||
|
||||
/**
|
||||
* The last non-reversed transaction dated strictly BEFORE {@code date}, or null when none exists.
|
||||
* <p>
|
||||
* Distinct from {@link #findLastTransaction(LocalDate)}, which matches the date exactly. Used to seed the opening
|
||||
* balance of an interest calculation that starts at a pivot date: a transaction dated ON that date falls inside the
|
||||
* first posting period and is applied there, so seeding from it would count it twice, while requiring an exact match
|
||||
* would leave the opening balance at zero on any pivot date that happens to carry no transaction.
|
||||
* <p>
|
||||
* Relies on {@code transactions} being ordered ascending by date, as its {@code @OrderBy} declares, so the final
|
||||
* match is the latest one.
|
||||
*/
|
||||
protected SavingsAccountTransaction findLastTransactionBefore(final LocalDate date) {
|
||||
SavingsAccountTransaction candidate = null;
|
||||
for (final SavingsAccountTransaction transaction : getTransactions()) {
|
||||
if (transaction.isNotReversed() && !transaction.isReversalTransaction()
|
||||
&& DateUtils.isBefore(transaction.getTransactionDate(), date)) {
|
||||
candidate = transaction;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
protected SavingsAccountTransaction findLastFilteredTransactionWithPivotConfig(final LocalDate date) {
|
||||
SavingsAccountTransaction savingsTransaction = null;
|
||||
List<SavingsAccountTransaction> trans = getSavingsAccountTransactionsWithPivotConfig();
|
||||
@@ -921,13 +943,23 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
|
||||
if (backdatedTxnsAllowedTill) {
|
||||
transaction = findLastFilteredTransactionWithPivotConfig(startInterestCalculationDate);
|
||||
} else {
|
||||
transaction = findLastTransaction(startInterestCalculationDate);
|
||||
// Strictly before the pivot, not on it: anything dated on the pivot date belongs to the
|
||||
// first posting period and is applied there, so seeding from it would apply it twice --
|
||||
// and an exact-date match would leave this at zero whenever the pivot date carries no
|
||||
// transaction of its own, silently accruing the whole term on a zero balance.
|
||||
transaction = findLastTransactionBefore(startInterestCalculationDate);
|
||||
}
|
||||
|
||||
if (transaction == null) {
|
||||
periodStartingBalance = Money.zero(this.currency);
|
||||
} else {
|
||||
} else if (backdatedTxnsAllowedTill) {
|
||||
periodStartingBalance = Money.of(this.currency, this.summary.getRunningBalanceOnPivotDate());
|
||||
} else {
|
||||
// summary.runningBalanceOnPivotDate is @Transient and only ever populated by the
|
||||
// assembler on the backdated-transactions path, so reading it here returned zero and
|
||||
// silently wiped the opening balance. The balance carried by the last transaction
|
||||
// before the start date is the same figure, and is always present.
|
||||
periodStartingBalance = transaction.getRunningBalance(this.currency);
|
||||
}
|
||||
} else {
|
||||
periodStartingBalance = Money.zero(this.currency);
|
||||
@@ -3140,7 +3172,7 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDate calculateDateAccountIsLockedUntil(final LocalDate activationLocalDate) {
|
||||
protected LocalDate calculateDateAccountIsLockedUntil(final LocalDate activationLocalDate) {
|
||||
|
||||
LocalDate lockedInUntilLocalDate = null;
|
||||
final PeriodFrequencyType lockinPeriodFrequencyType = PeriodFrequencyType.fromInt(this.lockinPeriodFrequencyType);
|
||||
|
||||
+2
@@ -61,6 +61,8 @@ public interface DepositAccountWritePlatformService {
|
||||
|
||||
CommandProcessingResult prematureCloseRDAccount(Long savingsId, JsonCommand command);
|
||||
|
||||
CommandProcessingResult processFdPayment(Long savingsId, JsonCommand command);
|
||||
|
||||
SavingsAccountTransaction initiateSavingsTransfer(Long accountId, LocalDate transferDate, DepositAccountType depositAccountType);
|
||||
|
||||
SavingsAccountTransaction withdrawSavingsTransfer(Long accountId, LocalDate transferDate, DepositAccountType depositAccountType);
|
||||
|
||||
Reference in New Issue
Block a user