Skip to content

Commit

Permalink
FINERACT-1960: Selected fees to be considered for accrual
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Alberto Hernandez committed Aug 23, 2023
1 parent 2f47059 commit ef1cfd0
Show file tree
Hide file tree
Showing 18 changed files with 285 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public class SavingsApiConstants {
// charges parameters
public static final String chargeIdParamName = "chargeId";
public static final String chargesParamName = "charges";
public static final String accrualChargesParamName = "accrualCharges";
public static final String savingsAccountChargeIdParamName = "savingsAccountChargeId";
public static final String chargeNameParamName = "name";
public static final String penaltyParamName = "penalty";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public final class SavingsProductData implements Serializable {

// charges
private final Collection<ChargeData> charges;
private final Collection<ChargeData> accrualCharges;

// template
private final Collection<CurrencyData> currencyOptions;
Expand Down Expand Up @@ -120,6 +121,7 @@ public static SavingsProductData template(final CurrencyData currency, final Enu
final Map<String, Object> accountingMappings = null;
final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null;
final Collection<ChargeData> charges = null;
final Collection<ChargeData> accrualCharges = null;
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final boolean allowOverdraft = false;
Expand Down Expand Up @@ -147,10 +149,11 @@ public static SavingsProductData template(final CurrencyData currency, final Enu
penaltyOptions, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, allowOverdraft, overdraftLimit,
minRequiredBalance, enforceMinRequiredBalance, maxAllowedLienLimit, lienAllowed, minBalanceForInterestCalculation,
nominalAnnualInterestRateOverdraft, minOverdraftForInterestCalculation, withHoldTax, taxGroup, taxGroupOptions,
isDormancyTrackingActive, daysToInactive, daysToDormancy, daysToEscheat, accountMappingForPayment);
isDormancyTrackingActive, daysToInactive, daysToDormancy, daysToEscheat, accountMappingForPayment, accrualCharges);
}

public static SavingsProductData withCharges(final SavingsProductData product, final Collection<ChargeData> charges) {
public static SavingsProductData withCharges(final SavingsProductData product, final Collection<ChargeData> charges,
final Collection<ChargeData> accrualCharges) {
return new SavingsProductData(product.id, product.name, product.shortName, product.description, product.currency,
product.nominalAnnualInterestRate, product.interestCompoundingPeriodType, product.interestPostingPeriodType,
product.interestCalculationType, product.interestCalculationDaysInYearType, product.minRequiredOpeningBalance,
Expand All @@ -165,7 +168,7 @@ public static SavingsProductData withCharges(final SavingsProductData product, f
product.minBalanceForInterestCalculation, product.nominalAnnualInterestRateOverdraft,
product.minOverdraftForInterestCalculation, product.withHoldTax, product.taxGroup, product.taxGroupOptions,
product.isDormancyTrackingActive, product.daysToInactive, product.daysToDormancy, product.daysToEscheat,
product.accountMappingForPayment);
product.accountMappingForPayment, accrualCharges);
}

/**
Expand Down Expand Up @@ -200,7 +203,8 @@ public static SavingsProductData withTemplate(final SavingsProductData existingP
existingProduct.maxAllowedLienLimit, existingProduct.lienAllowed, existingProduct.minBalanceForInterestCalculation,
existingProduct.nominalAnnualInterestRateOverdraft, existingProduct.minOverdraftForInterestCalculation,
existingProduct.withHoldTax, existingProduct.taxGroup, taxGroupOptions, existingProduct.isDormancyTrackingActive,
existingProduct.daysToInactive, existingProduct.daysToDormancy, existingProduct.daysToEscheat, accountMappingForPayment);
existingProduct.daysToInactive, existingProduct.daysToDormancy, existingProduct.daysToEscheat, accountMappingForPayment,
existingProduct.accrualCharges);
}

public static SavingsProductData withAccountingDetails(final SavingsProductData existingProduct,
Expand Down Expand Up @@ -237,7 +241,7 @@ public static SavingsProductData withAccountingDetails(final SavingsProductData
existingProduct.nominalAnnualInterestRateOverdraft, existingProduct.minOverdraftForInterestCalculation,
existingProduct.withHoldTax, existingProduct.taxGroup, existingProduct.taxGroupOptions,
existingProduct.isDormancyTrackingActive, existingProduct.daysToInactive, existingProduct.daysToDormancy,
existingProduct.daysToEscheat, existingProduct.accountMappingForPayment);
existingProduct.daysToEscheat, existingProduct.accountMappingForPayment, existingProduct.accrualCharges);
}

public static SavingsProductData instance(final Long id, final String name, final String shortName, final String description,
Expand Down Expand Up @@ -268,6 +272,7 @@ public static SavingsProductData instance(final Long id, final String name, fina
final Collection<ChargeData> chargeOptions = null;
final Collection<ChargeData> penaltyOptions = null;
final Collection<ChargeData> charges = null;
final Collection<ChargeData> accrualCharges = null;
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
final Collection<ChargeToGLAccountMapper> penaltyToIncomeAccountMappings = null;
final Collection<TaxGroupData> taxGroupOptions = null;
Expand All @@ -282,7 +287,7 @@ public static SavingsProductData instance(final Long id, final String name, fina
penaltyOptions, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, allowOverdraft, overdraftLimit,
minRequiredBalance, enforceMinRequiredBalance, maxAllowedLienLimit, lienAllowed, minBalanceForInterestCalculation,
nominalAnnualInterestRateOverdraft, minOverdraftForInterestCalculation, withHoldTax, taxGroup, taxGroupOptions,
isDormancyTrackingActive, daysToInactive, daysToDormancy, daysToEscheat, accountMappingForPayment);
isDormancyTrackingActive, daysToInactive, daysToDormancy, daysToEscheat, accountMappingForPayment, accrualCharges);
}

public static SavingsProductData lookup(final Long id, final String name) {
Expand Down Expand Up @@ -325,6 +330,7 @@ public static SavingsProductData lookup(final Long id, final String name) {
final Collection<EnumOptionData> accountingRuleOptions = null;
final Map<String, List<GLAccountData>> accountingMappingOptions = null;
final Collection<ChargeData> charges = null;
final Collection<ChargeData> accrualCharges = null;
final Collection<ChargeData> chargeOptions = null;
final Collection<ChargeData> penaltyOptions = null;
final Collection<ChargeToGLAccountMapper> feeToIncomeAccountMappings = null;
Expand All @@ -345,7 +351,7 @@ public static SavingsProductData lookup(final Long id, final String name) {
penaltyOptions, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, allowOverdraft, overdraftLimit,
minRequiredBalance, enforceMinRequiredBalance, maxAllowedLienLimit, lienAllowed, minBalanceForInterestCalculation,
nominalAnnualInterestRateOverdraft, minOverdraftForInterestCalculation, withHoldTax, taxGroup, taxGroupOptions,
isDormancyTrackingActive, daysToInactive, daysToDormancy, daysToEscheat, accountMappingForPayment);
isDormancyTrackingActive, daysToInactive, daysToDormancy, daysToEscheat, accountMappingForPayment, accrualCharges);
}

public static SavingsProductData createForInterestPosting(final Long id, final EnumOptionData accountingRule) {
Expand Down Expand Up @@ -386,6 +392,7 @@ private SavingsProductData(final Long id, final EnumOptionData accountingRule) {

this.charges = null;// charges associated with Savings product
this.chargeOptions = null;// charges available for adding to
this.accrualCharges = null;
// Savings product
this.penaltyOptions = null;// penalties available for adding
// to Savings product
Expand Down Expand Up @@ -433,7 +440,7 @@ private SavingsProductData(final Long id, final String name, final String shortN
final BigDecimal nominalAnnualInterestRateOverdraft, final BigDecimal minOverdraftForInterestCalculation,
final boolean withHoldTax, final TaxGroupData taxGroup, final Collection<TaxGroupData> taxGroupOptions,
final Boolean isDormancyTrackingActive, final Long daysToInactive, final Long daysToDormancy, final Long daysToEscheat,
final String accountMappingForPayment) {
final String accountMappingForPayment, final Collection<ChargeData> accrualCharges) {
this.id = id;
this.name = name;
this.shortName = shortName;
Expand Down Expand Up @@ -469,6 +476,7 @@ private SavingsProductData(final Long id, final String name, final String shortN
this.paymentChannelToFundSourceMappings = paymentChannelToFundSourceMappings;

this.charges = charges;// charges associated with Savings product
this.accrualCharges = accrualCharges;
this.chargeOptions = chargeOptions;// charges available for adding to
// Savings product
this.penaltyOptions = penaltyOptions;// penalties available for adding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public interface ChargeReadPlatformService {
*/
Collection<ChargeData> retrieveSavingsProductCharges(Long savingsProductId);

Collection<ChargeData> retrieveSavingsProductAccrualCharges(Long savingsProductId);

/** Retrieve savings account charges **/
Collection<ChargeData> retrieveSavingsAccountApplicableCharges(Long savingsId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ public String savingsProductChargeSchema() {
return chargeSchema() + " join m_savings_product_charge spc on spc.charge_id = c.id";
}

public String savingsProductAccrualChargeSchema() {
return chargeSchema() + " join m_savings_product_accrual_charge spc on spc.charge_id = c.id";
}

public String shareProductChargeSchema() {
return chargeSchema() + " join m_share_product_charge mspc on mspc.charge_id = c.id";
}
Expand Down Expand Up @@ -431,6 +435,17 @@ public Collection<ChargeData> retrieveSavingsProductCharges(final Long savingsPr
return this.jdbcTemplate.query(sql, rm, new Object[] { savingsProductId }); // NOSONAR
}

@Override
public Collection<ChargeData> retrieveSavingsProductAccrualCharges(final Long savingsProductId) {
final ChargeMapper rm = new ChargeMapper();

String sql = "select " + rm.savingsProductAccrualChargeSchema()
+ " where c.is_deleted=false and c.is_active=true and spc.savings_product_id=? ";
sql += addInClauseToSQL_toLimitChargesMappedToOffice_ifOfficeSpecificProductsEnabled();

return this.jdbcTemplate.query(sql, rm, new Object[] { savingsProductId }); // NOSONAR
}

@Override
public Collection<ChargeData> retrieveShareProductCharges(final Long shareProductId) {
final ChargeMapper rm = new ChargeMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ public String retrieveOne(@PathParam("productId") @Parameter(description = "prod
SavingsProductData savingProductData = this.savingProductReadPlatformService.retrieveOne(productId);

final Collection<ChargeData> charges = this.chargeReadPlatformService.retrieveSavingsProductCharges(productId);
final Collection<ChargeData> accrualCharges = this.chargeReadPlatformService.retrieveSavingsProductAccrualCharges(productId);

savingProductData = SavingsProductData.withCharges(savingProductData, charges);
savingProductData = SavingsProductData.withCharges(savingProductData, charges, accrualCharges);

final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());

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

import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;

/**
Expand Down Expand Up @@ -70,6 +69,7 @@ private PostSavingsCharges() {}
@Schema(example = "1")
public Integer accountingRule;
public Set<PostSavingsCharges> charges;
public Set<PostSavingsCharges> accrualCharges;
@Schema(example = "accountMappingForPayment")
public String accountMappingForPayment;
}
Expand Down Expand Up @@ -396,6 +396,20 @@ private GetSavingsProductsPenaltyToIncomeAccountMappingsCharge() {}
public GetSavingsProductsAccountingMappings.GetSavingsProductsIncomeFromPenaltyAccount incomeAccount;
}

static final class GetSavingsProductsCharge {

private GetSavingsProductsCharge() {}

@Schema(example = "12")
public Integer id;
@Schema(example = "12.34")
public BigDecimal amount;
@Schema(example = "Annual Fee")
public String name;
@Schema(example = "false")
public Boolean active;
}

@Schema(example = "1")
public Integer id;
@Schema(example = "savings product")
Expand All @@ -419,7 +433,9 @@ private GetSavingsProductsPenaltyToIncomeAccountMappingsCharge() {}
public Set<GetSavingsProductsFeeToIncomeAccountMappings> feeToIncomeAccountMappings;
public Set<GetSavingsProductsPenaltyToIncomeAccountMappings> penaltyToIncomeAccountMappings;
@Schema(example = "[]")
public List<Integer> charges;
public Set<GetSavingsProductsCharge> charges;
@Schema(example = "[]")
public Set<GetSavingsProductsCharge> accrualCharges;
}

@Schema(description = "GetSavingsProductsTemplateResponse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public class SavingsProductDataValidator {
nominalAnnualInterestRateOverdraftParamName, minOverdraftForInterestCalculationParamName,
SavingsApiConstants.minRequiredBalanceParamName, SavingsApiConstants.enforceMinRequiredBalanceParamName,
SavingsApiConstants.maxAllowedLienLimitParamName, SavingsApiConstants.lienAllowedParamName,
minBalanceForInterestCalculationParamName, withHoldTaxParamName, taxGroupIdParamName));
minBalanceForInterestCalculationParamName, withHoldTaxParamName, taxGroupIdParamName,
SavingsApiConstants.accrualChargesParamName));

@Autowired
public SavingsProductDataValidator(final FromJsonHelper fromApiJsonHelper) {
Expand Down
Loading

0 comments on commit ef1cfd0

Please sign in to comment.