Merge pull request #1097 from pramodn02/testcase

periodic accounting API changes
This commit is contained in:
Vishwas Babu A J
2014-10-06 00:05:29 -07:00
6 changed files with 19 additions and 11 deletions
+4 -4
View File
@@ -31104,7 +31104,7 @@ Content-Type: application/json
<td><div class="mifosXHeading2">Field Descriptions</div></td> <td><div class="mifosXHeading2">Field Descriptions</div></td>
</tr> </tr>
<tr class=alt> <tr class=alt>
<td>accrueTill</td> <td>tillDate</td>
</tr> </tr>
<tr> <tr>
<td class=fielddesc>which specifies periodic accruals should happen till the given Date <td class=fielddesc>which specifies periodic accruals should happen till the given Date
@@ -31126,7 +31126,7 @@ Content-Type: application/json
<td><div class="mifosXHeading2">Mandatory Fields</div></td> <td><div class="mifosXHeading2">Mandatory Fields</div></td>
</tr> </tr>
<tr class=alt> <tr class=alt>
<td>accrueTill <td>tillDate
</td> </td>
</tr> </tr>
@@ -31136,7 +31136,7 @@ Content-Type: application/json
</div> </div>
<div class="method-example"> <div class="method-example">
<code class="method-declaration"> <code class="method-declaration">
POST https://DomainName/api/v1/accrualaccounting POST https://DomainName/api/v1/runaccruals
</code> </code>
<code class="method-request"> <code class="method-request">
POST financialactivityaccounts POST financialactivityaccounts
@@ -31145,7 +31145,7 @@ Request Body:
{ {
"locale": "en", "locale": "en",
"dateFormat": "dd MMMM yyyy", "dateFormat": "dd MMMM yyyy",
"accrueTill":"04 June 2014" "tillDate":"04 June 2014"
} }
</code> </code>
<code class="method-response"> <code class="method-response">
@@ -15,7 +15,7 @@ import com.jayway.restassured.specification.ResponseSpecification;
public class PeriodicAccrualAccountingHelper { public class PeriodicAccrualAccountingHelper {
private static final String PERIODIC_ACCRUAL_URL = "/mifosng-provider/api/v1/accrualaccounting"; private static final String PERIODIC_ACCRUAL_URL = "/mifosng-provider/api/v1/runaccruals";
private final RequestSpecification requestSpec; private final RequestSpecification requestSpec;
private final ResponseSpecification responseSpec; private final ResponseSpecification responseSpec;
@@ -33,7 +33,7 @@ public class PeriodicAccrualAccountingHelper {
final HashMap<String, String> map = new HashMap<>(); final HashMap<String, String> map = new HashMap<>();
map.put("dateFormat", "dd MMMM yyyy"); map.put("dateFormat", "dd MMMM yyyy");
map.put("locale", "en_GB"); map.put("locale", "en_GB");
map.put("accrueTill", date); map.put("tillDate", date);
return new Gson().toJson(map); return new Gson().toJson(map);
} }
@@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Path("/accrualaccounting") @Path("/runaccruals")
@Component @Component
@Scope("singleton") @Scope("singleton")
public class AccrualAccountingApiResource { public class AccrualAccountingApiResource {
@@ -11,7 +11,7 @@ import java.util.Set;
public class AccrualAccountingConstants { public class AccrualAccountingConstants {
public static final String accrueTillParamName = "accrueTill"; public static final String accrueTillParamName = "tillDate";
public static final String localeParamName = "locale"; public static final String localeParamName = "locale";
public static final String dateFormatParamName = "dateFormat"; public static final String dateFormatParamName = "dateFormat";
@@ -231,7 +231,9 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
if (reducePrincipal.isGreaterThanZero()) { if (reducePrincipal.isGreaterThanZero()) {
switch (loanApplicationTerms.getRescheduleStrategyMethod()) { switch (loanApplicationTerms.getRescheduleStrategyMethod()) {
case REDUCE_EMI_AMOUNT: case REDUCE_EMI_AMOUNT:
loanApplicationTerms.setFixedEmiAmount(null); if (!loanApplicationTerms.isMultiDisburseLoan()) {
loanApplicationTerms.setFixedEmiAmount(null);
}
fixedEmiAmount = fixedEmiAmount.zero(); fixedEmiAmount = fixedEmiAmount.zero();
outstandingBalance = outstandingBalance.minus(reducePrincipal); outstandingBalance = outstandingBalance.minus(reducePrincipal);
balanceForcalculation = balanceForcalculation.minus(reducePrincipal); balanceForcalculation = balanceForcalculation.minus(reducePrincipal);
@@ -1659,13 +1661,14 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
.getId() != null && loanTransaction.getId().compareTo(precloseTransaction.getId()) == 1)))) { .getId() != null && loanTransaction.getId().compareTo(precloseTransaction.getId()) == 1)))) {
precloseTransaction = loanTransaction; precloseTransaction = loanTransaction;
} }
collectedPrincipal = collectedPrincipal.plus(loanTransaction.getPrincipalPortion()); collectedPrincipal = collectedPrincipal.plus(loanTransaction.getPrincipalPortion());
} }
if (precloseTransaction != null) { if (precloseTransaction != null) {
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = calculatePrepaymentAmount(installments, currency, LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = calculatePrepaymentAmount(installments, currency,
precloseTransaction.getTransactionDate(), applicationTerms.getInterestChargedFromLocalDate(), applicationTerms, mc, precloseTransaction.getTransactionDate(), applicationTerms.getInterestChargedFromLocalDate(), applicationTerms, mc,
loanCharges); loanCharges);
Money pendingPrinciapl = applicationTerms.getPrincipal().minus(collectedPrincipal).plus(precloseTransaction.getPrincipalPortion()); Money pendingPrinciapl = applicationTerms.getPrincipal().minus(collectedPrincipal)
.plus(precloseTransaction.getPrincipalPortion());
if (pendingPrinciapl.isGreaterThan(loanRepaymentScheduleInstallment.getPrincipal(currency)) if (pendingPrinciapl.isGreaterThan(loanRepaymentScheduleInstallment.getPrincipal(currency))
|| precloseTransaction.getAmount(currency).isLessThan(loanRepaymentScheduleInstallment.getTotalOutstanding(currency))) { || precloseTransaction.getAmount(currency).isLessThan(loanRepaymentScheduleInstallment.getTotalOutstanding(currency))) {
precloseTransaction = null; precloseTransaction = null;
@@ -61,6 +61,7 @@ import org.mifosplatform.portfolio.calendar.domain.CalendarInstance;
import org.mifosplatform.portfolio.calendar.domain.CalendarInstanceRepository; import org.mifosplatform.portfolio.calendar.domain.CalendarInstanceRepository;
import org.mifosplatform.portfolio.calendar.domain.CalendarRepository; import org.mifosplatform.portfolio.calendar.domain.CalendarRepository;
import org.mifosplatform.portfolio.calendar.domain.CalendarType; import org.mifosplatform.portfolio.calendar.domain.CalendarType;
import org.mifosplatform.portfolio.calendar.exception.CalendarParameterUpdateNotSupportedException;
import org.mifosplatform.portfolio.charge.domain.Charge; import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.charge.domain.ChargePaymentMode; import org.mifosplatform.portfolio.charge.domain.ChargePaymentMode;
import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper; import org.mifosplatform.portfolio.charge.domain.ChargeRepositoryWrapper;
@@ -1732,6 +1733,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
// loop through each loan to reschedule the repayment dates // loop through each loan to reschedule the repayment dates
for (final Loan loan : loans) { for (final Loan loan : loans) {
if (loan != null) { if (loan != null) {
if(loan.repaymentScheduleDetail().isInterestRecalculationEnabled()){
final String defaultUserMessage = "Meeting calendar type update is not supported";
throw new CalendarParameterUpdateNotSupportedException("jlg.loan.recalculation", defaultUserMessage);
}
holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan.getDisbursementDate().toDate()); holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan.getDisbursementDate().toDate());
loan.updateLoanRepaymentScheduleDates(calendar.getStartDateLocalDate(), calendar.getRecurrence(), isHolidayEnabled, loan.updateLoanRepaymentScheduleDates(calendar.getStartDateLocalDate(), calendar.getRecurrence(), isHolidayEnabled,
holidays, workingDays); holidays, workingDays);