Skip to content

Commit

Permalink
Merge feature FBR-104 (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardohildt authored Oct 5, 2023
1 parent 51595d5 commit 2c71e40
Show file tree
Hide file tree
Showing 21 changed files with 743 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class ChargesApiResource {
"chargeAppliesTo", "chargeTimeType", "chargeCalculationType", "chargeCalculationTypeOptions", "chargeAppliesToOptions",
"chargeTimeTypeOptions", "currencyOptions", "loanChargeCalculationTypeOptions", "loanChargeTimeTypeOptions",
"savingsChargeCalculationTypeOptions", "savingsChargeTimeTypeOptions", "incomeAccount", "clientChargeCalculationTypeOptions",
"clientChargeTimeTypeOptions"));
"clientChargeTimeTypeOptions", "adminFeeRanges", "chargeDisbursementType", "chargeDisbursementTypeOptions"));

private final String resourceNameForPermissions = "CHARGE";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.MonthDay;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.portfolio.charge.domain.ChargeRange;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
import org.apache.fineract.portfolio.loanaccount.data.LoanChargeData;
import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData;
Expand Down Expand Up @@ -63,6 +65,7 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
private final EnumOptionData feeFrequency;
private final GLAccountData incomeOrLiabilityAccount;
private final TaxGroupData taxGroup;
private final EnumOptionData chargeDisbursementType;

private final Collection<CurrencyData> currencyOptions;
private final List<EnumOptionData> chargeCalculationTypeOptions;//
Expand All @@ -87,6 +90,8 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
private final String accountMappingForChargeConfig;
private final List<GLAccountData> expenseAccountOptions;
private final List<GLAccountData> assetAccountOptions;
private List<ChargeRangeData> chargeRanges;
private final List<EnumOptionData> chargeDisbursementTypeOptions;

public static ChargeData template(final Collection<CurrencyData> currencyOptions,
final List<EnumOptionData> chargeCalculationTypeOptions, final List<EnumOptionData> chargeAppliesToOptions,
Expand All @@ -97,7 +102,8 @@ public static ChargeData template(final Collection<CurrencyData> currencyOptions
final List<EnumOptionData> feeFrequencyOptions, final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions,
final Collection<TaxGroupData> taxGroupOptions, final List<EnumOptionData> shareChargeCalculationTypeOptions,
final List<EnumOptionData> shareChargeTimeTypeOptions, String accountMappingForChargeConfig,
List<GLAccountData> expenseAccountOptions, List<GLAccountData> assetAccountOptions) {
List<GLAccountData> expenseAccountOptions, List<GLAccountData> assetAccountOptions,
final List<EnumOptionData> chargeDisbursementTypeOptions) {
final GLAccountData account = null;
final TaxGroupData taxGroupData = null;

Expand All @@ -107,7 +113,7 @@ public static ChargeData template(final Collection<CurrencyData> currencyOptions
savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
clientChargeTimeTypeOptions, null, null, null, null, null, feeFrequencyOptions, account, incomeOrLiabilityAccountOptions,
taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions, accountMappingForChargeConfig,
expenseAccountOptions, assetAccountOptions);
expenseAccountOptions, assetAccountOptions, chargeDisbursementTypeOptions, null, null);
}

public static ChargeData withTemplate(final ChargeData charge, final ChargeData template) {
Expand All @@ -121,7 +127,8 @@ public static ChargeData withTemplate(final ChargeData charge, final ChargeData
charge.feeOnMonthDay, charge.feeInterval, charge.minCap, charge.maxCap, charge.feeFrequency, template.feeFrequencyOptions,
charge.incomeOrLiabilityAccount, template.incomeOrLiabilityAccountOptions, template.taxGroupOptions,
template.shareChargeCalculationTypeOptions, template.shareChargeTimeTypeOptions, template.accountMappingForChargeConfig,
template.expenseAccountOptions, template.assetAccountOptions);
template.expenseAccountOptions, template.assetAccountOptions, template.chargeDisbursementTypeOptions,
charge.chargeDisbursementType, charge.chargeRanges);
}

