update state transition and transaction api for loans.
This commit is contained in:
@@ -1,98 +0,0 @@
|
||||
package org.mifosng.data.command;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
public class AdjustLoanTransactionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private Long repaymentId;
|
||||
private String dateFormat;
|
||||
private String transactionDateFormatted;
|
||||
private LocalDate transactionDate;
|
||||
private String comment;
|
||||
private String transactionAmountFormatted;
|
||||
private BigDecimal transactionAmount;
|
||||
|
||||
protected AdjustLoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public AdjustLoanTransactionCommand(final Long loanId, final Long repaymentId,
|
||||
final LocalDate paymentDate, final String comment,
|
||||
final BigDecimal paymentAmount) {
|
||||
this.loanId = loanId;
|
||||
this.repaymentId = repaymentId;
|
||||
this.transactionDate = paymentDate;
|
||||
this.comment = comment;
|
||||
this.transactionAmount = paymentAmount;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public Long getRepaymentId() {
|
||||
return repaymentId;
|
||||
}
|
||||
|
||||
public void setRepaymentId(Long repaymentId) {
|
||||
this.repaymentId = repaymentId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getTransactionDateFormatted() {
|
||||
return transactionDateFormatted;
|
||||
}
|
||||
|
||||
public void setTransactionDateFormatted(String transactionDateFormatted) {
|
||||
this.transactionDateFormatted = transactionDateFormatted;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(LocalDate transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getTransactionAmountFormatted() {
|
||||
return transactionAmountFormatted;
|
||||
}
|
||||
|
||||
public void setTransactionAmountFormatted(String transactionAmountFormatted) {
|
||||
this.transactionAmountFormatted = transactionAmountFormatted;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(BigDecimal transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package org.mifosng.data.command;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
public class LoanTransactionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String dateFormat;
|
||||
private String transactionDateFormatted;
|
||||
private LocalDate transactionDate;
|
||||
private String comment;
|
||||
private String transactionAmountFormatted;
|
||||
private BigDecimal transactionAmount;
|
||||
|
||||
protected LoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanTransactionCommand(final Long loanId,
|
||||
final LocalDate paymentDate, final String comment,
|
||||
final BigDecimal paymentAmount) {
|
||||
this.loanId = loanId;
|
||||
this.transactionDate = paymentDate;
|
||||
this.comment = comment;
|
||||
this.transactionAmount = paymentAmount;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(final String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getTransactionDateFormatted() {
|
||||
return transactionDateFormatted;
|
||||
}
|
||||
|
||||
public void setTransactionDateFormatted(String transactionDateFormatted) {
|
||||
this.transactionDateFormatted = transactionDateFormatted;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(LocalDate transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public String getTransactionAmountFormatted() {
|
||||
return transactionAmountFormatted;
|
||||
}
|
||||
|
||||
public void setTransactionAmountFormatted(String transactionAmountFormatted) {
|
||||
this.transactionAmountFormatted = transactionAmountFormatted;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(BigDecimal transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
}
|
||||
+7
-24
@@ -139,9 +139,9 @@ $(document).ready(function() {
|
||||
removeErrors(placeholderDiv);
|
||||
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
console.log(jsonErrors);
|
||||
|
||||
var valErrors = jsonErrors.errors;
|
||||
console.log(valErrors);
|
||||
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(valErrors, function() {
|
||||
@@ -158,7 +158,7 @@ $(document).ready(function() {
|
||||
argArray[argArrayIndex] = this.value;
|
||||
argArrayIndex++;
|
||||
});
|
||||
console.log(argArray);
|
||||
|
||||
// hardcoded support for six arguments
|
||||
errorObj.message = jQuery.i18n.prop(this.userMessageGlobalisationCode, argArray[0], argArray[1], argArray[2], argArray[3], argArray[4], argArray[5]);
|
||||
errorObj.value = this.value;
|
||||
@@ -292,7 +292,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: postUrl,
|
||||
@@ -302,7 +301,6 @@ $(document).ready(function() {
|
||||
cache: false,
|
||||
data: newFormData,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
@@ -377,7 +375,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: postUrl,
|
||||
@@ -435,8 +432,6 @@ $(document).ready(function() {
|
||||
var $newtabs = $("#newtabs").tabs({
|
||||
|
||||
"add": function( event, ui ) {
|
||||
console.log(ui);
|
||||
//alert("adding new tab: " + ui.panel.id + " :" + ui.tab.className);
|
||||
$newtabs.tabs('select', '#' + ui.panel.id);
|
||||
},
|
||||
"ajaxOptions": {
|
||||
@@ -445,7 +440,6 @@ $(document).ready(function() {
|
||||
contentType: 'application/json',
|
||||
cache: false,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
error: function(jqXHR, status, errorThrown, index, anchor) {
|
||||
@@ -455,12 +449,8 @@ $(document).ready(function() {
|
||||
},
|
||||
success: function(data, status, xhr) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
var currentTabIndex = $newtabs.tabs('option', 'selected');
|
||||
var currentTabAnchor = $newtabs.data('tabs').anchors[currentTabIndex];
|
||||
//$(currentTabAnchor).data('cache.tabs', true)
|
||||
//alert('tab: ' + currentTabIndex + ' - id: ' + currentTabAnchor);
|
||||
|
||||
var offsetToSubmittedDate = 0;
|
||||
var offsetToApprovalDate = 0;
|
||||
@@ -468,7 +458,6 @@ $(document).ready(function() {
|
||||
var maxOffset = 0; // today
|
||||
|
||||
if (currentTabIndex < 1) {
|
||||
console.log("success: client tab.");
|
||||
var tableHtml = $("#clientDataTabTemplate").render(data);
|
||||
$("#clienttab").html(tableHtml);
|
||||
|
||||
@@ -653,8 +642,8 @@ $(document).ready(function() {
|
||||
|
||||
var linkId = this.id;
|
||||
var loanId = linkId.replace("repaymentbtn", "");
|
||||
var getUrl = baseApiUrl + 'loans/' + loanId + '/transactions/template?transactionType=repayment';
|
||||
var postUrl = baseApiUrl + 'loans/' + loanId + '/transactions?transactionType=repayment';
|
||||
var getUrl = baseApiUrl + 'loans/' + loanId + '/transactions/template?command=repayment';
|
||||
var postUrl = baseApiUrl + 'loans/' + loanId + '/transactions?command=repayment';
|
||||
|
||||
var templateSelector = "#transactionLoanFormTemplate";
|
||||
var width = 500;
|
||||
@@ -676,8 +665,8 @@ $(document).ready(function() {
|
||||
var linkId = this.id;
|
||||
var loanId = linkId.replace("waivebtn", "");
|
||||
|
||||
var getUrl = baseApiUrl + 'loans/' + loanId + '/transactions/template?transactionType=waiver';
|
||||
var postUrl = baseApiUrl + 'loans/' + loanId + '/transactions?transactionType=waiver';
|
||||
var getUrl = baseApiUrl + 'loans/' + loanId + '/transactions/template?command=waiver';
|
||||
var postUrl = baseApiUrl + 'loans/' + loanId + '/transactions?command=waiver';
|
||||
|
||||
var templateSelector = "#transactionLoanFormTemplate";
|
||||
var width = 500;
|
||||
@@ -690,7 +679,6 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getUrl, postUrl, 'POST', "dialog.title.waive.loan", templateSelector, width, height, saveSuccessFunction);
|
||||
//popupDialogWithFormView(getUrl, postUrl, 'POST', 'dialog.title.waive.loan', templateSelector, width, height, currentTabIndex, offsetToSubmittedDate, defaultOffset, maxOffset)
|
||||
e.preventDefault();
|
||||
});
|
||||
$('button.waiveloan span').text(jQuery.i18n.prop('dialog.button.loan.waive'));
|
||||
@@ -715,7 +703,6 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getAndPutUrl, getAndPutUrl, 'PUT', "dialog.title.adjust.loan.repayment", templateSelector, width, height, saveSuccessFunction);
|
||||
// popupDialogWithFormView(getAndPutUrl, getAndPutUrl, 'PUT', 'dialog.title.adjust.loan.repayment', templateSelector, width, height, currentTabIndex, offsetToSubmittedDate, defaultOffset, maxOffset)
|
||||
e.preventDefault();
|
||||
});
|
||||
$('button.adjustloanrepayment span').text(jQuery.i18n.prop('dialog.button.adjust.loan.repayment'));
|
||||
@@ -748,11 +735,9 @@ $(document).ready(function() {
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
beforeSend: function(xhr) {
|
||||
console.log("base64: " + base64);
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
var tableHtml = $("#clientAccountSummariesTemplate").render(data);
|
||||
$("#clientaccountssummary").html(tableHtml);
|
||||
|
||||
@@ -786,8 +771,6 @@ $(document).ready(function() {
|
||||
xhr.setRequestHeader("Authorization", "Basic " + base64);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
|
||||
var noteParent = new Object();
|
||||
noteParent.title = jQuery.i18n.prop('widget.notes.heading');
|
||||
noteParent.notes = data;
|
||||
|
||||
@@ -804,11 +804,11 @@
|
||||
<div id="formerrors"></div>
|
||||
|
||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||
<label for="eventDateFormatted"><spring:message code="label.loan.on"/></label>
|
||||
<input id="eventDateFormatted" name="eventDateFormatted" title="" class="datepickerfield" />
|
||||
<label for="eventDate"><spring:message code="label.loan.on"/></label>
|
||||
<input id="eventDate" name="eventDate" title="" class="datepickerfield" />
|
||||
|
||||
<label for="comment"><spring:message code="label.loan.action.note"/></label>
|
||||
<textarea rows="3" cols="53" id="comment" name="comment"></textarea>
|
||||
<label for="note"><spring:message code="label.loan.action.note"/></label>
|
||||
<textarea rows="3" cols="53" id="note" name="note"></textarea>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
@@ -816,8 +816,8 @@
|
||||
<form id="entityform">
|
||||
<div id="formerrors"></div>
|
||||
|
||||
<label for="comment"><spring:message code="label.loan.action.note"/></label>
|
||||
<textarea rows="6" cols="53" id="comment" name="comment"></textarea>
|
||||
<label for="note"><spring:message code="label.loan.action.note"/></label>
|
||||
<textarea rows="6" cols="53" id="note" name="note"></textarea>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
@@ -826,14 +826,14 @@
|
||||
<div id="formerrors"></div>
|
||||
|
||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||
<label for="transactionDateFormatted"><spring:message code="label.loan.transaction.on"/></label>
|
||||
<input id="transactionDateFormatted" name="transactionDateFormatted" cssClass="text ui-widget-content ui-corner-all" title="" class="datepickerfield" value="{{=$ctx.globalDate(date)}}"/>
|
||||
<label for="transactionDate"><spring:message code="label.loan.transaction.on"/></label>
|
||||
<input id="transactionDate" name="transactionDate" class="text ui-widget-content ui-corner-all" title="" class="datepickerfield" value="{{=$ctx.globalDate(date)}}"/>
|
||||
|
||||
<label for="transactionAmountFormatted"><spring:message code="label.loan.transaction.amount"/></label>
|
||||
<input id="transactionAmountFormatted" name="transactionAmountFormatted" cssClass="text ui-widget-content ui-corner-all" title="" value="{{=$ctx.money(total)}}" />
|
||||
<label for="transactionAmount"><spring:message code="label.loan.transaction.amount"/></label>
|
||||
<input id="transactionAmount" name="transactionAmount" class="text ui-widget-content ui-corner-all" title="" value="{{=$ctx.money(total)}}" />
|
||||
|
||||
<label for="comment"><spring:message code="label.loan.action.note"/></label>
|
||||
<textarea rows="3" cols="53" id="comment" name="comment" cssClass="text ui-widget-content ui-corner-all"></textarea>
|
||||
<label for="note"><spring:message code="label.loan.action.note"/></label>
|
||||
<textarea rows="3" cols="53" id="note" name="note" class="text ui-widget-content ui-corner-all"></textarea>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
|
||||
public interface ImportPlatformService {
|
||||
|
||||
|
||||
+11
-11
@@ -19,15 +19,15 @@ import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitApproveDisburseLoanCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitApproveDisburseLoanCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
@@ -140,12 +140,12 @@ public class ImportPlatformServiceImpl implements ImportPlatformService {
|
||||
|
||||
LoanStateTransitionCommand approveLoanCommand = combinedCommand.getApproveLoanCommand();
|
||||
if (approveLoanCommand != null) {
|
||||
loan.approve(approveLoanCommand.getEventDate(), loanLifecycleStateMachine);
|
||||
loan.approve(approveLoanCommand.getEventLocalDate(), loanLifecycleStateMachine);
|
||||
}
|
||||
|
||||
LoanStateTransitionCommand disburseLoanCommand = combinedCommand.getDisburseLoanCommand();
|
||||
if (disburseLoanCommand != null) {
|
||||
loan.disburse(disburseLoanCommand.getEventDate(), loanLifecycleStateMachine);
|
||||
loan.disburse(disburseLoanCommand.getEventLocalDate(), loanLifecycleStateMachine);
|
||||
}
|
||||
|
||||
newLoanCollection.add(loan);
|
||||
@@ -173,9 +173,9 @@ public class ImportPlatformServiceImpl implements ImportPlatformService {
|
||||
for (LoanTransactionCommand repaymentDetail : command.getRepayments()) {
|
||||
Loan loan = findLoanByIdentifier(allLoans, repaymentDetail.getLoanId().toString());
|
||||
|
||||
Money repaymentAmount = Money.of(loan.getCurrency(), repaymentDetail.getTransactionAmount());
|
||||
Money repaymentAmount = Money.of(loan.getCurrency(), repaymentDetail.getTransactionAmountValue());
|
||||
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repaymentAmount, repaymentDetail.getTransactionDate());
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repaymentAmount, repaymentDetail.getTransactionLocalDate());
|
||||
loan.makeRepayment(loanRepayment, loanLifecycleStateMachine);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.mifosng.data.ClientLoanAccountSummaryCollectionData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.OfficeLookup;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
|
||||
@@ -24,12 +24,12 @@ import org.mifosng.data.LoanAccountData;
|
||||
import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||
import org.mifosng.platform.exceptions.UnrecognizedQueryParamException;
|
||||
@@ -187,12 +187,12 @@ public class LoansApiResource {
|
||||
public Response stateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam,
|
||||
final LoanStateTransitionCommand command) {
|
||||
|
||||
LocalDate eventDate = this.apiDataConversionService.convertFrom(
|
||||
command.getEventDateFormatted(), "eventDateFormatted",
|
||||
LocalDate eventLocalDate = this.apiDataConversionService.convertFrom(
|
||||
command.getEventDate(), "eventDate",
|
||||
command.getDateFormat());
|
||||
|
||||
command.setLoanId(loanId);
|
||||
command.setEventDate(eventDate);
|
||||
command.setEventLocalDate(eventLocalDate);
|
||||
|
||||
Response response = null;
|
||||
|
||||
@@ -210,7 +210,7 @@ public class LoansApiResource {
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(loanId, command.getComment());
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(loanId, command.getNote());
|
||||
if (is(commandParam, "undoapproval")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.undoLoanApproval(undoCommand);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
@@ -236,31 +236,37 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response executeLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("transactionType") final String transactionType,
|
||||
@QueryParam("command") final String commandParam,
|
||||
final LoanTransactionCommand command) {
|
||||
|
||||
Response response = null;
|
||||
command.setLoanId(loanId);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService.localeFromString(command.getLocale());
|
||||
|
||||
LocalDate transactionDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDateFormatted(),
|
||||
"transactionDateFormatted", command.getDateFormat());
|
||||
command.setTransactionDate(transactionDate);
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDate(),
|
||||
"transactionDate", command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
BigDecimal transactionAmount = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmountFormatted(),
|
||||
"transactionAmountFormatted", Locale.UK);
|
||||
command.setTransactionAmount(transactionAmount);
|
||||
BigDecimal transactionAmountValue = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmount(),
|
||||
"transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
|
||||
if (StringUtils.isNotBlank(transactionType)
|
||||
&& transactionType.trim().equalsIgnoreCase("waiver")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.waiveLoanAmount(command);
|
||||
return Response.ok().entity(identifier).build();
|
||||
if (is(commandParam, "repayment")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.makeLoanRepayment(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.waiveLoanAmount(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.makeLoanRepayment(command);
|
||||
return Response.ok().entity(identifier).build();
|
||||
return response;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -269,37 +275,43 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewRepaymentDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("type") final String transactionType,
|
||||
@QueryParam("command") final String commandParam,
|
||||
@Context UriInfo uriInfo) {
|
||||
|
||||
String json = "";
|
||||
String selectedFields = loanRepaymentDefaultFieldList;
|
||||
if (StringUtils.isNotBlank(transactionType)
|
||||
&& transactionType.trim().equalsIgnoreCase("waiver")) {
|
||||
if (is(commandParam, "repayment")) {
|
||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveNewLoanRepaymentDetails(loanId);
|
||||
json = this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||
loanRepaymentFilterName, loanRepaymentAllowedFieldList, selectedFields,
|
||||
uriInfo.getQueryParameters());
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
LoanRepaymentData loanWaiverData = this.loanReadPlatformService
|
||||
.retrieveNewLoanWaiverDetails(loanId);
|
||||
return this.jsonFormattingService.convertRequest(loanWaiverData,
|
||||
json = this.jsonFormattingService.convertRequest(loanWaiverData,
|
||||
loanRepaymentFilterName, loanRepaymentAllowedFieldList, selectedFields,
|
||||
uriInfo.getQueryParameters());
|
||||
}
|
||||
|
||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveNewLoanRepaymentDetails(loanId);
|
||||
return this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||
loanRepaymentFilterName, loanRepaymentAllowedFieldList, selectedFields,
|
||||
uriInfo.getQueryParameters());
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/transactions/{repaymentId}")
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public String retrieveRepaymentDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@PathParam("repaymentId") final Long repaymentId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
@Context UriInfo uriInfo) {
|
||||
|
||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveLoanRepaymentDetails(loanId, repaymentId);
|
||||
.retrieveLoanRepaymentDetails(loanId, transactionId);
|
||||
|
||||
String selectedFields = "";
|
||||
return this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||
@@ -308,29 +320,30 @@ public class LoansApiResource {
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{loanId}/transactions/{repaymentId}")
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response adjustLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@PathParam("repaymentId") final Long repaymentId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
final AdjustLoanTransactionCommand command) {
|
||||
|
||||
command.setLoanId(loanId);
|
||||
command.setRepaymentId(repaymentId);
|
||||
command.setTransactionId(transactionId);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService.localeFromString(command.getLocale());
|
||||
|
||||
LocalDate transactionDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDateFormatted(),
|
||||
"transactionDateFormatted", command.getDateFormat());
|
||||
command.setTransactionDate(transactionDate);
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDate(),
|
||||
"transactionDate", command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
BigDecimal transactionAmount = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmountFormatted(),
|
||||
"transactionAmountFormatted", Locale.UK);
|
||||
command.setTransactionAmount(transactionAmount);
|
||||
BigDecimal transactionAmountValue = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmount(),
|
||||
"transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.adjustLoanTransaction(command);
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.adjustLoanTransaction(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
public class AdjustLoanTransactionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private Long transactionId;
|
||||
private String locale;
|
||||
private String dateFormat;
|
||||
private String transactionDate;
|
||||
private LocalDate transactionLocalDate;
|
||||
private String note;
|
||||
private String transactionAmount;
|
||||
private BigDecimal transactionAmountValue;
|
||||
|
||||
protected AdjustLoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public AdjustLoanTransactionCommand(final Long loanId, final Long transactionId,
|
||||
final LocalDate transactionLocalDate, final String note,
|
||||
final BigDecimal transactionAmountValue) {
|
||||
this.loanId = loanId;
|
||||
this.transactionId = transactionId;
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
this.note = note;
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public Long getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public String getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(String transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionLocalDate() {
|
||||
return transactionLocalDate;
|
||||
}
|
||||
|
||||
public void setTransactionLocalDate(LocalDate transactionLocalDate) {
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(String transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmountValue() {
|
||||
return transactionAmountValue;
|
||||
}
|
||||
|
||||
public void setTransactionAmountValue(BigDecimal transactionAmountValue) {
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@XmlRootElement
|
||||
public class ImportLoanCommand {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
+27
-28
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@@ -12,19 +12,18 @@ public class LoanStateTransitionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String dateFormat;
|
||||
private String eventDateFormatted;
|
||||
private LocalDate eventDate;
|
||||
private String comment;
|
||||
private String eventDate;
|
||||
private LocalDate eventLocalDate;
|
||||
private String note;
|
||||
|
||||
protected LoanStateTransitionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanStateTransitionCommand(final Long loanId, final LocalDate eventDate,
|
||||
final String comment) {
|
||||
public LoanStateTransitionCommand(final Long loanId, final LocalDate eventDate, final String comment) {
|
||||
this.loanId = loanId;
|
||||
this.eventDate = eventDate;
|
||||
this.comment = comment;
|
||||
this.eventLocalDate = eventDate;
|
||||
this.note = comment;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
@@ -35,22 +34,6 @@ public class LoanStateTransitionCommand {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(final String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public LocalDate getEventDate() {
|
||||
return eventDate;
|
||||
}
|
||||
|
||||
public void setEventDate(LocalDate eventDate) {
|
||||
this.eventDate = eventDate;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
@@ -59,11 +42,27 @@ public class LoanStateTransitionCommand {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getEventDateFormatted() {
|
||||
return eventDateFormatted;
|
||||
public String getEventDate() {
|
||||
return eventDate;
|
||||
}
|
||||
|
||||
public void setEventDateFormatted(String eventDateFormatted) {
|
||||
this.eventDateFormatted = eventDateFormatted;
|
||||
public void setEventDate(String eventDate) {
|
||||
this.eventDate = eventDate;
|
||||
}
|
||||
|
||||
public LocalDate getEventLocalDate() {
|
||||
return eventLocalDate;
|
||||
}
|
||||
|
||||
public void setEventLocalDate(LocalDate eventLocalDate) {
|
||||
this.eventLocalDate = eventLocalDate;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
public class LoanTransactionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String locale;
|
||||
private String dateFormat;
|
||||
private String transactionDate;
|
||||
private LocalDate transactionLocalDate;
|
||||
private String note;
|
||||
private String transactionAmount;
|
||||
private BigDecimal transactionAmountValue;
|
||||
|
||||
protected LoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanTransactionCommand(final Long loanId,
|
||||
final LocalDate paymentDate, final String note,
|
||||
final BigDecimal paymentAmount) {
|
||||
this.loanId = loanId;
|
||||
this.transactionLocalDate = paymentDate;
|
||||
this.note = note;
|
||||
this.transactionAmountValue = paymentAmount;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(String transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionLocalDate() {
|
||||
return transactionLocalDate;
|
||||
}
|
||||
|
||||
public void setTransactionLocalDate(LocalDate transactionLocalDate) {
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(String transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmountValue() {
|
||||
return transactionAmountValue;
|
||||
}
|
||||
|
||||
public void setTransactionAmountValue(BigDecimal transactionAmountValue) {
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@XmlRootElement
|
||||
public class SubmitApproveDisburseLoanCommand {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.mifosng.data.command;
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
+8
-9
@@ -1,18 +1,17 @@
|
||||
package org.mifosng.data.command;
|
||||
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
public class UndoStateTransitionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String comment;
|
||||
private String note;
|
||||
|
||||
protected UndoStateTransitionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public UndoStateTransitionCommand(final Long loanId, final String comment) {
|
||||
public UndoStateTransitionCommand(final Long loanId, final String note) {
|
||||
this.loanId = loanId;
|
||||
this.comment = comment;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
@@ -23,11 +22,11 @@ public class UndoStateTransitionCommand {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package org.mifosng.platform.client.service;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface ClientWritePlatformService {
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import static org.mifosng.platform.Specifications.officesThatMatch;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.client.domain.Note;
|
||||
|
||||
+9
-9
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class AdjustLoanTransactionCommandValidator {
|
||||
@@ -19,8 +19,8 @@ public class AdjustLoanTransactionCommandValidator {
|
||||
public void validate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
if (command.getRepaymentId() == null || command.getRepaymentId().longValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.id.is.invalid", "The parameter repaymentId is invalid.", "repaymentId", command.getRepaymentId());
|
||||
if (command.getTransactionId() == null || command.getTransactionId().longValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.id.is.invalid", "The parameter repaymentId is invalid.", "transactionId", command.getTransactionId());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
@@ -29,18 +29,18 @@ public class AdjustLoanTransactionCommandValidator {
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.date.cannot.be.blank", "The parameter transactionDateFormatted cannot be blank.", "transactionDateFormatted");
|
||||
if (command.getTransactionLocalDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.date.cannot.be.blank", "The parameter transactionDate cannot be blank.", "transactionDate");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionAmount() == null || command.getTransactionAmount().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmountFormatted less than zero.", "transactionAmountFormatted", command.getTransactionAmountFormatted());
|
||||
if (command.getTransactionAmountValue() == null || command.getTransactionAmountValue().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmount less than zero.", "transactionAmount", command.getTransactionAmountValue());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment()) && command.getComment().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter comment exceeds max allowed size of {0}", "comment", 1000);
|
||||
if (StringUtils.isNotBlank(command.getNote()) && command.getNote().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter note exceeds max allowed size of {0}", "note", 1000);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.DataValidatorBuilder;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class CalculateLoanScheduleCommandValidator {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package org.mifosng.platform.loan.service;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.LoanPayoffReadModel;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
|
||||
public interface CalculationPlatformService {
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.mifosng.data.CurrencyData;
|
||||
import org.mifosng.data.LoanPayoffReadModel;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.MoneyData;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrency;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrencyRepository;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.MoneyData;
|
||||
import org.mifosng.data.ScheduledLoanInstallment;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ public interface LoanReadPlatformService {
|
||||
|
||||
LoanRepaymentData retrieveNewLoanWaiverDetails(Long loanId);
|
||||
|
||||
LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId, Long repaymentId);
|
||||
LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId, Long transactionId);
|
||||
}
|
||||
+1
-5
@@ -36,7 +36,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
// private final SimpleJdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final LoanRepository loanRepository;
|
||||
private final ApplicationCurrencyRepository applicationCurrencyRepository;
|
||||
@@ -46,7 +45,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
@Autowired
|
||||
public LoanReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
// final DataSource dataSource,
|
||||
final LoanRepository loanRepository, final LoanTransactionRepository loanTransactionRepository, final ApplicationCurrencyRepository applicationCurrencyRepository,
|
||||
final LoanProductReadPlatformService loanProductReadPlatformService, final ClientReadPlatformService clientReadPlatformService) {
|
||||
this.context = context;
|
||||
@@ -55,7 +53,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
this.applicationCurrencyRepository = applicationCurrencyRepository;
|
||||
this.loanProductReadPlatformService = loanProductReadPlatformService;
|
||||
this.clientReadPlatformService = clientReadPlatformService;
|
||||
// this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -264,8 +261,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
// TODO - OPTIMIZE - write simple sql query to fetch back date of
|
||||
// possible next transaction date.
|
||||
Loan loan = this.loanRepository.findOne(loansThatMatch(
|
||||
currentUser.getOrganisation(), loanId));
|
||||
Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId));
|
||||
if (loan == null) {
|
||||
throw new LoanNotFoundException(loanId);
|
||||
}
|
||||
|
||||
+6
-15
@@ -3,9 +3,9 @@ package org.mifosng.platform.loan.service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.DataValidatorBuilder;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class LoanStateTransitionCommandValidator {
|
||||
@@ -19,20 +19,11 @@ public class LoanStateTransitionCommandValidator {
|
||||
public void validate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
if (command.getLoanId() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.id.is.invalid", "The parameter loanId is invalid.", "loanId", command.getLoanId());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.transition");
|
||||
|
||||
if (command.getEventDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.state.transition.date.cannot.be.blank", "The parameter eventDate cannot be blank.", "eventDate");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment()) && command.getComment().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter comment exceeds mas allowed length of {0}.", "comment");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
baseDataValidator.reset().parameter("loanId").value(command.getLoanId()).notNull();
|
||||
baseDataValidator.reset().parameter("eventDate").value(command.getEventLocalDate()).notNull();
|
||||
baseDataValidator.reset().parameter("note").value(command.getNote()).notExceedingLengthOf(1000);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
|
||||
+6
-7
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class LoanTransactionCommandValidator {
|
||||
@@ -24,17 +24,17 @@ public class LoanTransactionCommandValidator {
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionDate() == null) {
|
||||
if (command.getTransactionLocalDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.date.cannot.be.blank", "The parameter transactionDateFormatted cannot be blank.", "transactionDateFormatted");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionAmount() == null || command.getTransactionAmount().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmountFormatted less than zero.", "transactionAmountFormatted", command.getTransactionAmountFormatted());
|
||||
if (command.getTransactionAmount() == null || command.getTransactionAmountValue().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmountFormatted less than zero.", "transactionAmountFormatted", command.getTransactionAmountValue());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment()) && command.getComment().length() > 1000) {
|
||||
if (StringUtils.isNotBlank(command.getNote()) && command.getNote().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter comment exceeds max allowed size of {0}", "comment", 1000);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
@@ -43,5 +43,4 @@ public class LoanTransactionCommandValidator {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
package org.mifosng.platform.loan.service;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface LoanWritePlatformService {
|
||||
|
||||
+63
-50
@@ -10,17 +10,18 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.ScheduledLoanInstallment;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.client.domain.Note;
|
||||
import org.mifosng.platform.client.domain.NoteRepository;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosng.platform.exceptions.LoanNotFoundException;
|
||||
import org.mifosng.platform.exceptions.LoanTransactionNotFoundException;
|
||||
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
||||
import org.mifosng.platform.exceptions.PlatformDomainRuleException;
|
||||
import org.mifosng.platform.loan.domain.DefaultLoanLifecycleStateMachine;
|
||||
@@ -138,16 +139,18 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
if (loan == null) {
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotApproveLoanInPast()) {
|
||||
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotApproveLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to approve loan with a date in the past.");
|
||||
}
|
||||
|
||||
loan.approve(command.getEventDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.approve(eventDate, defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -168,8 +171,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
loan.undoApproval(defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -190,15 +194,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotRejectLoanInPast()) {
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotRejectLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to reject loan with a date in the past.");
|
||||
}
|
||||
|
||||
loan.reject(command.getEventDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.reject(eventDate, defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -219,15 +225,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotWithdrawByClientLoanInPast()) {
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotWithdrawByClientLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to mark loan as withdrawn by client with a date in the past.");
|
||||
}
|
||||
|
||||
loan.withdraw(command.getEventDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.withdraw(eventDate, defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -248,15 +256,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotDisburseLoanInPast()) {
|
||||
String noteText = command.getNote();
|
||||
LocalDate actualDisbursementDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(actualDisbursementDate) && currentUser.canNotDisburseLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to disburse loan with a date in the past.");
|
||||
}
|
||||
|
||||
LocalDate disbursedOn = command.getEventDate();
|
||||
String comment = command.getComment();
|
||||
|
||||
LocalDate actualDisbursementDate = new LocalDate(disbursedOn);
|
||||
|
||||
if (loan.isRepaymentScheduleRegenerationRequiredForDisbursement(actualDisbursementDate)) {
|
||||
|
||||
LocalDate repaymentsStartingFromDate = loan.getExpectedFirstRepaymentOnDate();
|
||||
@@ -309,15 +314,15 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
interest.getAmount());
|
||||
modifiedLoanRepaymentSchedule.add(installment);
|
||||
}
|
||||
loan.disburseWithModifiedRepaymentSchedule(disbursedOn, comment, modifiedLoanRepaymentSchedule, defaultLoanLifecycleStateMachine());
|
||||
loan.disburseWithModifiedRepaymentSchedule(actualDisbursementDate, noteText, modifiedLoanRepaymentSchedule, defaultLoanLifecycleStateMachine());
|
||||
} else {
|
||||
loan.disburse(disbursedOn, defaultLoanLifecycleStateMachine());
|
||||
loan.disburse(actualDisbursementDate, defaultLoanLifecycleStateMachine());
|
||||
}
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -343,8 +348,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -365,21 +371,23 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getTransactionDate()) && currentUser.canNotMakeRepaymentOnLoanInPast()) {
|
||||
LocalDate transactionDate = command.getTransactionLocalDate();
|
||||
if (this.isBeforeToday(transactionDate) && currentUser.canNotMakeRepaymentOnLoanInPast()) {
|
||||
throw new NoAuthorizationException("error.msg.no.permission.to.make.repayment.on.loan.in.past");
|
||||
}
|
||||
|
||||
Money repayment = Money.of(loan.getLoanRepaymentScheduleDetail()
|
||||
.getPrincipal().getCurrency(),
|
||||
command.getTransactionAmount());
|
||||
command.getTransactionAmountValue());
|
||||
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repayment, command.getTransactionDate());
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repayment, transactionDate);
|
||||
loan.makeRepayment(loanRepayment, defaultLoanLifecycleStateMachine());
|
||||
this.loanTransactionRepository.save(loanRepayment);
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, loanRepayment, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, loanRepayment, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -400,17 +408,20 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
LoanTransaction transactionToAdjust = this.loanTransactionRepository
|
||||
.findOne(command.getRepaymentId());
|
||||
|
||||
LoanTransaction transactionToAdjust = this.loanTransactionRepository.findOne(command.getTransactionId());
|
||||
if (transactionToAdjust == null) {
|
||||
throw new LoanTransactionNotFoundException(command.getTransactionId());
|
||||
}
|
||||
|
||||
Money transactionAmount = Money.of(loan
|
||||
.getLoanRepaymentScheduleDetail().getPrincipal()
|
||||
.getCurrency(), command.getTransactionAmount());
|
||||
.getCurrency(), command.getTransactionAmountValue());
|
||||
|
||||
// adjustment is only supported for repayments and waivers at present
|
||||
LoanTransaction newTransactionDetail = LoanTransaction.repayment(transactionAmount, command.getTransactionDate());
|
||||
LocalDate transactionDate = command.getTransactionLocalDate();
|
||||
LoanTransaction newTransactionDetail = LoanTransaction.repayment(transactionAmount, transactionDate);
|
||||
if (transactionToAdjust.isWaiver()) {
|
||||
newTransactionDetail = LoanTransaction.waiver(transactionAmount, command.getTransactionDate());
|
||||
newTransactionDetail = LoanTransaction.waiver(transactionAmount, transactionDate);
|
||||
}
|
||||
|
||||
loan.adjustExistingTransaction(transactionToAdjust, newTransactionDetail, defaultLoanLifecycleStateMachine());
|
||||
@@ -419,9 +430,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(),
|
||||
loan, newTransactionDetail, command.getComment());
|
||||
loan, newTransactionDetail, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -444,9 +456,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
Money waived = Money.of(loan.getLoanRepaymentScheduleDetail()
|
||||
.getPrincipal().getCurrency(),
|
||||
command.getTransactionAmount());
|
||||
command.getTransactionAmountValue());
|
||||
|
||||
LoanTransaction waiver = LoanTransaction.waiver(waived, command.getTransactionDate());
|
||||
LoanTransaction waiver = LoanTransaction.waiver(waived, command.getTransactionLocalDate());
|
||||
|
||||
loan.waive(waiver, defaultLoanLifecycleStateMachine());
|
||||
|
||||
@@ -454,8 +466,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, waiver, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, waiver, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class SubmitLoanApplicationCommandValidator {
|
||||
|
||||
@@ -7,10 +7,10 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.ImportPlatformService;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -7,10 +7,10 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.ImportPlatformService;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
Reference in New Issue
Block a user