diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/AdjustLoanTransactionCommand.java b/mifosng-data/src/main/java/org/mifosng/data/command/AdjustLoanTransactionCommand.java deleted file mode 100644 index 71594861d..000000000 --- a/mifosng-data/src/main/java/org/mifosng/data/command/AdjustLoanTransactionCommand.java +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/LoanTransactionCommand.java b/mifosng-data/src/main/java/org/mifosng/data/command/LoanTransactionCommand.java deleted file mode 100644 index 4c0b8f2c7..000000000 --- a/mifosng-data/src/main/java/org/mifosng/data/command/LoanTransactionCommand.java +++ /dev/null @@ -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; - } -} \ No newline at end of file diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp index 74e3466d0..c6a530012 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/client/viewClientAccount.jsp @@ -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; diff --git a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp index 0bbc92bb5..c4d0f90de 100644 --- a/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp +++ b/mifosng-individual-lending-app/src/main/webapp/WEB-INF/views/view-templates.jsp @@ -804,11 +804,11 @@
- - + + - - + + @@ -816,8 +816,8 @@ @@ -826,14 +826,14 @@ - - + + - - + + - - + + diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformService.java index a09dd6b14..b4234ffba 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformService.java @@ -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 { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformServiceImpl.java index 82d60038b..c4eeb0b05 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/ImportPlatformServiceImpl.java @@ -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); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientApiResource.java index 05c9be598..5436ee734 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/ClientApiResource.java @@ -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; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java index a3c47976f..f3618aad7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/LoansApiResource.java @@ -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(); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/AdjustLoanTransactionCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/AdjustLoanTransactionCommand.java new file mode 100644 index 000000000..a7a2916ac --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/AdjustLoanTransactionCommand.java @@ -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; + } +} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/CalculateLoanScheduleCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/CalculateLoanScheduleCommand.java similarity index 99% rename from mifosng-data/src/main/java/org/mifosng/data/command/CalculateLoanScheduleCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/CalculateLoanScheduleCommand.java index 9b4c78f7e..187f8e584 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/CalculateLoanScheduleCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/CalculateLoanScheduleCommand.java @@ -1,4 +1,4 @@ -package org.mifosng.data.command; +package org.mifosng.platform.api.commands; import java.math.BigDecimal; diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/ImportLoanCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ImportLoanCommand.java similarity index 91% rename from mifosng-data/src/main/java/org/mifosng/data/command/ImportLoanCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ImportLoanCommand.java index f6a075272..848aa75a9 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/ImportLoanCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ImportLoanCommand.java @@ -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 { diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/ImportLoanRepaymentsCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ImportLoanRepaymentsCommand.java similarity index 91% rename from mifosng-data/src/main/java/org/mifosng/data/command/ImportLoanRepaymentsCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ImportLoanRepaymentsCommand.java index 6f39b6e31..a202d1b2b 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/ImportLoanRepaymentsCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/ImportLoanRepaymentsCommand.java @@ -1,4 +1,4 @@ -package org.mifosng.data.command; +package org.mifosng.platform.api.commands; import java.util.ArrayList; import java.util.List; diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/LoanStateTransitionCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/LoanStateTransitionCommand.java similarity index 55% rename from mifosng-data/src/main/java/org/mifosng/data/command/LoanStateTransitionCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/LoanStateTransitionCommand.java index 3aa917617..3f8d22bd4 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/LoanStateTransitionCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/LoanStateTransitionCommand.java @@ -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; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/LoanTransactionCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/LoanTransactionCommand.java new file mode 100644 index 000000000..c3d569c07 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/LoanTransactionCommand.java @@ -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; + } +} \ No newline at end of file diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/NoteCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/NoteCommand.java similarity index 95% rename from mifosng-data/src/main/java/org/mifosng/data/command/NoteCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/NoteCommand.java index d4b81f728..0ad551cf5 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/NoteCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/NoteCommand.java @@ -1,4 +1,4 @@ -package org.mifosng.data.command; +package org.mifosng.platform.api.commands; import javax.xml.bind.annotation.XmlRootElement; diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/SubmitApproveDisburseLoanCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/SubmitApproveDisburseLoanCommand.java similarity index 96% rename from mifosng-data/src/main/java/org/mifosng/data/command/SubmitApproveDisburseLoanCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/SubmitApproveDisburseLoanCommand.java index 7f4cad475..5f7c5fc12 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/SubmitApproveDisburseLoanCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/SubmitApproveDisburseLoanCommand.java @@ -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 { diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/SubmitLoanApplicationCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/SubmitLoanApplicationCommand.java similarity index 99% rename from mifosng-data/src/main/java/org/mifosng/data/command/SubmitLoanApplicationCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/SubmitLoanApplicationCommand.java index 64205f24a..6665459ae 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/SubmitLoanApplicationCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/SubmitLoanApplicationCommand.java @@ -1,4 +1,4 @@ -package org.mifosng.data.command; +package org.mifosng.platform.api.commands; import java.math.BigDecimal; diff --git a/mifosng-data/src/main/java/org/mifosng/data/command/UndoStateTransitionCommand.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/UndoStateTransitionCommand.java similarity index 61% rename from mifosng-data/src/main/java/org/mifosng/data/command/UndoStateTransitionCommand.java rename to mifosng-provider/src/main/java/org/mifosng/platform/api/commands/UndoStateTransitionCommand.java index 7e97a2c30..dec3703b1 100644 --- a/mifosng-data/src/main/java/org/mifosng/data/command/UndoStateTransitionCommand.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/UndoStateTransitionCommand.java @@ -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; } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java index 832df6489..76a527a4a 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformService.java @@ -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 { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java index fc82c2d25..25909f335 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java @@ -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; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java index 50e06ae5e..576201613 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/AdjustLoanTransactionCommandValidator.java @@ -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