public static ChargeData instance(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
Expand All @@ -130,7 +137,7 @@ public static ChargeData instance(final Long id, final String name, final BigDec
final boolean active, final boolean freeWithdrawal, final Integer freeWithdrawalChargeFrequency, final Integer restartFrequency,
final Integer restartFrequencyEnum, final boolean isPaymentType, final PaymentTypeData paymentTypeOptions,
final BigDecimal minCap, final BigDecimal maxCap, final EnumOptionData feeFrequency, final GLAccountData accountData,
TaxGroupData taxGroupData) {
TaxGroupData taxGroupData, final EnumOptionData chargeDisbursementType) {

final Collection<CurrencyData> currencyOptions = null;
final List<EnumOptionData> chargeCalculationTypeOptions = null;
Expand All @@ -151,14 +158,17 @@ public static ChargeData instance(final Long id, final String name, final BigDec
final String accountMappingForChargeConfig = null;
final List<GLAccountData> expenseAccountOptions = null;
final List<GLAccountData> assetAccountOptions = null;
final List<EnumOptionData> chargeDisbursementTypeOptions = null;

return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode,
penalty, active, freeWithdrawal, freeWithdrawalChargeFrequency, restartFrequency, restartFrequencyEnum, isPaymentType,
paymentTypeOptions, taxGroupData, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions,
chargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions,
savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, accountData,
incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions,
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions, chargeDisbursementTypeOptions,
chargeDisbursementType, null);
}

public static ChargeData lookup(final Long id, final String name, final boolean isPenalty) {
Expand All @@ -168,6 +178,7 @@ public static ChargeData lookup(final Long id, final String name, final boolean
final EnumOptionData chargeAppliesTo = null;
final EnumOptionData chargeCalculationType = null;
final EnumOptionData chargePaymentMode = null;
final EnumOptionData chargeDisbursementType = null;
final MonthDay feeOnMonthDay = null;
final Integer feeInterval = null;
final Boolean penalty = isPenalty;
Expand Down Expand Up @@ -202,6 +213,8 @@ public static ChargeData lookup(final Long id, final String name, final boolean
final String accountMappingForChargeConfig = null;
final List<GLAccountData> expenseAccountOptions = null;
final List<GLAccountData> assetAccountOptions = null;
final List<EnumOptionData> chargeDisbursementTypeOptions = null;
final List<ChargeRangeData> chargeRanges = null;

return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode,
penalty, active, freeWithdrawal, freeWithdrawalChargeFrequency, restartFrequency, restartFrequencyEnum, isPaymentType,
Expand All @@ -210,7 +223,8 @@ public static ChargeData lookup(final Long id, final String name, final boolean
savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, account,
incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions,
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions, chargeDisbursementTypeOptions,
chargeDisbursementType, chargeRanges);
}

private ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
Expand All @@ -229,7 +243,8 @@ private ChargeData(final Long id, final String name, final BigDecimal amount, fi
final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions, final Collection<TaxGroupData> taxGroupOptions,
final List<EnumOptionData> shareChargeCalculationTypeOptions, final List<EnumOptionData> shareChargeTimeTypeOptions,
final String accountMappingForChargeConfig, final List<GLAccountData> expenseAccountOptions,
final List<GLAccountData> assetAccountOptions) {
final List<GLAccountData> assetAccountOptions, final List<EnumOptionData> chargeDisbursementTypeOptions,
final EnumOptionData chargeDisbursementType, final List<ChargeRangeData> chargeRanges) {
this.id = id;
this.name = name;
this.amount = amount;
Expand All @@ -250,6 +265,7 @@ private ChargeData(final Long id, final String name, final BigDecimal amount, fi
this.paymentTypeOptions = paymentTypeOptions;
this.minCap = minCap;
this.maxCap = maxCap;
this.chargeDisbursementType = chargeDisbursementType;
this.currencyOptions = currencyOptions;
this.chargeCalculationTypeOptions = chargeCalculationTypeOptions;
this.chargeAppliesToOptions = chargeAppliesToOptions;
Expand All @@ -272,6 +288,8 @@ private ChargeData(final Long id, final String name, final BigDecimal amount, fi
this.accountMappingForChargeConfig = accountMappingForChargeConfig;
this.assetAccountOptions = assetAccountOptions;
this.expenseAccountOptions = expenseAccountOptions;
this.chargeDisbursementTypeOptions = chargeDisbursementTypeOptions;
this.chargeRanges = chargeRanges;
}

@Override
Expand Down Expand Up @@ -388,4 +406,24 @@ public BigDecimal getAmount() {
public CurrencyData getCurrency() {
return currency;
}

public void addRange(ChargeRange chargeRange) {
if (this.chargeRanges == null) {
this.chargeRanges = new ArrayList();
}
this.chargeRanges.add(new ChargeRangeData(chargeRange.getMinDay(), chargeRange.getMaxDay(), chargeRange.getFeeRate()));
}

public static class ChargeRangeData {

public final Integer adminFeeMin;
public final Integer adminFeeMax;
public final BigDecimal adminFeeRate;

public ChargeRangeData(final Integer adminFeeMin, final Integer adminFeeMax, BigDecimal adminFeeRate) {
this.adminFeeMin = adminFeeMin;
this.adminFeeMax = adminFeeMax;
this.adminFeeRate = adminFeeRate;
}
}
}
Loading

0 comments on commit 2c71e40

Please sign in to comment.