fixed error db migration and rd product edit error fixed

This commit is contained in:
Nitesh Yadav
2026-05-12 11:32:13 +05:30
parent 6544ad3cbc
commit 30bbd6d0af
6 changed files with 15081 additions and 16339 deletions
@@ -46,6 +46,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
@@ -265,6 +266,11 @@ public class InterestRateChart extends AbstractPersistableCustom<Long> {
chartSlab.update(chartSlabsCommand, chartSlabsChanges, baseDataValidator, locale);
}
} else {
final InterestRateChartSlab matchingChartSlab = this.findChartSlabByRanges(chartSlabsCommand, locale);
if (matchingChartSlab != null) {
matchingChartSlab.update(chartSlabsCommand, chartSlabsChanges, baseDataValidator, locale);
continue;
}
/**
* TODO: AA: Move this code to InterestRateChartSlabAssembler
@@ -321,6 +327,24 @@ public class InterestRateChart extends AbstractPersistableCustom<Long> {
return chartSlabs.remove(chartSlab);
}
private InterestRateChartSlab findChartSlabByRanges(final JsonCommand chartSlabsCommand, final Locale locale) {
final Integer fromPeriod = chartSlabsCommand.integerValueOfParameterNamed(fromPeriodParamName, locale);
final Integer toPeriod = chartSlabsCommand.integerValueOfParameterNamed(toPeriodParamName, locale);
final BigDecimal amountRangeFrom = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeFromParamName, locale);
final BigDecimal amountRangeTo = chartSlabsCommand.bigDecimalValueOfParameterNamed(amountRangeToParamName, locale);
for (InterestRateChartSlab chartSlab : setOfChartSlabs()) {
final InterestRateChartSlabFields slabFields = chartSlab.slabFields();
if (Objects.equals(slabFields.fromPeriod(), fromPeriod) && Objects.equals(slabFields.toPeriod(), toPeriod)
&& slabFields.isBigDecimalSame(slabFields.getAmountRangeFrom(), amountRangeFrom)
&& slabFields.isBigDecimalSame(slabFields.getAmountRangeTo(), amountRangeTo)) {
return chartSlab;
}
}
return null;
}
public LocalDate getFromDate() {
return this.chartFields.getFromDate();
}
@@ -19,6 +19,8 @@
package org.apache.fineract.portfolio.savings.domain;
import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.deleteParamName;
import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.endDateParamName;
import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.fromDateParamName;
import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.idParamName;
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME;
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.maxDepositTermParamName;
@@ -45,6 +47,7 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.apache.fineract.accounting.common.AccountingRuleType;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -215,10 +218,16 @@ public class FixedDepositProduct extends SavingsProduct {
chart.update(chartCommand, chartsChanges, baseDataValidator, this.setOfCharts(), this.currency().getCode());
}
} else {
// assemble chart
final InterestRateChart newChart = this.chartAssembler.assembleFrom(chartElement, this.currency().getCode(),
baseDataValidator);
this.addChart(newChart);
final InterestRateChart matchingChart = this.findChartByDates(chartCommand);
if (matchingChart != null) {
matchingChart.update(chartCommand, chartsChanges, baseDataValidator, this.setOfCharts(),
this.currency().getCode());
} else {
// assemble chart
final InterestRateChart newChart = this.chartAssembler.assembleFrom(chartElement, this.currency().getCode(),
baseDataValidator);
this.addChart(newChart);
}
}
}
}
@@ -260,6 +269,23 @@ public class FixedDepositProduct extends SavingsProduct {
return charts.remove(chart);
}
private InterestRateChart findChartByDates(final JsonCommand chartCommand) {
if (!chartCommand.parameterExists(fromDateParamName) || !chartCommand.parameterExists(endDateParamName)) {
return this.charts != null && this.charts.size() == 1 ? this.charts.iterator().next() : null;
}
final LocalDate fromDate = chartCommand.localDateValueOfParameterNamed(fromDateParamName);
final LocalDate endDate = chartCommand.localDateValueOfParameterNamed(endDateParamName);
for (InterestRateChart chart : setOfCharts()) {
if (Objects.equals(chart.getFromDate(), fromDate) && Objects.equals(chart.getEndDate(), endDate)) {
return chart;
}
}
return null;
}
public void setHelpers(final InterestRateChartAssembler chartAssembler) {
this.chartAssembler = chartAssembler;
}
@@ -71,6 +71,32 @@
</addColumn>
</changeSet>
<changeSet author="fineract" id="2010b-add-nomination-facility-to-savings-account">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="m_savings_account" columnName="nomination_facility"/>
</not>
</preConditions>
<addColumn tableName="m_savings_account">
<column name="nomination_facility" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<changeSet author="fineract" id="2010c-add-auto-debit-facility-to-savings-account">
<preConditions onFail="MARK_RAN">
<not>
<columnExists tableName="m_savings_account" columnName="auto_debit_facility"/>
</not>
</preConditions>
<addColumn tableName="m_savings_account">
<column name="auto_debit_facility" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<!-- Facility config table for savings accounts -->
<changeSet author="fineract" id="2010-create-savings-account-facility-config">
<createTable tableName="m_savings_account_facility_config">