MIFOSX-1870 : Added Currency Type

This commit is contained in:
Satish Sajjan
2014-12-31 19:24:29 +05:30
parent d310eb308d
commit 70331f8447
7 changed files with 510 additions and 415 deletions
+87 -1
View File
@@ -1972,7 +1972,7 @@
<td></td> <td></td>
<td><a href="#roles_retrieve">Retrieve a Role</a></td> <td><a href="#roles_retrieve">Retrieve a Role</a></td>
<td><a href="#roles_update">Update a Role</a></td> <td><a href="#roles_update">Update a Role</a></td>
<td></td> <td><a href="#roles_delete">Delete Role</a></td>
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
@@ -1984,6 +1984,22 @@
Permissions</a></td> Permissions</a></td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td></td>
<td>roles/{roleId}?command=enable</td>
<td><a href="#roles_enable">Enable Role</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>roles/{roleId}?command=disable</td>
<td><a href="#roles_disable">Disable Role</a></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr> <tr>
<td><a href="#permissions">Permission</a></td> <td><a href="#permissions">Permission</a></td>
<td>permissions</td> <td>permissions</td>
@@ -30184,6 +30200,30 @@ GET https://DomainName/api/v1/roles
</div> </div>
</div> </div>
<a id="roles_delete" name="roles_delete" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Delete a Role</h4>
<p>Description : Delete the role in case role is not associated with any users.</p>
</div>
<div class="method-example">
<code class="method-declaration">
DELETE https://DomainName/api/v1/roles/{roleId}
</code>
<code class="method-request">
DELETE roles/20
Content-Type: application/json
No Request Body
</code>
<code class="method-response">
{
"resourceId":1
}
</code>
</div>
</div>
<a id="roles_retrieve" name="roles_retrieve" class="old-syle-anchor">&nbsp;</a> <a id="roles_retrieve" name="roles_retrieve" class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
<div class="method-description"> <div class="method-description">
@@ -30305,6 +30345,52 @@ GET https://DomainName/api/v1/roles/{roleId}/permissions
</div> </div>
</div> </div>
<a id="roles_enable" name="roles_enable" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Enable Role</h4>
<p>Description : Enable role in case role is disabled.</p>
</div>
<div class="method-example">
<code class="method-declaration">
POST https://DomainName/api/v1/roles/{roleId}?command=enable
</code>
<code class="method-request">
POST roles/1?command=enable
Content-Type: application/json
No Request Body
</code>
<code class="method-response">
{
"resourceId":1
}
</code>
</div>
</div>
<a id="roles_disable" name="roles_disable" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h4>Disable Role</h4>
<p>Description : Disable the role in case role is not associated with any users.</p>
</div>
<div class="method-example">
<code class="method-declaration">
POST https://DomainName/api/v1/roles/{roleId}?command=disable
</code>
<code class="method-request">
POST roles/1?command=disable
Content-Type: application/json
No Request Body
</code>
<code class="method-response">
{
"resourceId":1
}
</code>
</div>
</div>
<a id="rolespermissions_update" name="rolespermissions_update" <a id="rolespermissions_update" name="rolespermissions_update"
class="old-syle-anchor">&nbsp;</a> class="old-syle-anchor">&nbsp;</a>
<div class="method-section"> <div class="method-section">
@@ -5,6 +5,20 @@
*/ */
package org.mifosplatform.organisation.teller.api; package org.mifosplatform.organisation.teller.api;
import java.util.Collection;
import java.util.Date;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat; import org.joda.time.format.ISODateTimeFormat;
import org.mifosplatform.commands.domain.CommandWrapper; import org.mifosplatform.commands.domain.CommandWrapper;
@@ -19,18 +33,12 @@ import org.mifosplatform.organisation.teller.data.CashierTransactionsWithSummary
import org.mifosplatform.organisation.teller.data.TellerData; import org.mifosplatform.organisation.teller.data.TellerData;
import org.mifosplatform.organisation.teller.data.TellerJournalData; import org.mifosplatform.organisation.teller.data.TellerJournalData;
import org.mifosplatform.organisation.teller.data.TellerTransactionData; import org.mifosplatform.organisation.teller.data.TellerTransactionData;
import org.mifosplatform.organisation.teller.domain.Teller;
import org.mifosplatform.organisation.teller.service.TellerManagementReadPlatformService; import org.mifosplatform.organisation.teller.service.TellerManagementReadPlatformService;
import org.mifosplatform.organisation.teller.util.DateRange; import org.mifosplatform.organisation.teller.util.DateRange;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.Collection;
import java.util.Date;
@Path("tellers") @Path("tellers")
@Component @Component
@Scope("singleton") @Scope("singleton")
@@ -52,7 +60,7 @@ public class TellerApiResource {
} }
@GET @GET
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getTellerData(@QueryParam("officeId") final Long officeId) { public String getTellerData(@QueryParam("officeId") final Long officeId) {
final Collection<TellerData> foundTellers = this.readPlatformService.getTellers(officeId); final Collection<TellerData> foundTellers = this.readPlatformService.getTellers(officeId);
@@ -62,7 +70,7 @@ public class TellerApiResource {
@Path("{tellerId}") @Path("{tellerId}")
@GET @GET
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String findTeller(@PathParam("tellerId") final Long tellerId) { public String findTeller(@PathParam("tellerId") final Long tellerId) {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
@@ -71,7 +79,7 @@ public class TellerApiResource {
} }
@POST @POST
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String createTeller(final String tellerData) { public String createTeller(final String tellerData) {
final CommandWrapper request = new CommandWrapperBuilder().createTeller().withJson(tellerData).build(); final CommandWrapper request = new CommandWrapperBuilder().createTeller().withJson(tellerData).build();
@@ -83,7 +91,7 @@ public class TellerApiResource {
@Path("{tellerId}") @Path("{tellerId}")
@PUT @PUT
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String updateTeller(@PathParam("tellerId") final Long tellerId, final String tellerData) { public String updateTeller(@PathParam("tellerId") final Long tellerId, final String tellerData) {
final CommandWrapper request = new CommandWrapperBuilder().updateTeller(tellerId).withJson(tellerData).build(); final CommandWrapper request = new CommandWrapperBuilder().updateTeller(tellerId).withJson(tellerData).build();
@@ -95,7 +103,7 @@ public class TellerApiResource {
@Path("{tellerId}") @Path("{tellerId}")
@DELETE @DELETE
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String deleteTeller(@PathParam("tellerId") final Long tellerId) { public String deleteTeller(@PathParam("tellerId") final Long tellerId) {
final CommandWrapper request = new CommandWrapperBuilder().deleteTeller(tellerId).build(); final CommandWrapper request = new CommandWrapperBuilder().deleteTeller(tellerId).build();
@@ -107,7 +115,7 @@ public class TellerApiResource {
@GET @GET
@Path("{tellerId}/cashiers") @Path("{tellerId}/cashiers")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getCashierData(@PathParam("tellerId") final Long tellerId, @QueryParam("fromdate") final String fromDateStr, public String getCashierData(@PathParam("tellerId") final Long tellerId, @QueryParam("fromdate") final String fromDateStr,
@QueryParam("todate") final String toDateStr) { @QueryParam("todate") final String toDateStr) {
@@ -131,7 +139,7 @@ public class TellerApiResource {
@GET @GET
@Path("{tellerId}/cashiers/{cashierId}") @Path("{tellerId}/cashiers/{cashierId}")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String findCashierData(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) { public String findCashierData(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) {
final CashierData cashier = this.readPlatformService.findCashier(cashierId); final CashierData cashier = this.readPlatformService.findCashier(cashierId);
@@ -141,22 +149,21 @@ public class TellerApiResource {
@GET @GET
@Path("{tellerId}/cashiers/template") @Path("{tellerId}/cashiers/template")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getCashierTemplate(@PathParam("tellerId") final Long tellerId) { public String getCashierTemplate(@PathParam("tellerId") final Long tellerId) {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
Long officeId = teller.getOfficeId(); Long officeId = teller.getOfficeId();
final CashierData cashier = final CashierData cashier = this.readPlatformService.retrieveCashierTemplate(officeId, tellerId, true);
this.readPlatformService.retrieveCashierTemplate(officeId, tellerId, true);
return this.jsonSerializer.serialize(cashier); return this.jsonSerializer.serialize(cashier);
} }
@POST @POST
@Path("{tellerId}/cashiers") @Path("{tellerId}/cashiers")
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String createCashier(@PathParam("tellerId") final Long tellerId, final String cashierData) { public String createCashier(@PathParam("tellerId") final Long tellerId, final String cashierData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateTeller(tellerId).withJson(cashierData).build(); final CommandWrapper request = new CommandWrapperBuilder().allocateTeller(tellerId).withJson(cashierData).build();
@@ -168,10 +175,12 @@ public class TellerApiResource {
@PUT @PUT
@Path("{tellerId}/cashiers/{cashierId}") @Path("{tellerId}/cashiers/{cashierId}")
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String updateCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId, final String cashierDate) { public String updateCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final CommandWrapper request = new CommandWrapperBuilder().updateAllocationTeller(tellerId, cashierId).withJson(cashierDate).build(); final String cashierDate) {
final CommandWrapper request = new CommandWrapperBuilder().updateAllocationTeller(tellerId, cashierId).withJson(cashierDate)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request); final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
@@ -180,7 +189,7 @@ public class TellerApiResource {
@DELETE @DELETE
@Path("{tellerId}/cashiers/{cashierId}") @Path("{tellerId}/cashiers/{cashierId}")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String deleteCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) { public String deleteCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) {
final CommandWrapper request = new CommandWrapperBuilder().deleteAllocationTeller(tellerId, cashierId).build(); final CommandWrapper request = new CommandWrapperBuilder().deleteAllocationTeller(tellerId, cashierId).build();
@@ -192,10 +201,12 @@ public class TellerApiResource {
@POST @POST
@Path("{tellerId}/cashiers/{cashierId}/allocate") @Path("{tellerId}/cashiers/{cashierId}/allocate")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String allocateCashToCashier (@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId, final String cashierTxnData) { public String allocateCashToCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final CommandWrapper request = new CommandWrapperBuilder().allocateCashToCashier(tellerId, cashierId).withJson(cashierTxnData).build(); final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateCashToCashier(tellerId, cashierId).withJson(cashierTxnData)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request); final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
@@ -205,10 +216,12 @@ public class TellerApiResource {
@POST @POST
@Path("{tellerId}/cashiers/{cashierId}/settle") @Path("{tellerId}/cashiers/{cashierId}/settle")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String settleCashFromCashier (@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId, final String cashierTxnData) { public String settleCashFromCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final CommandWrapper request = new CommandWrapperBuilder().settleCashFromCashier(tellerId, cashierId).withJson(cashierTxnData).build(); final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().settleCashFromCashier(tellerId, cashierId).withJson(cashierTxnData)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request); final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
@@ -218,10 +231,9 @@ public class TellerApiResource {
@GET @GET
@Path("{tellerId}/cashiers/{cashierId}/transactions") @Path("{tellerId}/cashiers/{cashierId}/transactions")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getTransactionsForCashier (@PathParam("tellerId") final Long tellerId, public String getTransactionsForCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
@PathParam("cashierId") final Long cashierId,
final String fromDateStr, final String toDateStr) { final String fromDateStr, final String toDateStr) {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
final CashierData cashier = this.readPlatformService.findCashier(cashierId); final CashierData cashier = this.readPlatformService.findCashier(cashierId);
@@ -229,68 +241,59 @@ public class TellerApiResource {
final Date fromDate = null; final Date fromDate = null;
final Date toDate = null; final Date toDate = null;
final Collection<CashierTransactionData> cashierTxns = final Collection<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, true,
this.readPlatformService.retrieveCashierTransactions(cashierId, fromDate, toDate);
true, fromDate, toDate);
return this.jsonSerializer.serialize(cashierTxns); return this.jsonSerializer.serialize(cashierTxns);
} }
@GET @GET
@Path("{tellerId}/cashiers/{cashierId}/summaryandtransactions") @Path("{tellerId}/cashiers/{cashierId}/summaryandtransactions")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getTransactionsWtihSummaryForCashier (@PathParam("tellerId") final Long tellerId, public String getTransactionsWtihSummaryForCashier(@PathParam("tellerId") final Long tellerId,
@PathParam("cashierId") final Long cashierId, @PathParam("cashierId") final Long cashierId, final String fromDateStr, final String toDateStr) {
final String fromDateStr, final String toDateStr) {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
final CashierData cashier = this.readPlatformService.findCashier(cashierId); final CashierData cashier = this.readPlatformService.findCashier(cashierId);
final Date fromDate = null; final Date fromDate = null;
final Date toDate = null; final Date toDate = null;
final CashierTransactionsWithSummaryData cashierTxnWithSummary = final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.readPlatformService.retrieveCashierTransactionsWithSummary(
this.readPlatformService.retrieveCashierTransactionsWithSummary cashierId, true, fromDate, toDate);
(cashierId,
true, fromDate, toDate);
return this.jsonSerializer.serialize(cashierTxnWithSummary); return this.jsonSerializer.serialize(cashierTxnWithSummary);
} }
@GET @GET
@Path("{tellerId}/cashiers/{cashierId}/transactions/template") @Path("{tellerId}/cashiers/{cashierId}/transactions/template")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getCashierTxnTemplate(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) { public String getCashierTxnTemplate(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) {
final CashierTransactionData cashierTxnTemplate = final CashierTransactionData cashierTxnTemplate = this.readPlatformService.retrieveCashierTxnTemplate(cashierId);
this.readPlatformService.retrieveCashierTxnTemplate(cashierId);
return this.jsonSerializer.serialize(cashierTxnTemplate); return this.jsonSerializer.serialize(cashierTxnTemplate);
} }
@GET @GET
@Path("{tellerId}/transactions") @Path("{tellerId}/transactions")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getTransactionData(@PathParam("tellerId") final Long tellerId, public String getTransactionData(@PathParam("tellerId") final Long tellerId, @QueryParam("dateRange") final String dateRange) {
@QueryParam("dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange); final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerTransactionData> transactions = final Collection<TellerTransactionData> transactions = this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId,
this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId, dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate()); dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(transactions); return this.jsonSerializer.serialize(transactions);
} }
@GET @GET
@Path("{tellerId}/transactions/{transactionId}") @Path("{tellerId}/transactions/{transactionId}")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String findTransactionData(@PathParam("tellerId") final Long tellerid, public String findTransactionData(@PathParam("tellerId") final Long tellerid, @PathParam("transactionId") final Long transactionId) {
@PathParam("transactionId") final Long transactionId) {
final TellerTransactionData transaction = this.readPlatformService.findTellerTransaction(transactionId); final TellerTransactionData transaction = this.readPlatformService.findTellerTransaction(transactionId);
return this.jsonSerializer.serialize(transaction); return this.jsonSerializer.serialize(transaction);
@@ -298,20 +301,20 @@ public class TellerApiResource {
@GET @GET
@Path("{tellerId}/journals") @Path("{tellerId}/journals")
@Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public String getJournalData(@PathParam("tellerId") final Long tellerId, public String getJournalData(@PathParam("tellerId") final Long tellerId, @QueryParam("cashierId") final Long cashierDate,
@QueryParam("cashierId") final Long cashierDate,
@QueryParam("dateRange") final String dateRange) { @QueryParam("dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange); final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerJournalData> journals = final Collection<TellerJournalData> journals = this.readPlatformService.fetchTellerJournals(tellerId, cashierDate,
this.readPlatformService.fetchTellerJournals(tellerId, cashierDate, dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate()); dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(journals); return this.jsonSerializer.serialize(journals);
} }
private class CashiersForTeller { private class CashiersForTeller {
public Long tellerId; public Long tellerId;
public String tellerName; public String tellerName;
public Long officeId; public Long officeId;
@@ -10,13 +10,8 @@ import java.math.BigDecimal;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import org.joda.time.LocalDate; import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
import org.mifosplatform.organisation.office.data.OfficeData;
import org.mifosplatform.organisation.staff.data.StaffData;
import org.mifosplatform.organisation.teller.domain.CashierTxnType; import org.mifosplatform.organisation.teller.domain.CashierTxnType;
import org.mifosplatform.portfolio.client.data.ClientData;
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
public final class CashierTransactionData implements Serializable { public final class CashierTransactionData implements Serializable {
@@ -41,6 +36,8 @@ public final class CashierTransactionData implements Serializable {
private final Date startDate; private final Date startDate;
private final Date endDate; private final Date endDate;
private final Collection<CurrencyData> currencyOptions;
/* /*
* Creates a new cashier. * Creates a new cashier.
*/ */
@@ -48,7 +45,7 @@ public final class CashierTransactionData implements Serializable {
final BigDecimal txnAmount, final Date txnDate, String txnNote, final BigDecimal txnAmount, final Date txnDate, String txnNote,
String entityType, Long entityId, Date createdDate, String entityType, Long entityId, Date createdDate,
Long officeId, String officeName, Long tellerId, String tellerName, String cashierName, Long officeId, String officeName, Long tellerId, String tellerName, String cashierName,
CashierData cashierData, Date startDate, Date endDate ) { CashierData cashierData, Date startDate, Date endDate, final Collection<CurrencyData> currencyOptions) {
this.id = id; this.id = id;
this.cashierId = cashierId; this.cashierId = cashierId;
this.txnType = txnType; this.txnType = txnType;
@@ -68,6 +65,8 @@ public final class CashierTransactionData implements Serializable {
this.startDate = startDate; this.startDate = startDate;
this.endDate = endDate; this.endDate = endDate;
this.currencyOptions = currencyOptions;
} }
public static CashierTransactionData instance(final Long id, final Long cashierId, CashierTxnType txnType, public static CashierTransactionData instance(final Long id, final Long cashierId, CashierTxnType txnType,
@@ -78,16 +77,16 @@ public final class CashierTransactionData implements Serializable {
Date startDate, Date endDate) { Date startDate, Date endDate) {
return new CashierTransactionData(id, cashierId, txnType, txnAmount, txnDate, txnNote, entityType, return new CashierTransactionData(id, cashierId, txnType, txnAmount, txnDate, txnNote, entityType,
entityId, createdDate, officeId, officeName, tellerId, entityId, createdDate, officeId, officeName, tellerId,
tellerName, cashierName, cashierData, startDate, endDate); tellerName, cashierName, cashierData, startDate, endDate, null);
} }
public static CashierTransactionData template (final Long cashierId, public static CashierTransactionData template (final Long cashierId,
final Long tellerId, final String tellerName, final Long tellerId, final String tellerName,
final Long officeId, final String officeName, final String cashierName, final Long officeId, final String officeName, final String cashierName,
final CashierData cashierData, Date startDate, Date endDate) { final CashierData cashierData, Date startDate, Date endDate, final Collection<CurrencyData> currencyOptions) {
return new CashierTransactionData(null, cashierId, null, null, null, null, null, return new CashierTransactionData(null, cashierId, null, null, null, null, null,
null, null, officeId, officeName, tellerId, tellerName, cashierName, cashierData, null, null, officeId, officeName, tellerId, tellerName, cashierName, cashierData,
startDate, endDate); startDate, endDate, currencyOptions);
} }
public Long getId() { public Long getId() {
@@ -55,6 +55,9 @@ public class CashierTransaction extends AbstractPersistable<Long> {
@Column(name = "created_date", nullable = false) @Column(name = "created_date", nullable = false)
private Date createdDate; private Date createdDate;
@Column(name = "currency_code", nullable = true)
private String currencyCode;
/** /**
* Creates a new cashier. * Creates a new cashier.
*/ */
@@ -71,15 +74,16 @@ public class CashierTransaction extends AbstractPersistable<Long> {
final String entityType = command.stringValueOfParameterNamed("entityType"); final String entityType = command.stringValueOfParameterNamed("entityType");
final String txnNote = command.stringValueOfParameterNamed("txnNote"); final String txnNote = command.stringValueOfParameterNamed("txnNote");
final Long entityId = command.longValueOfParameterNamed("entityId"); final Long entityId = command.longValueOfParameterNamed("entityId");
final String currencyCode = command.stringValueOfParameterNamed("currencyCode");
// TODO: get client/loan/savings details // TODO: get client/loan/savings details
return new CashierTransaction (cashier, txnType, txnAmount, txnDate, return new CashierTransaction (cashier, txnType, txnAmount, txnDate,
entityType, entityId, txnNote); entityType, entityId, txnNote, currencyCode);
} }
public CashierTransaction (Cashier cashier, Integer txnType, BigDecimal txnAmount, public CashierTransaction (Cashier cashier, Integer txnType, BigDecimal txnAmount,
LocalDate txnDate, String entityType, Long entityId, String txnNote) { LocalDate txnDate, String entityType, Long entityId, String txnNote, String currencyCode) {
this.cashier = cashier; this.cashier = cashier;
this.txnType = txnType; this.txnType = txnType;
if (txnDate != null) { if (txnDate != null) {
@@ -90,6 +94,7 @@ public class CashierTransaction extends AbstractPersistable<Long> {
this.entityId = entityId; this.entityId = entityId;
this.txnNote = txnNote; this.txnNote = txnNote;
this.createdDate = new Date(); this.createdDate = new Date();
this.currencyCode = currencyCode;
} }
public Map<String, Object> update(final JsonCommand command) { public Map<String, Object> update(final JsonCommand command) {
@@ -131,6 +136,13 @@ public class CashierTransaction extends AbstractPersistable<Long> {
this.txnNote = newValue; this.txnNote = newValue;
} }
final String currencyCodeParamName = "currencyCode";
if (command.isChangeInStringParameterNamed(currencyCodeParamName, this.currencyCode)) {
final String newValue = command.stringValueOfParameterNamed(currencyCodeParamName);
actualChanges.put(currencyCodeParamName, newValue);
this.currencyCode = newValue;
}
return actualChanges; return actualChanges;
} }
@@ -248,4 +260,12 @@ public class CashierTransaction extends AbstractPersistable<Long> {
this.txnNote = txnNote; this.txnNote = txnNote;
} }
public String getCurrencyCode() {
return this.currencyCode;
}
public void setCurrencyCode(String currencyCode) {
this.currencyCode = currencyCode;
}
} }
@@ -42,7 +42,7 @@ public final class TellerCommandFromApiJsonDeserializer {
"officeId", "name", "description", "startDate", "officeId", "name", "description", "startDate",
"endDate", "status", "dateFormat", "locale", "endDate", "status", "dateFormat", "locale",
"isFullDay", "staffId", "startTime", "endTime", "isFullDay", "staffId", "startTime", "endTime",
"txnAmount","txnDate", "txnNote", "entityType", "entityId")); "txnAmount","txnDate", "txnNote", "entityType", "entityId", "currencyCode"));
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@@ -164,5 +164,8 @@ public final class TellerCommandFromApiJsonDeserializer {
final String txnNote = this.fromApiJsonHelper.extractStringNamed("txnNote", element); final String txnNote = this.fromApiJsonHelper.extractStringNamed("txnNote", element);
baseDataValidator.reset().parameter("txnNote").value(txnNote).notExceedingLengthOf(200); baseDataValidator.reset().parameter("txnNote").value(txnNote).notExceedingLengthOf(200);
final String currencyCode = this.fromApiJsonHelper.extractStringNamed("currencyCode", element);
baseDataValidator.reset().parameter("currencyCode").value(currencyCode).notExceedingLengthOf(3);
} }
} }
@@ -18,6 +18,8 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException; import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService;
import org.mifosplatform.organisation.office.data.OfficeData; import org.mifosplatform.organisation.office.data.OfficeData;
import org.mifosplatform.organisation.office.service.OfficeReadPlatformService; import org.mifosplatform.organisation.office.service.OfficeReadPlatformService;
import org.mifosplatform.organisation.staff.data.StaffData; import org.mifosplatform.organisation.staff.data.StaffData;
@@ -50,17 +52,17 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
private final TellerInOfficeHierarchyMapper tellerInOfficeHierarchyMapper = new TellerInOfficeHierarchyMapper(); private final TellerInOfficeHierarchyMapper tellerInOfficeHierarchyMapper = new TellerInOfficeHierarchyMapper();
private final OfficeReadPlatformService officeReadPlatformService; private final OfficeReadPlatformService officeReadPlatformService;
private final StaffReadPlatformService staffReadPlatformService; private final StaffReadPlatformService staffReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService;
@Autowired @Autowired
public TellerManagementReadPlatformServiceImpl(final PlatformSecurityContext context, public TellerManagementReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
final RoutingDataSource dataSource, final OfficeReadPlatformService officeReadPlatformService, StaffReadPlatformService staffReadPlatformService,
final OfficeReadPlatformService officeReadPlatformService, final CurrencyReadPlatformService currencyReadPlatformService) {
StaffReadPlatformService staffReadPlatformService
) {
this.context = context; this.context = context;
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
this.officeReadPlatformService = officeReadPlatformService; this.officeReadPlatformService = officeReadPlatformService;
this.staffReadPlatformService = staffReadPlatformService; this.staffReadPlatformService = staffReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService;
} }
private static final class TellerMapper implements RowMapper<TellerData> { private static final class TellerMapper implements RowMapper<TellerData> {
@@ -97,8 +99,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date"); final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date");
final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date"); final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date");
return TellerData.instance(id, officeId, debitAccountId, creditAccountId, return TellerData.instance(id, officeId, debitAccountId, creditAccountId, tellerName, description, startDate, endDate,
tellerName, description, startDate, endDate, tellerStatus, officeName, null, null); tellerStatus, officeName, null, null);
} }
} }
@@ -139,8 +141,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date"); final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date");
final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date"); final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date");
return TellerData.instance(id, officeId, debitAccountId, creditAccountId, return TellerData.instance(id, officeId, debitAccountId, creditAccountId, tellerName, description, startDate, endDate,
tellerName, description, startDate, endDate, tellerStatus, officeName, null, null); tellerStatus, officeName, null, null);
} }
} }
@@ -249,19 +251,18 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
@Override @Override
public Collection<TellerData> getTellers(Long officeId) { public Collection<TellerData> getTellers(Long officeId) {
return retrieveAllTellers (false); return retrieveAllTellers(false);
} }
@Override @Override
public Collection<CashierData> getCashiersForTeller(Long tellerId, public Collection<CashierData> getCashiersForTeller(Long tellerId, Date fromDate, Date toDate) {
Date fromDate, Date toDate) { return retrieveCashiersForTellers(null, tellerId);
return retrieveCashiersForTellers (null, tellerId);
} }
@Override @Override
public Collection<CashierData> retrieveCashiersForTellers(final String sqlSearch, final Long tellerId) { public Collection<CashierData> retrieveCashiersForTellers(final String sqlSearch, final Long tellerId) {
final String extraCriteria = getTellerCriteria(sqlSearch, tellerId); final String extraCriteria = getTellerCriteria(sqlSearch, tellerId);
return fetchCashiers (extraCriteria); return fetchCashiers(extraCriteria);
} }
private String getTellerCriteria(final String sqlSearch, final Long tellerId) { private String getTellerCriteria(final String sqlSearch, final Long tellerId) {
@@ -283,7 +284,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return extraCriteria.toString(); return extraCriteria.toString();
} }
private Collection<CashierData> fetchCashiers (final String extraCriteria) { private Collection<CashierData> fetchCashiers(final String extraCriteria) {
final CashierMapper cm = new CashierMapper(); final CashierMapper cm = new CashierMapper();
String sql = "select " + cm.schema(); String sql = "select " + cm.schema();
@@ -294,7 +295,6 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.query(sql, cm, new Object[] {}); return this.jdbcTemplate.query(sql, cm, new Object[] {});
} }
@Override @Override
public CashierData findCashier(Long cashierId) { public CashierData findCashier(Long cashierId) {
try { try {
@@ -308,8 +308,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} }
@Override @Override
public Collection<CashierData> getCashierData(Long officeId, Long tellerId, public Collection<CashierData> getCashierData(Long officeId, Long tellerId, Long staffId, Date date) {
Long staffId, Date date) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@@ -327,27 +326,23 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} }
@Override @Override
public Collection<TellerTransactionData> fetchTellerTransactionsByTellerId( public Collection<TellerTransactionData> fetchTellerTransactionsByTellerId(Long tellerId, Date fromDate, Date toDate) {
Long tellerId, Date fromDate, Date toDate) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public Collection<TellerJournalData> getJournals(Long officeId, public Collection<TellerJournalData> getJournals(Long officeId, Long tellerId, Long cashierId, Date dateFrom, Date dateTo) {
Long tellerId, Long cashierId, Date dateFrom, Date dateTo) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public Collection<TellerJournalData> fetchTellerJournals(Long tellerId, public Collection<TellerJournalData> fetchTellerJournals(Long tellerId, Long cashierId, Date fromDate, Date toDate) {
Long cashierId, Date fromDate, Date toDate) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Cacheable(value = "tellers", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')") @Cacheable(value = "tellers", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#root.target.context.authenticatedUser().getOffice().getHierarchy()+'of')")
public Collection<TellerData> retrieveAllTellers(final boolean includeAllTellers) { public Collection<TellerData> retrieveAllTellers(final boolean includeAllTellers) {
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
@@ -365,8 +360,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} }
@Override @Override
public CashierData retrieveCashierTemplate(Long officeId, Long tellerId, public CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly) {
boolean staffInSelectedOfficeOnly) {
final Long defaultOfficeId = defaultToUsersOfficeIfNull(officeId); final Long defaultOfficeId = defaultToUsersOfficeIfNull(officeId);
final OfficeData officeData = this.officeReadPlatformService.retrieveOffice(defaultOfficeId); final OfficeData officeData = this.officeReadPlatformService.retrieveOffice(defaultOfficeId);
@@ -396,8 +390,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
staffOptions = null; staffOptions = null;
} }
return CashierData.template(officeId, officeName, return CashierData.template(officeId, officeName, tellerId, tellerName, staffOptions);
tellerId, tellerName, staffOptions);
} }
@Override @Override
@@ -408,7 +401,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
Long officeId = null; Long officeId = null;
Long tellerId = null; Long tellerId = null;
Date startDate = null; Date startDate = null;
Date endDate = null ; Date endDate = null;
CashierData cashierData = findCashier(cashierId); CashierData cashierData = findCashier(cashierId);
if (cashierData != null) { if (cashierData != null) {
@@ -424,14 +417,15 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
startDate = cashierData.getStartDate(); startDate = cashierData.getStartDate();
endDate = cashierData.getEndDate(); endDate = cashierData.getEndDate();
} }
//Fetching all currency type from m_organisation_currency table
final Collection<CurrencyData> currencyOptions = this.currencyReadPlatformService.retrieveAllowedCurrencies();
return CashierTransactionData.template(cashierId, tellerId, tellerName, officeId, return CashierTransactionData.template(cashierId, tellerId, tellerName, officeId, officeName, cashierName, cashierData, startDate,
officeName, cashierName, cashierData, startDate, endDate); endDate, currencyOptions);
} }
@Override @Override
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary ( public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(final Long cashierId, final boolean includeAllTellers,
final Long cashierId, final boolean includeAllTellers,
final Date fromDate, final Date toDate) { final Date fromDate, final Date toDate) {
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy(); final String hierarchy = currentUser.getOffice().getHierarchy();
@@ -441,60 +435,46 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} else { } else {
hierarchySearchString = hierarchy + "%"; hierarchySearchString = hierarchy + "%";
} }
final CashierTransactionSummaryMapper ctsm = final CashierTransactionSummaryMapper ctsm = new CashierTransactionSummaryMapper();
new CashierTransactionSummaryMapper();
final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000"; final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000";
Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, new Object[] { cashierId,
this.jdbcTemplate.query(sql, ctsm, new Object[] { hierarchySearchString, cashierId, hierarchySearchString, cashierId, hierarchySearchString });
cashierId, hierarchySearchString,
cashierId, hierarchySearchString,
cashierId, hierarchySearchString });
Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator(); Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator();
BigDecimal allocAmount = new BigDecimal (0); BigDecimal allocAmount = new BigDecimal(0);
BigDecimal cashInAmount = new BigDecimal (0); BigDecimal cashInAmount = new BigDecimal(0);
BigDecimal cashOutAmount = new BigDecimal (0); BigDecimal cashOutAmount = new BigDecimal(0);
BigDecimal settleAmount = new BigDecimal (0); BigDecimal settleAmount = new BigDecimal(0);
while(itr.hasNext()) { while (itr.hasNext()) {
CashierTransactionTypeTotalsData total = itr.next(); CashierTransactionTypeTotalsData total = itr.next();
if (total != null) { if (total != null) {
if ( total.getCashierTxnType() == CashierTxnType.ALLOCATE.getId() ) { if (total.getCashierTxnType() == CashierTxnType.ALLOCATE.getId()) {
allocAmount = total.getCashTotal(); allocAmount = total.getCashTotal();
} else if ( total.getCashierTxnType() == CashierTxnType.SETTLE.getId() ) { } else if (total.getCashierTxnType() == CashierTxnType.SETTLE.getId()) {
settleAmount = total.getCashTotal(); settleAmount = total.getCashTotal();
} else if ( total.getCashierTxnType() == CashierTxnType.INWARD_CASH_TXN.getId() ) { } else if (total.getCashierTxnType() == CashierTxnType.INWARD_CASH_TXN.getId()) {
cashInAmount = total.getCashTotal(); cashInAmount = total.getCashTotal();
} else if ( total.getCashierTxnType() == CashierTxnType.OUTWARD_CASH_TXN.getId() ) { } else if (total.getCashierTxnType() == CashierTxnType.OUTWARD_CASH_TXN.getId()) {
cashOutAmount = total.getCashTotal(); cashOutAmount = total.getCashTotal();
} }
} }
} }
final Collection<CashierTransactionData> cashierTransactions = final Collection<CashierTransactionData> cashierTransactions = retrieveCashierTransactions(cashierId, includeAllTellers, fromDate,
retrieveCashierTransactions (cashierId, includeAllTellers, toDate);
fromDate, toDate);
CashierTransactionData cashierTxnTemplate = retrieveCashierTxnTemplate (cashierId); CashierTransactionData cashierTxnTemplate = retrieveCashierTxnTemplate(cashierId);
CashierTransactionsWithSummaryData txnsWithSummary = CashierTransactionsWithSummaryData txnsWithSummary = CashierTransactionsWithSummaryData.instance(cashierTransactions, allocAmount,
CashierTransactionsWithSummaryData.instance( cashInAmount, cashOutAmount, settleAmount, cashierTxnTemplate.getOfficeName(), cashierTxnTemplate.getTellerId(),
cashierTransactions, cashierTxnTemplate.getTellerName(), cashierTxnTemplate.getCashierId(), cashierTxnTemplate.getCashierName());
allocAmount,
cashInAmount,
cashOutAmount,
settleAmount,
cashierTxnTemplate.getOfficeName(),
cashierTxnTemplate.getTellerId(), cashierTxnTemplate.getTellerName(),
cashierTxnTemplate.getCashierId(), cashierTxnTemplate.getCashierName()
);
return txnsWithSummary; return txnsWithSummary;
} }
@Override @Override
public Collection<CashierTransactionData> retrieveCashierTransactions ( public Collection<CashierTransactionData> retrieveCashierTransactions(final Long cashierId, final boolean includeAllTellers,
final Long cashierId, final boolean includeAllTellers,
final Date fromDate, final Date toDate) { final Date fromDate, final Date toDate) {
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy(); final String hierarchy = currentUser.getOffice().getHierarchy();
@@ -507,25 +487,18 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final CashierTransactionMapper ctm = new CashierTransactionMapper(); final CashierTransactionMapper ctm = new CashierTransactionMapper();
final String sql = "select * from (select " + final String sql = "select * from (select " + ctm.cashierTxnSchema()
ctm.cashierTxnSchema() + + " where txn.cashier_id = ? and o.hierarchy like ? ) cashier_txns " + " union (select " + ctm.savingsTxnSchema()
" where txn.cashier_id = ? and o.hierarchy like ? ) cashier_txns " + + " where sav_txn.is_reversed = 0 and c.id = ? and o.hierarchy like ? and "
" union (select " + + " created_date between c.start_date and date_add(c.end_date, interval 1 day) "
ctm.savingsTxnSchema() + + " and renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge', 'withdrawal') ) " + " union (select "
" where sav_txn.is_reversed = 0 and c.id = ? and o.hierarchy like ? and " + + ctm.loansTxnSchema() + " where loan_txn.is_reversed = 0 and c.id = ? and o.hierarchy like ? and "
" created_date between c.start_date and date_add(c.end_date, interval 1 day) " + + " created_date between c.start_date and date_add(c.end_date, interval 1 day) "
" and renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge', 'withdrawal') ) " + + " and renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment','Disbursement') ) "
" union (select " + + " order by created_date ";
ctm.loansTxnSchema() +
" where loan_txn.is_reversed = 0 and c.id = ? and o.hierarchy like ? and " +
" created_date between c.start_date and date_add(c.end_date, interval 1 day) " +
" and renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment','Disbursement') ) " +
" order by created_date ";
return this.jdbcTemplate.query(sql, ctm, return this.jdbcTemplate.query(sql, ctm, new Object[] { cashierId, hierarchySearchString, cashierId, hierarchySearchString,
new Object[] { cashierId, hierarchySearchString, cashierId, hierarchySearchString });
cashierId, hierarchySearchString,
cashierId, hierarchySearchString});
} }
private static final class CashierMapper implements RowMapper<CashierData> { private static final class CashierMapper implements RowMapper<CashierData> {
@@ -557,7 +530,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date"); final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date");
final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date"); final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date");
final Integer fullDayFromDB = rs.getInt ("full_day"); final Integer fullDayFromDB = rs.getInt("full_day");
Boolean fullDay = false; Boolean fullDay = false;
if (fullDayFromDB == 1) { if (fullDayFromDB == 1) {
fullDay = true; fullDay = true;
@@ -565,9 +538,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final String startTime = rs.getString("start_time"); final String startTime = rs.getString("start_time");
final String endTime = rs.getString("end_time"); final String endTime = rs.getString("end_time");
return CashierData.instance(id, null, null, return CashierData.instance(id, null, null, staffId, staffName, tellerId, tellerName, description, startDate.toDate(),
staffId, staffName, tellerId, tellerName, endDate.toDate(), fullDay, startTime, endTime);
description, startDate.toDate(), endDate.toDate(), fullDay, startTime, endTime);
} }
} }
@@ -581,7 +553,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" txn.txn_type as txn_type, "); sqlBuilder.append(" txn.txn_type as txn_type, ");
sqlBuilder.append(" txn.txn_amount as txn_amount, txn.txn_date as txn_date, txn.txn_note as txn_note, "); sqlBuilder.append(" txn.txn_amount as txn_amount, txn.txn_date as txn_date, txn.txn_note as txn_note, ");
sqlBuilder.append(" txn.entity_type as entity_type, txn.entity_id as entity_id, txn.created_date as created_date, "); sqlBuilder.append(" txn.entity_type as entity_type, txn.entity_id as entity_id, txn.created_date as created_date, ");
sqlBuilder.append(" o.id as office_id, o.name as office_name, t.id as teller_id, t.name as teller_name, s.display_name as cashier_name "); sqlBuilder
.append(" o.id as office_id, o.name as office_name, t.id as teller_id, t.name as teller_name, s.display_name as cashier_name ");
sqlBuilder.append(" from m_cashier_transactions txn "); sqlBuilder.append(" from m_cashier_transactions txn ");
sqlBuilder.append(" left join m_cashiers c on c.id = txn.cashier_id "); sqlBuilder.append(" left join m_cashiers c on c.id = txn.cashier_id ");
sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id "); sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id ");
@@ -605,11 +578,14 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" 105 "); sqlBuilder.append(" 105 ");
sqlBuilder.append(" end as txn_type, "); sqlBuilder.append(" end as txn_type, ");
sqlBuilder.append(" sav_txn.amount as txn_amount, sav_txn.transaction_date as txn_date, "); sqlBuilder.append(" sav_txn.amount as txn_amount, sav_txn.transaction_date as txn_date, ");
sqlBuilder.append(" concat (renum.enum_value, ', Sav:', sav.id, '-', sav.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, "); sqlBuilder
.append(" concat (renum.enum_value, ', Sav:', sav.id, '-', sav.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
sqlBuilder.append(" 'savings' as entity_type, sav.id as entity_id, sav_txn.created_date as created_date, "); sqlBuilder.append(" 'savings' as entity_type, sav.id as entity_id, sav_txn.created_date as created_date, ");
sqlBuilder.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name "); sqlBuilder
.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name ");
sqlBuilder.append(" from m_savings_account_transaction sav_txn "); sqlBuilder.append(" from m_savings_account_transaction sav_txn ");
sqlBuilder.append(" left join r_enum_value renum on sav_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'savings_transaction_type_enum' "); sqlBuilder
.append(" left join r_enum_value renum on sav_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'savings_transaction_type_enum' ");
sqlBuilder.append(" left join m_savings_account sav on sav_txn.savings_account_id = sav.id "); sqlBuilder.append(" left join m_savings_account sav on sav_txn.savings_account_id = sav.id ");
sqlBuilder.append(" left join m_client cl on sav.client_id = cl.id "); sqlBuilder.append(" left join m_client cl on sav.client_id = cl.id ");
sqlBuilder.append(" left join m_office o on cl.office_id = o.id "); sqlBuilder.append(" left join m_office o on cl.office_id = o.id ");
@@ -634,11 +610,14 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" 105 "); sqlBuilder.append(" 105 ");
sqlBuilder.append(" end as cash_txn_type, "); sqlBuilder.append(" end as cash_txn_type, ");
sqlBuilder.append(" loan_txn.amount as txn_amount, loan_txn.transaction_date as txn_date, "); sqlBuilder.append(" loan_txn.amount as txn_amount, loan_txn.transaction_date as txn_date, ");
sqlBuilder.append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, "); sqlBuilder
.append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, "); sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, ");
sqlBuilder.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name "); sqlBuilder
.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name ");
sqlBuilder.append(" from m_loan_transaction loan_txn "); sqlBuilder.append(" from m_loan_transaction loan_txn ");
sqlBuilder.append(" left join r_enum_value renum on loan_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'transaction_type_enum' "); sqlBuilder
.append(" left join r_enum_value renum on loan_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'transaction_type_enum' ");
sqlBuilder.append(" left join m_loan loan on loan_txn.loan_id = loan.id "); sqlBuilder.append(" left join m_loan loan on loan_txn.loan_id = loan.id ");
sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id "); sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id ");
sqlBuilder.append(" left join m_office o on cl.office_id = o.id "); sqlBuilder.append(" left join m_office o on cl.office_id = o.id ");
@@ -678,10 +657,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final String tellerName = rs.getString("teller_name"); final String tellerName = rs.getString("teller_name");
final String cashierName = rs.getString("cashier_name"); final String cashierName = rs.getString("cashier_name");
return CashierTransactionData.instance( return CashierTransactionData.instance(id, cashierId, txnType, txnAmount, txnDate, txnNote, entityType, entityId, createdDate,
id, cashierId, txnType, txnAmount, txnDate, txnNote, officeId, officeName, tellerId, tellerName, cashierName, null, null, null);
entityType, entityId, createdDate, officeId, officeName,
tellerId, tellerName, cashierName, null, null, null);
} }
} }
@@ -697,7 +674,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" txn.txn_type as cash_txn_type, "); sqlBuilder.append(" txn.txn_type as cash_txn_type, ");
sqlBuilder.append(" txn.txn_amount as txn_amount, txn.txn_date as txn_date, txn.txn_note as txn_note, "); sqlBuilder.append(" txn.txn_amount as txn_amount, txn.txn_date as txn_date, txn.txn_note as txn_note, ");
sqlBuilder.append(" txn.entity_type as entity_type, txn.entity_id as entity_id, txn.created_date as created_date, "); sqlBuilder.append(" txn.entity_type as entity_type, txn.entity_id as entity_id, txn.created_date as created_date, ");
sqlBuilder.append(" o.id as office_id, o.name as office_name, t.id as teller_id, t.name as teller_name, s.display_name as cashier_name "); sqlBuilder
.append(" o.id as office_id, o.name as office_name, t.id as teller_id, t.name as teller_name, s.display_name as cashier_name ");
sqlBuilder.append(" from m_cashier_transactions txn "); sqlBuilder.append(" from m_cashier_transactions txn ");
sqlBuilder.append(" left join m_cashiers c on c.id = txn.cashier_id "); sqlBuilder.append(" left join m_cashiers c on c.id = txn.cashier_id ");
sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id "); sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id ");
@@ -716,11 +694,14 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" 105 "); sqlBuilder.append(" 105 ");
sqlBuilder.append(" end as cash_txn_type, "); sqlBuilder.append(" end as cash_txn_type, ");
sqlBuilder.append(" sav_txn.amount as txn_amount, sav_txn.transaction_date as txn_date, "); sqlBuilder.append(" sav_txn.amount as txn_amount, sav_txn.transaction_date as txn_date, ");
sqlBuilder.append(" concat (renum.enum_value, ', Sav:', sav.id, '-', sav.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, "); sqlBuilder
.append(" concat (renum.enum_value, ', Sav:', sav.id, '-', sav.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
sqlBuilder.append(" 'savings' as entity_type, sav.id as entity_id, sav_txn.created_date as created_date, "); sqlBuilder.append(" 'savings' as entity_type, sav.id as entity_id, sav_txn.created_date as created_date, ");
sqlBuilder.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name "); sqlBuilder
.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name ");
sqlBuilder.append(" from m_savings_account_transaction sav_txn "); sqlBuilder.append(" from m_savings_account_transaction sav_txn ");
sqlBuilder.append(" left join r_enum_value renum on sav_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'savings_transaction_type_enum' "); sqlBuilder
.append(" left join r_enum_value renum on sav_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'savings_transaction_type_enum' ");
sqlBuilder.append(" left join m_savings_account sav on sav_txn.savings_account_id = sav.id "); sqlBuilder.append(" left join m_savings_account sav on sav_txn.savings_account_id = sav.id ");
sqlBuilder.append(" left join m_client cl on sav.client_id = cl.id "); sqlBuilder.append(" left join m_client cl on sav.client_id = cl.id ");
sqlBuilder.append(" left join m_office o on cl.office_id = o.id "); sqlBuilder.append(" left join m_office o on cl.office_id = o.id ");
@@ -743,11 +724,14 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" 105 "); sqlBuilder.append(" 105 ");
sqlBuilder.append(" end as cash_txn_type, "); sqlBuilder.append(" end as cash_txn_type, ");
sqlBuilder.append(" loan_txn.amount as txn_amount, loan_txn.transaction_date as txn_date, "); sqlBuilder.append(" loan_txn.amount as txn_amount, loan_txn.transaction_date as txn_date, ");
sqlBuilder.append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, "); sqlBuilder
.append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, "); sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, ");
sqlBuilder.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name "); sqlBuilder
.append(" o.id as office_id, o.name as office_name, null as teller_id, null as teller_name, staff.display_name as cashier_name ");
sqlBuilder.append(" from m_loan_transaction loan_txn "); sqlBuilder.append(" from m_loan_transaction loan_txn ");
sqlBuilder.append(" left join r_enum_value renum on loan_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'transaction_type_enum' "); sqlBuilder
.append(" left join r_enum_value renum on loan_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'transaction_type_enum' ");
sqlBuilder.append(" left join m_loan loan on loan_txn.loan_id = loan.id "); sqlBuilder.append(" left join m_loan loan on loan_txn.loan_id = loan.id ");
sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id "); sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id ");
sqlBuilder.append(" left join m_office o on cl.office_id = o.id "); sqlBuilder.append(" left join m_office o on cl.office_id = o.id ");
@@ -765,15 +749,14 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} }
@Override @Override
public CashierTransactionTypeTotalsData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { public CashierTransactionTypeTotalsData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum)
throws SQLException {
final Integer cashierTxnType = rs.getInt("cash_txn_type"); final Integer cashierTxnType = rs.getInt("cash_txn_type");
final BigDecimal txnTotal = rs.getBigDecimal("txn_total"); final BigDecimal txnTotal = rs.getBigDecimal("txn_total");
return CashierTransactionTypeTotalsData.instance( return CashierTransactionTypeTotalsData.instance(cashierTxnType, txnTotal);
cashierTxnType, txnTotal);
} }
} }
} }
@@ -0,0 +1 @@
ALTER TABLE `m_cashier_transactions` ADD COLUMN `currency_code` VARCHAR(3) NULL AFTER `txn_note`;