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>
@@ -30183,6 +30199,30 @@ GET https://DomainName/api/v1/roles
</code> </code>
</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">
@@ -30304,6 +30344,52 @@ GET https://DomainName/api/v1/roles/{roleId}/permissions
</code> </code>
</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>
@@ -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")
@@ -43,7 +51,7 @@ public class TellerApiResource {
@Autowired @Autowired
public TellerApiResource(PlatformSecurityContext securityContext, DefaultToApiJsonSerializer<TellerData> jsonSerializer, public TellerApiResource(PlatformSecurityContext securityContext, DefaultToApiJsonSerializer<TellerData> jsonSerializer,
TellerManagementReadPlatformService readPlatformService, PortfolioCommandSourceWritePlatformService commandWritePlatformService) { TellerManagementReadPlatformService readPlatformService, PortfolioCommandSourceWritePlatformService commandWritePlatformService) {
super(); super();
this.securityContext = securityContext; this.securityContext = securityContext;
this.jsonSerializer = jsonSerializer; this.jsonSerializer = jsonSerializer;
@@ -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,10 +115,10 @@ 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) {
final DateTimeFormatter dateFormatter = ISODateTimeFormat.basicDate(); final DateTimeFormatter dateFormatter = ISODateTimeFormat.basicDate();
final Date fromDate = (fromDateStr != null ? dateFormatter.parseDateTime(fromDateStr).toDate() : new Date()); final Date fromDate = (fromDateStr != null ? dateFormatter.parseDateTime(fromDateStr).toDate() : new Date());
@@ -118,7 +126,7 @@ public class TellerApiResource {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
final Collection<CashierData> cashiers = this.readPlatformService.getCashiersForTeller(tellerId, fromDate, toDate); final Collection<CashierData> cashiers = this.readPlatformService.getCashiersForTeller(tellerId, fromDate, toDate);
CashiersForTeller cashiersForTeller = new CashiersForTeller(); CashiersForTeller cashiersForTeller = new CashiersForTeller();
cashiersForTeller.cashiers = cashiers; cashiersForTeller.cashiers = cashiers;
cashiersForTeller.tellerId = tellerId; cashiersForTeller.tellerId = tellerId;
@@ -131,32 +139,31 @@ 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);
return this.jsonSerializer.serialize(cashier); return this.jsonSerializer.serialize(cashier);
} }
@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();
@@ -189,108 +198,102 @@ public class TellerApiResource {
return this.jsonSerializer.serialize(result); return this.jsonSerializer.serialize(result);
} }
@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);
return this.jsonSerializer.serialize(result); return this.jsonSerializer.serialize(result);
} }
@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);
return this.jsonSerializer.serialize(result); return this.jsonSerializer.serialize(result);
} }
@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);
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,25 +301,25 @@ 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 String tellerName; public Long tellerId;
public Long officeId; public String tellerName;
public String officeName; public Long officeId;
public Collection<CashierData> cashiers; public String officeName;
public Collection<CashierData> cashiers;
} }
} }
@@ -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 {
@@ -40,6 +35,8 @@ public final class CashierTransactionData implements Serializable {
private final CashierData cashierData; private final CashierData cashierData;
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() {
@@ -54,6 +54,9 @@ public class CashierTransaction extends AbstractPersistable<Long> {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@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) {
@@ -130,6 +135,13 @@ public class CashierTransaction extends AbstractPersistable<Long> {
actualChanges.put(txnNoteParamName, newValue); actualChanges.put(txnNoteParamName, newValue);
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;
} }
@@ -247,5 +259,13 @@ public class CashierTransaction extends AbstractPersistable<Long> {
public void setTxnNote (String txnNote) { public void setTxnNote (String txnNote) {
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,24 +52,24 @@ 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> {
public String schema() { public String schema() {
final StringBuilder sqlBuilder = new StringBuilder(400); final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append("t.id as id,t.office_id as office_id, t.name as teller_name, t.description as description, "); sqlBuilder.append("t.id as id,t.office_id as office_id, t.name as teller_name, t.description as description, ");
sqlBuilder.append("t.valid_from as start_date, t.valid_to as end_date, t.state as status, o.name as office_name, "); sqlBuilder.append("t.valid_from as start_date, t.valid_to as end_date, t.state as status, o.name as office_name, ");
@@ -89,16 +91,16 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
TellerStatus tellerStatus = null; TellerStatus tellerStatus = null;
final Integer status = rs.getInt("status"); final Integer status = rs.getInt("status");
if (status != null) { if (status != null) {
tellerStatus = TellerStatus.fromInt(status); tellerStatus = TellerStatus.fromInt(status);
} }
final Long debitAccountId = rs.getLong("debit_account_id"); final Long debitAccountId = rs.getLong("debit_account_id");
final Long creditAccountId = rs.getLong("credit_account_id"); final Long creditAccountId = rs.getLong("credit_account_id");
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);
} }
} }
@@ -131,16 +133,16 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
TellerStatus tellerStatus = null; TellerStatus tellerStatus = null;
final Integer status = rs.getInt("status"); final Integer status = rs.getInt("status");
if (status != null) { if (status != null) {
tellerStatus = TellerStatus.fromInt(status); tellerStatus = TellerStatus.fromInt(status);
} }
final Long debitAccountId = rs.getLong("debit_account_id"); final Long debitAccountId = rs.getLong("debit_account_id");
final Long creditAccountId = rs.getLong("credit_account_id"); final Long creditAccountId = rs.getLong("credit_account_id");
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);
} }
} }
@@ -247,24 +249,23 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return extraCriteria.toString(); return extraCriteria.toString();
} }
@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) {
final StringBuffer extraCriteria = new StringBuffer(200); final StringBuffer extraCriteria = new StringBuffer(200);
@@ -279,11 +280,11 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
if (StringUtils.isNotBlank(extraCriteria.toString())) { if (StringUtils.isNotBlank(extraCriteria.toString())) {
extraCriteria.delete(0, 4); extraCriteria.delete(0, 4);
} }
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,10 +295,9 @@ 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 {
final CashierMapper cm = new CashierMapper(); final CashierMapper cm = new CashierMapper();
final String sql = "select " + cm.schema() + " where c.id = ?"; final String sql = "select " + cm.schema() + " where c.id = ?";
@@ -305,48 +305,43 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
throw new StaffNotFoundException(cashierId); throw new StaffNotFoundException(cashierId);
} }
} }
@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; }
}
@Override @Override
public Collection<CashierData> getTellerCashiers(Long tellerId, Date date) { public Collection<CashierData> getTellerCashiers(Long tellerId, Date date) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public TellerTransactionData findTellerTransaction(Long transactionId) { public TellerTransactionData findTellerTransaction(Long transactionId) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@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) {
@@ -364,22 +359,21 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.query(sql, tm, new Object[] { hierarchySearchString }); return this.jdbcTemplate.query(sql, tm, new Object[] { hierarchySearchString });
} }
@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); String officeName = "";
String officeName = ""; if (officeData != null) {
if (officeData != null) { officeName = officeData.name();
officeName = officeData.name(); }
}
TellerData tellerData = findTeller(tellerId);
TellerData tellerData = findTeller(tellerId); String tellerName = "";
String tellerName = ""; if (tellerData != null) {
if (tellerData != null) { tellerName = tellerData.getName();
tellerName = tellerData.getName(); }
}
final Collection<OfficeData> offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown(); final Collection<OfficeData> offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
@@ -396,43 +390,43 @@ 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
public CashierTransactionData retrieveCashierTxnTemplate(Long cashierId) {
String officeName = "";
String tellerName = "";
String cashierName = "";
Long officeId = null;
Long tellerId = null;
Date startDate = null;
Date endDate = null ;
CashierData cashierData = findCashier(cashierId);
if (cashierData != null) {
cashierName = cashierData.getStaffName();
tellerId = cashierData.getTellerId();
if (tellerId != null) {
TellerData tellerData = findTeller(tellerId);
if (tellerData != null) {
tellerName = tellerData.getName();
officeName = tellerData.getOfficeName();
}
}
startDate = cashierData.getStartDate();
endDate = cashierData.getEndDate();
}
return CashierTransactionData.template(cashierId, tellerId, tellerName, officeId, @Override
officeName, cashierName, cashierData, startDate, endDate); public CashierTransactionData retrieveCashierTxnTemplate(Long cashierId) {
} String officeName = "";
String tellerName = "";
@Override String cashierName = "";
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary ( Long officeId = null;
final Long cashierId, final boolean includeAllTellers, Long tellerId = null;
final Date fromDate, final Date toDate) { Date startDate = null;
Date endDate = null;
CashierData cashierData = findCashier(cashierId);
if (cashierData != null) {
cashierName = cashierData.getStaffName();
tellerId = cashierData.getTellerId();
if (tellerId != null) {
TellerData tellerData = findTeller(tellerId);
if (tellerData != null) {
tellerName = tellerData.getName();
officeName = tellerData.getOfficeName();
}
}
startDate = cashierData.getStartDate();
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, officeName, cashierName, cashierData, startDate,
endDate, currencyOptions);
}
@Override
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(final Long cashierId, final boolean includeAllTellers,
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();
String hierarchySearchString = null; String hierarchySearchString = null;
@@ -441,61 +435,47 @@ 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.instance(cashierTransactions, allocAmount,
CashierTransactionsWithSummaryData txnsWithSummary = cashInAmount, cashOutAmount, settleAmount, cashierTxnTemplate.getOfficeName(), cashierTxnTemplate.getTellerId(),
CashierTransactionsWithSummaryData.instance( cashierTxnTemplate.getTellerName(), cashierTxnTemplate.getCashierId(), cashierTxnTemplate.getCashierName());
cashierTransactions,
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();
String hierarchySearchString = null; String hierarchySearchString = null;
@@ -504,35 +484,28 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} else { } else {
hierarchySearchString = hierarchy + "%"; hierarchySearchString = hierarchy + "%";
} }
final CashierTransactionMapper ctm = new CashierTransactionMapper();
final String sql = "select * from (select " +
ctm.cashierTxnSchema() +
" where txn.cashier_id = ? and o.hierarchy like ? ) cashier_txns " +
" union (select " +
ctm.savingsTxnSchema() +
" where sav_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 ('deposit','withdrawal fee', 'Pay Charge', 'withdrawal') ) " +
" union (select " +
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, final CashierTransactionMapper ctm = new CashierTransactionMapper();
new Object[] { cashierId, hierarchySearchString,
cashierId, hierarchySearchString, final String sql = "select * from (select " + ctm.cashierTxnSchema()
cashierId, hierarchySearchString}); + " where txn.cashier_id = ? and o.hierarchy like ? ) cashier_txns " + " union (select " + ctm.savingsTxnSchema()
+ " where sav_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 ('deposit','withdrawal fee', 'Pay Charge', 'withdrawal') ) " + " union (select "
+ 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, new Object[] { cashierId, hierarchySearchString, cashierId, hierarchySearchString,
cashierId, hierarchySearchString });
} }
private static final class CashierMapper implements RowMapper<CashierData> { private static final class CashierMapper implements RowMapper<CashierData> {
public String schema() { public String schema() {
final StringBuilder sqlBuilder = new StringBuilder(400); final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append("c.id as id,c.teller_id as teller_id, t.name as teller_name, c.description as description, "); sqlBuilder.append("c.id as id,c.teller_id as teller_id, t.name as teller_name, c.description as description, ");
sqlBuilder.append("c.staff_id as staff_id, s.display_name as staff_name, "); sqlBuilder.append("c.staff_id as staff_id, s.display_name as staff_name, ");
@@ -554,62 +527,65 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final Long staffId = rs.getLong("staff_id"); final Long staffId = rs.getLong("staff_id");
final String staffName = rs.getString("staff_name"); final String staffName = rs.getString("staff_name");
final String description = rs.getString("description"); final String description = rs.getString("description");
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;
} }
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);
} }
} }
private static final class CashierTransactionMapper implements RowMapper<CashierTransactionData> { private static final class CashierTransactionMapper implements RowMapper<CashierTransactionData> {
public String cashierTxnSchema() { public String cashierTxnSchema() {
final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append(" txn.id as txn_id, txn.cashier_id as cashier_id, "); final StringBuilder sqlBuilder = new StringBuilder(400);
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.id as txn_id, txn.cashier_id as cashier_id, ");
sqlBuilder.append(" txn.entity_type as entity_type, txn.entity_id as entity_id, txn.created_date as created_date, "); sqlBuilder.append(" txn.txn_type as txn_type, ");
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(" txn.txn_amount as txn_amount, txn.txn_date as txn_date, txn.txn_note as txn_note, ");
sqlBuilder.append(" from m_cashier_transactions txn "); sqlBuilder.append(" txn.entity_type as entity_type, txn.entity_id as entity_id, txn.created_date as created_date, ");
sqlBuilder.append(" left join m_cashiers c on c.id = txn.cashier_id "); sqlBuilder
sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id "); .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(" left join m_office o on o.id = t.office_id "); 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_tellers t on t.id = c.teller_id ");
sqlBuilder.append(" left join m_office o on o.id = t.office_id ");
sqlBuilder.append(" left join m_staff s on s.id = c.staff_id "); sqlBuilder.append(" left join m_staff s on s.id = c.staff_id ");
return sqlBuilder.toString(); return sqlBuilder.toString();
} }
public String savingsTxnSchema() { public String savingsTxnSchema() {
final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append(" sav_txn.id as txn_id, null as cashier_id, "); final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append(" sav_txn.id as txn_id, null as cashier_id, ");
sqlBuilder.append(" case "); sqlBuilder.append(" case ");
sqlBuilder.append(" when renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge') "); sqlBuilder.append(" when renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge') ");
sqlBuilder.append(" then 103 "); sqlBuilder.append(" then 103 ");
sqlBuilder.append(" when renum.enum_value in ('withdrawal', '') "); sqlBuilder.append(" when renum.enum_value in ('withdrawal', '') ");
sqlBuilder.append(" then 104 "); sqlBuilder.append(" then 104 ");
sqlBuilder.append(" else "); sqlBuilder.append(" else ");
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
sqlBuilder.append(" 'savings' as entity_type, sav.id as entity_id, sav_txn.created_date as created_date, "); .append(" concat (renum.enum_value, ', Sav:', sav.id, '-', sav.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
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(" '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(" 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 ");
@@ -619,33 +595,36 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return sqlBuilder.toString(); return sqlBuilder.toString();
} }
public String loansTxnSchema() {
final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append(" loan_txn.id as txn_id, c.id as cashier_id, "); public String loansTxnSchema() {
sqlBuilder.append(" case ");
sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') "); final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append(" then 103 ");
sqlBuilder.append(" when renum.enum_value in ('Disbursement') "); sqlBuilder.append(" loan_txn.id as txn_id, c.id as cashier_id, ");
sqlBuilder.append(" then 104 "); sqlBuilder.append(" case ");
sqlBuilder.append(" else "); sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') ");
sqlBuilder.append(" 105 "); sqlBuilder.append(" then 103 ");
sqlBuilder.append(" end as cash_txn_type, "); sqlBuilder.append(" when renum.enum_value in ('Disbursement') ");
sqlBuilder.append(" loan_txn.amount as txn_amount, loan_txn.transaction_date as txn_date, "); sqlBuilder.append(" then 104 ");
sqlBuilder.append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, "); sqlBuilder.append(" else ");
sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, "); sqlBuilder.append(" 105 ");
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(" end as cash_txn_type, ");
sqlBuilder.append(" from m_loan_transaction loan_txn "); sqlBuilder.append(" loan_txn.amount as txn_amount, loan_txn.transaction_date as txn_date, ");
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
sqlBuilder.append(" left join m_loan loan on loan_txn.loan_id = loan.id "); .append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id "); sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, ");
sqlBuilder.append(" left join m_office o on cl.office_id = o.id "); sqlBuilder
sqlBuilder.append(" left join m_appuser user on loan_txn.appuser_id = user.id "); .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(" left join m_staff staff on user.staff_id = staff.id "); sqlBuilder.append(" from m_loan_transaction loan_txn ");
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id "); 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_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_appuser user on loan_txn.appuser_id = user.id ");
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
return sqlBuilder.toString(); return sqlBuilder.toString();
} }
@@ -662,65 +641,67 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final String entityType = rs.getString("entity_type"); final String entityType = rs.getString("entity_type");
final Long entityId = rs.getLong("entity_id"); final Long entityId = rs.getLong("entity_id");
final LocalDate createdLocalDate = JdbcSupport.getLocalDate(rs, "created_date"); final LocalDate createdLocalDate = JdbcSupport.getLocalDate(rs, "created_date");
Date txnDate = null; Date txnDate = null;
if (txnLocalDate != null) { if (txnLocalDate != null) {
txnDate = txnLocalDate.toDate(); txnDate = txnLocalDate.toDate();
} }
Date createdDate = null; Date createdDate = null;
if (createdLocalDate != null) { if (createdLocalDate != null) {
createdDate = createdLocalDate.toDate(); createdDate = createdLocalDate.toDate();
} }
final Long officeId = rs.getLong("office_id"); final Long officeId = rs.getLong("office_id");
final String officeName = rs.getString("office_name"); final String officeName = rs.getString("office_name");
final Long tellerId = rs.getLong("teller_id"); final Long tellerId = rs.getLong("teller_id");
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);
} }
} }
private static final class CashierTransactionSummaryMapper implements RowMapper<CashierTransactionTypeTotalsData> { private static final class CashierTransactionSummaryMapper implements RowMapper<CashierTransactionTypeTotalsData> {
public String cashierTxnSummarySchema() { public String cashierTxnSummarySchema() {
final StringBuilder sqlBuilder = new StringBuilder(400); final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append(" cash_txn_type, sum(txn_amount) as txn_total from "); sqlBuilder.append(" cash_txn_type, sum(txn_amount) as txn_total from ");
sqlBuilder.append(" (select * from "); sqlBuilder.append(" (select * from ");
sqlBuilder.append(" (select txn.id as txn_id, txn.cashier_id as cashier_id, "); sqlBuilder.append(" (select txn.id as txn_id, txn.cashier_id as cashier_id, ");
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
sqlBuilder.append(" from m_cashier_transactions txn "); .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(" left join m_cashiers c on c.id = txn.cashier_id "); sqlBuilder.append(" from m_cashier_transactions txn ");
sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id "); sqlBuilder.append(" left join m_cashiers c on c.id = txn.cashier_id ");
sqlBuilder.append(" left join m_office o on o.id = t.office_id "); sqlBuilder.append(" left join m_tellers t on t.id = c.teller_id ");
sqlBuilder.append(" left join m_staff s on s.id = c.staff_id "); sqlBuilder.append(" left join m_office o on o.id = t.office_id ");
sqlBuilder.append(" left join m_staff s on s.id = c.staff_id ");
sqlBuilder.append(" where txn.cashier_id = ? "); sqlBuilder.append(" where txn.cashier_id = ? ");
sqlBuilder.append(" and o.hierarchy like ? ) cashier_txns "); sqlBuilder.append(" and o.hierarchy like ? ) cashier_txns ");
sqlBuilder.append(" UNION "); sqlBuilder.append(" UNION ");
sqlBuilder.append(" (select sav_txn.id as txn_id, c.id as cashier_id, "); sqlBuilder.append(" (select sav_txn.id as txn_id, c.id as cashier_id, ");
sqlBuilder.append(" case "); sqlBuilder.append(" case ");
sqlBuilder.append(" when renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge') "); sqlBuilder.append(" when renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge') ");
sqlBuilder.append(" then 103 "); sqlBuilder.append(" then 103 ");
sqlBuilder.append(" when renum.enum_value in ('withdrawal') "); sqlBuilder.append(" when renum.enum_value in ('withdrawal') ");
sqlBuilder.append(" then 104 "); sqlBuilder.append(" then 104 ");
sqlBuilder.append(" else "); sqlBuilder.append(" else ");
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
sqlBuilder.append(" 'savings' as entity_type, sav.id as entity_id, sav_txn.created_date as created_date, "); .append(" concat (renum.enum_value, ', Sav:', sav.id, '-', sav.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
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(" '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(" 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 ");
@@ -728,52 +709,54 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id "); sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id "); sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
sqlBuilder.append(" where sav_txn.is_reversed = 0 and c.id = ? "); sqlBuilder.append(" where sav_txn.is_reversed = 0 and c.id = ? ");
sqlBuilder.append(" and o.hierarchy like ? and "); sqlBuilder.append(" and o.hierarchy like ? and ");
sqlBuilder.append(" created_date between c.start_date and date_add(c.end_date, interval 1 day) "); sqlBuilder.append(" created_date between c.start_date and date_add(c.end_date, interval 1 day) ");
sqlBuilder.append(" ) "); sqlBuilder.append(" ) ");
sqlBuilder.append(" UNION "); sqlBuilder.append(" UNION ");
sqlBuilder.append(" ( "); sqlBuilder.append(" ( ");
sqlBuilder.append(" select loan_txn.id as txn_id, c.id as cashier_id, "); sqlBuilder.append(" select loan_txn.id as txn_id, c.id as cashier_id, ");
sqlBuilder.append(" case "); sqlBuilder.append(" case ");
sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') "); sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') ");
sqlBuilder.append(" then 103 "); sqlBuilder.append(" then 103 ");
sqlBuilder.append(" when renum.enum_value in ('Disbursement') "); sqlBuilder.append(" when renum.enum_value in ('Disbursement') ");
sqlBuilder.append(" then 104 "); sqlBuilder.append(" then 104 ");
sqlBuilder.append(" else "); sqlBuilder.append(" else ");
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
sqlBuilder.append(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, "); .append(" concat (renum.enum_value, ', Loan:', loan.id, '-', loan.account_no, ',Client:', cl.id, '-',cl.display_name) as txn_note, ");
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(" 'loans' as entity_type, loan.id as entity_id, loan_txn.created_date as created_date, ");
sqlBuilder.append(" from m_loan_transaction loan_txn "); sqlBuilder
sqlBuilder.append(" left join r_enum_value renum on loan_txn.transaction_type_enum = renum.enum_id and renum.enum_name = 'transaction_type_enum' "); .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(" left join m_loan loan on loan_txn.loan_id = loan.id "); sqlBuilder.append(" from m_loan_transaction loan_txn ");
sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id "); sqlBuilder
sqlBuilder.append(" left join m_office o on cl.office_id = o.id "); .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_appuser user on loan_txn.appuser_id = user.id "); sqlBuilder.append(" left join m_loan loan on loan_txn.loan_id = loan.id ");
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id "); sqlBuilder.append(" left join m_client cl on loan.client_id = cl.id ");
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id "); sqlBuilder.append(" left join m_office o on cl.office_id = o.id ");
sqlBuilder.append(" where loan_txn.is_reversed = 0 and c.id = ? "); sqlBuilder.append(" left join m_appuser user on loan_txn.appuser_id = user.id ");
sqlBuilder.append(" and o.hierarchy like ? "); sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
sqlBuilder.append(" and created_date between c.start_date and date_add(c.end_date, interval 1 day) "); sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
sqlBuilder.append(" where loan_txn.is_reversed = 0 and c.id = ? ");
sqlBuilder.append(" and o.hierarchy like ? ");
sqlBuilder.append(" and created_date between c.start_date and date_add(c.end_date, interval 1 day) ");
sqlBuilder.append(" ) "); sqlBuilder.append(" ) ");
sqlBuilder.append(" ) txns "); sqlBuilder.append(" ) txns ");
sqlBuilder.append(" group by cash_txn_type "); sqlBuilder.append(" group by cash_txn_type ");
return sqlBuilder.toString(); return sqlBuilder.toString();
} }
@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`;