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><a href="#roles_retrieve">Retrieve 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>
<td></td>
@@ -1984,6 +1984,22 @@
Permissions</a></td>
<td></td>
</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>
<td><a href="#permissions">Permission</a></td>
<td>permissions</td>
@@ -30184,6 +30200,30 @@ GET https://DomainName/api/v1/roles
</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>
<div class="method-section">
<div class="method-description">
@@ -30305,6 +30345,52 @@ GET https://DomainName/api/v1/roles/{roleId}/permissions
</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"
class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
@@ -5,6 +5,20 @@
*/
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.ISODateTimeFormat;
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.TellerJournalData;
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.util.DateRange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
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")
@Component
@Scope("singleton")
@@ -148,8 +156,7 @@ public class TellerApiResource {
final TellerData teller = this.readPlatformService.findTeller(tellerId);
Long officeId = teller.getOfficeId();
final CashierData cashier =
this.readPlatformService.retrieveCashierTemplate(officeId, tellerId, true);
final CashierData cashier = this.readPlatformService.retrieveCashierTemplate(officeId, tellerId, true);
return this.jsonSerializer.serialize(cashier);
}
@@ -170,8 +177,10 @@ public class TellerApiResource {
@Path("{tellerId}/cashiers/{cashierId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String updateCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId, final String cashierDate) {
final CommandWrapper request = new CommandWrapperBuilder().updateAllocationTeller(tellerId, cashierId).withJson(cashierDate).build();
public String updateCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final String cashierDate) {
final CommandWrapper request = new CommandWrapperBuilder().updateAllocationTeller(tellerId, cashierId).withJson(cashierDate)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
@@ -194,8 +203,10 @@ public class TellerApiResource {
@Path("{tellerId}/cashiers/{cashierId}/allocate")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String allocateCashToCashier (@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId, final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateCashToCashier(tellerId, cashierId).withJson(cashierTxnData).build();
public String allocateCashToCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateCashToCashier(tellerId, cashierId).withJson(cashierTxnData)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
@@ -207,8 +218,10 @@ public class TellerApiResource {
@Path("{tellerId}/cashiers/{cashierId}/settle")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String settleCashFromCashier (@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId, final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().settleCashFromCashier(tellerId, cashierId).withJson(cashierTxnData).build();
public String settleCashFromCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final String cashierTxnData) {
final CommandWrapper request = new CommandWrapperBuilder().settleCashFromCashier(tellerId, cashierId).withJson(cashierTxnData)
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(request);
@@ -220,8 +233,7 @@ public class TellerApiResource {
@Path("{tellerId}/cashiers/{cashierId}/transactions")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getTransactionsForCashier (@PathParam("tellerId") final Long tellerId,
@PathParam("cashierId") final Long cashierId,
public String getTransactionsForCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId,
final String fromDateStr, final String toDateStr) {
final TellerData teller = this.readPlatformService.findTeller(tellerId);
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
@@ -229,9 +241,8 @@ public class TellerApiResource {
final Date fromDate = null;
final Date toDate = null;
final Collection<CashierTransactionData> cashierTxns =
this.readPlatformService.retrieveCashierTransactions(cashierId,
true, fromDate, toDate);
final Collection<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, true,
fromDate, toDate);
return this.jsonSerializer.serialize(cashierTxns);
}
@@ -241,18 +252,15 @@ public class TellerApiResource {
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getTransactionsWtihSummaryForCashier(@PathParam("tellerId") final Long tellerId,
@PathParam("cashierId") final Long cashierId,
final String fromDateStr, final String toDateStr) {
@PathParam("cashierId") final Long cashierId, final String fromDateStr, final String toDateStr) {
final TellerData teller = this.readPlatformService.findTeller(tellerId);
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
final Date fromDate = null;
final Date toDate = null;
final CashierTransactionsWithSummaryData cashierTxnWithSummary =
this.readPlatformService.retrieveCashierTransactionsWithSummary
(cashierId,
true, fromDate, toDate);
final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.readPlatformService.retrieveCashierTransactionsWithSummary(
cashierId, true, fromDate, toDate);
return this.jsonSerializer.serialize(cashierTxnWithSummary);
}
@@ -263,24 +271,20 @@ public class TellerApiResource {
@Produces(MediaType.APPLICATION_JSON)
public String getCashierTxnTemplate(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) {
final CashierTransactionData cashierTxnTemplate =
this.readPlatformService.retrieveCashierTxnTemplate(cashierId);
final CashierTransactionData cashierTxnTemplate = this.readPlatformService.retrieveCashierTxnTemplate(cashierId);
return this.jsonSerializer.serialize(cashierTxnTemplate);
}
@GET
@Path("{tellerId}/transactions")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getTransactionData(@PathParam("tellerId") final Long tellerId,
@QueryParam("dateRange") final String dateRange) {
public String getTransactionData(@PathParam("tellerId") final Long tellerId, @QueryParam("dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerTransactionData> transactions =
this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId, dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
final Collection<TellerTransactionData> transactions = this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId,
dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(transactions);
}
@@ -289,8 +293,7 @@ public class TellerApiResource {
@Path("{tellerId}/transactions/{transactionId}")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String findTransactionData(@PathParam("tellerId") final Long tellerid,
@PathParam("transactionId") final Long transactionId) {
public String findTransactionData(@PathParam("tellerId") final Long tellerid, @PathParam("transactionId") final Long transactionId) {
final TellerTransactionData transaction = this.readPlatformService.findTellerTransaction(transactionId);
return this.jsonSerializer.serialize(transaction);
@@ -300,18 +303,18 @@ public class TellerApiResource {
@Path("{tellerId}/journals")
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getJournalData(@PathParam("tellerId") final Long tellerId,
@QueryParam("cashierId") final Long cashierDate,
public String getJournalData(@PathParam("tellerId") final Long tellerId, @QueryParam("cashierId") final Long cashierDate,
@QueryParam("dateRange") final String dateRange) {
final DateRange dateRangeHolder = DateRange.fromString(dateRange);
final Collection<TellerJournalData> journals =
this.readPlatformService.fetchTellerJournals(tellerId, cashierDate, dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
final Collection<TellerJournalData> journals = this.readPlatformService.fetchTellerJournals(tellerId, cashierDate,
dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(journals);
}
private class CashiersForTeller {
public Long tellerId;
public String tellerName;
public Long officeId;
@@ -10,13 +10,8 @@ import java.math.BigDecimal;
import java.util.Collection;
import java.util.Date;
import org.joda.time.LocalDate;
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.monetary.data.CurrencyData;
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 {
@@ -41,6 +36,8 @@ public final class CashierTransactionData implements Serializable {
private final Date startDate;
private final Date endDate;
private final Collection<CurrencyData> currencyOptions;
/*
* Creates a new cashier.
*/
@@ -48,7 +45,7 @@ public final class CashierTransactionData implements Serializable {
final BigDecimal txnAmount, final Date txnDate, String txnNote,
String entityType, Long entityId, Date createdDate,
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.cashierId = cashierId;
this.txnType = txnType;
@@ -68,6 +65,8 @@ public final class CashierTransactionData implements Serializable {
this.startDate = startDate;
this.endDate = endDate;
this.currencyOptions = currencyOptions;
}
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) {
return new CashierTransactionData(id, cashierId, txnType, txnAmount, txnDate, txnNote, entityType,
entityId, createdDate, officeId, officeName, tellerId,
tellerName, cashierName, cashierData, startDate, endDate);
tellerName, cashierName, cashierData, startDate, endDate, null);
}
public static CashierTransactionData template (final Long cashierId,
final Long tellerId, final String tellerName,
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,
null, null, officeId, officeName, tellerId, tellerName, cashierName, cashierData,
startDate, endDate);
startDate, endDate, currencyOptions);
}
public Long getId() {
@@ -55,6 +55,9 @@ public class CashierTransaction extends AbstractPersistable<Long> {
@Column(name = "created_date", nullable = false)
private Date createdDate;
@Column(name = "currency_code", nullable = true)
private String currencyCode;
/**
* Creates a new cashier.
*/
@@ -71,15 +74,16 @@ public class CashierTransaction extends AbstractPersistable<Long> {
final String entityType = command.stringValueOfParameterNamed("entityType");
final String txnNote = command.stringValueOfParameterNamed("txnNote");
final Long entityId = command.longValueOfParameterNamed("entityId");
final String currencyCode = command.stringValueOfParameterNamed("currencyCode");
// TODO: get client/loan/savings details
return new CashierTransaction (cashier, txnType, txnAmount, txnDate,
entityType, entityId, txnNote);
entityType, entityId, txnNote, currencyCode);
}
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.txnType = txnType;
if (txnDate != null) {
@@ -90,6 +94,7 @@ public class CashierTransaction extends AbstractPersistable<Long> {
this.entityId = entityId;
this.txnNote = txnNote;
this.createdDate = new Date();
this.currencyCode = currencyCode;
}
public Map<String, Object> update(final JsonCommand command) {
@@ -131,6 +136,13 @@ public class CashierTransaction extends AbstractPersistable<Long> {
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;
}
@@ -248,4 +260,12 @@ public class CashierTransaction extends AbstractPersistable<Long> {
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",
"endDate", "status", "dateFormat", "locale",
"isFullDay", "staffId", "startTime", "endTime",
"txnAmount","txnDate", "txnNote", "entityType", "entityId"));
"txnAmount","txnDate", "txnNote", "entityType", "entityId", "currencyCode"));
private final FromJsonHelper fromApiJsonHelper;
@@ -164,5 +164,8 @@ public final class TellerCommandFromApiJsonDeserializer {
final String txnNote = this.fromApiJsonHelper.extractStringNamed("txnNote", element);
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.service.RoutingDataSource;
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.service.OfficeReadPlatformService;
import org.mifosplatform.organisation.staff.data.StaffData;
@@ -50,17 +52,17 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
private final TellerInOfficeHierarchyMapper tellerInOfficeHierarchyMapper = new TellerInOfficeHierarchyMapper();
private final OfficeReadPlatformService officeReadPlatformService;
private final StaffReadPlatformService staffReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService;
@Autowired
public TellerManagementReadPlatformServiceImpl(final PlatformSecurityContext context,
final RoutingDataSource dataSource,
final OfficeReadPlatformService officeReadPlatformService,
StaffReadPlatformService staffReadPlatformService
) {
public TellerManagementReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
final OfficeReadPlatformService officeReadPlatformService, StaffReadPlatformService staffReadPlatformService,
final CurrencyReadPlatformService currencyReadPlatformService) {
this.context = context;
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.officeReadPlatformService = officeReadPlatformService;
this.staffReadPlatformService = staffReadPlatformService;
this.currencyReadPlatformService = currencyReadPlatformService;
}
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 endDate = JdbcSupport.getLocalDate(rs, "end_date");
return TellerData.instance(id, officeId, debitAccountId, creditAccountId,
tellerName, description, startDate, endDate, tellerStatus, officeName, null, null);
return TellerData.instance(id, officeId, debitAccountId, creditAccountId, tellerName, description, startDate, endDate,
tellerStatus, officeName, null, null);
}
}
@@ -139,8 +141,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_date");
final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date");
return TellerData.instance(id, officeId, debitAccountId, creditAccountId,
tellerName, description, startDate, endDate, tellerStatus, officeName, null, null);
return TellerData.instance(id, officeId, debitAccountId, creditAccountId, tellerName, description, startDate, endDate,
tellerStatus, officeName, null, null);
}
}
@@ -253,8 +255,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
}
@Override
public Collection<CashierData> getCashiersForTeller(Long tellerId,
Date fromDate, Date toDate) {
public Collection<CashierData> getCashiersForTeller(Long tellerId, Date fromDate, Date toDate) {
return retrieveCashiersForTellers(null, tellerId);
}
@@ -294,7 +295,6 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.query(sql, cm, new Object[] {});
}
@Override
public CashierData findCashier(Long cashierId) {
try {
@@ -308,8 +308,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
}
@Override
public Collection<CashierData> getCashierData(Long officeId, Long tellerId,
Long staffId, Date date) {
public Collection<CashierData> getCashierData(Long officeId, Long tellerId, Long staffId, Date date) {
// TODO Auto-generated method stub
return null;
}
@@ -327,27 +326,23 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
}
@Override
public Collection<TellerTransactionData> fetchTellerTransactionsByTellerId(
Long tellerId, Date fromDate, Date toDate) {
public Collection<TellerTransactionData> fetchTellerTransactionsByTellerId(Long tellerId, Date fromDate, Date toDate) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<TellerJournalData> getJournals(Long officeId,
Long tellerId, Long cashierId, Date dateFrom, Date dateTo) {
public Collection<TellerJournalData> getJournals(Long officeId, Long tellerId, Long cashierId, Date dateFrom, Date dateTo) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<TellerJournalData> fetchTellerJournals(Long tellerId,
Long cashierId, Date fromDate, Date toDate) {
public Collection<TellerJournalData> fetchTellerJournals(Long tellerId, Long cashierId, Date fromDate, Date toDate) {
// TODO Auto-generated method stub
return null;
}
@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) {
final AppUser currentUser = this.context.authenticatedUser();
@@ -365,8 +360,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
}
@Override
public CashierData retrieveCashierTemplate(Long officeId, Long tellerId,
boolean staffInSelectedOfficeOnly) {
public CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly) {
final Long defaultOfficeId = defaultToUsersOfficeIfNull(officeId);
final OfficeData officeData = this.officeReadPlatformService.retrieveOffice(defaultOfficeId);
@@ -396,8 +390,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
staffOptions = null;
}
return CashierData.template(officeId, officeName,
tellerId, tellerName, staffOptions);
return CashierData.template(officeId, officeName, tellerId, tellerName, staffOptions);
}
@Override
@@ -424,14 +417,15 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
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);
return CashierTransactionData.template(cashierId, tellerId, tellerName, officeId, officeName, cashierName, cashierData, startDate,
endDate, currencyOptions);
}
@Override
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary (
final Long cashierId, final boolean includeAllTellers,
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(final Long cashierId, final boolean includeAllTellers,
final Date fromDate, final Date toDate) {
final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy();
@@ -441,15 +435,11 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} else {
hierarchySearchString = hierarchy + "%";
}
final CashierTransactionSummaryMapper ctsm =
new CashierTransactionSummaryMapper();
final CashierTransactionSummaryMapper ctsm = new CashierTransactionSummaryMapper();
final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000";
Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals =
this.jdbcTemplate.query(sql, ctsm, new Object[] {
cashierId, hierarchySearchString,
cashierId, hierarchySearchString,
cashierId, hierarchySearchString });
Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, new Object[] { cashierId,
hierarchySearchString, cashierId, hierarchySearchString, cashierId, hierarchySearchString });
Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator();
BigDecimal allocAmount = new BigDecimal(0);
@@ -472,29 +462,19 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
}
}
final Collection<CashierTransactionData> cashierTransactions =
retrieveCashierTransactions (cashierId, includeAllTellers,
fromDate, toDate);
final Collection<CashierTransactionData> cashierTransactions = retrieveCashierTransactions(cashierId, includeAllTellers, fromDate,
toDate);
CashierTransactionData cashierTxnTemplate = retrieveCashierTxnTemplate(cashierId);
CashierTransactionsWithSummaryData txnsWithSummary =
CashierTransactionsWithSummaryData.instance(
cashierTransactions,
allocAmount,
cashInAmount,
cashOutAmount,
settleAmount,
cashierTxnTemplate.getOfficeName(),
cashierTxnTemplate.getTellerId(), cashierTxnTemplate.getTellerName(),
cashierTxnTemplate.getCashierId(), cashierTxnTemplate.getCashierName()
);
CashierTransactionsWithSummaryData txnsWithSummary = CashierTransactionsWithSummaryData.instance(cashierTransactions, allocAmount,
cashInAmount, cashOutAmount, settleAmount, cashierTxnTemplate.getOfficeName(), cashierTxnTemplate.getTellerId(),
cashierTxnTemplate.getTellerName(), cashierTxnTemplate.getCashierId(), cashierTxnTemplate.getCashierName());
return txnsWithSummary;
}
@Override
public Collection<CashierTransactionData> retrieveCashierTransactions (
final Long cashierId, final boolean includeAllTellers,
public Collection<CashierTransactionData> retrieveCashierTransactions(final Long cashierId, final boolean includeAllTellers,
final Date fromDate, final Date toDate) {
final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy();
@@ -507,24 +487,17 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
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 ";
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,
new Object[] { cashierId, hierarchySearchString,
cashierId, hierarchySearchString,
return this.jdbcTemplate.query(sql, ctm, new Object[] { cashierId, hierarchySearchString, cashierId, hierarchySearchString,
cashierId, hierarchySearchString });
}
@@ -565,9 +538,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final String startTime = rs.getString("start_time");
final String endTime = rs.getString("end_time");
return CashierData.instance(id, null, null,
staffId, staffName, tellerId, tellerName,
description, startDate.toDate(), endDate.toDate(), fullDay, startTime, endTime);
return CashierData.instance(id, null, null, staffId, staffName, tellerId, tellerName, 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_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(" 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(" left join m_cashiers c on c.id = txn.cashier_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(" end as txn_type, ");
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(" 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(" 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_client cl on sav.client_id = cl.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(" end as cash_txn_type, ");
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(" 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(" 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_client cl on loan.client_id = cl.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 cashierName = rs.getString("cashier_name");
return CashierTransactionData.instance(
id, cashierId, txnType, txnAmount, txnDate, txnNote,
entityType, entityId, createdDate, officeId, officeName,
tellerId, tellerName, cashierName, null, null, null);
return CashierTransactionData.instance(id, cashierId, txnType, txnAmount, txnDate, txnNote, 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_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(" 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(" left join m_cashiers c on c.id = txn.cashier_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(" end as cash_txn_type, ");
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(" 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(" 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_client cl on sav.client_id = cl.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(" end as cash_txn_type, ");
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(" 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(" 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_client cl on loan.client_id = cl.id ");
sqlBuilder.append(" left join m_office o on cl.office_id = o.id ");
@@ -765,15 +749,14 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
}
@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 BigDecimal txnTotal = rs.getBigDecimal("txn_total");
return CashierTransactionTypeTotalsData.instance(
cashierTxnType, txnTotal);
return CashierTransactionTypeTotalsData.instance(cashierTxnType, txnTotal);
}
}
}
@@ -0,0 +1 @@
ALTER TABLE `m_cashier_transactions` ADD COLUMN `currency_code` VARCHAR(3) NULL AFTER `txn_note`;