diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm
index 1e8b8c763..34887c066 100644
--- a/api-docs/apiLive.htm
+++ b/api-docs/apiLive.htm
@@ -1972,7 +1972,7 @@
|
Retrieve a Role |
Update a Role |
- |
+ Delete Role |
|
@@ -1984,6 +1984,22 @@
Permissions
|
+
+ |
+ roles/{roleId}?command=enable |
+ Enable Role |
+ |
+ |
+ |
+
+
+ |
+ roles/{roleId}?command=disable |
+ Disable Role |
+ |
+ |
+ |
+
| Permission |
permissions |
@@ -30183,6 +30199,30 @@ GET https://DomainName/api/v1/roles
+
+
+
+
+
+
Delete a Role
+
Description : Delete the role in case role is not associated with any users.
+
+
+
+DELETE https://DomainName/api/v1/roles/{roleId}
+
+
+DELETE roles/20
+Content-Type: application/json
+No Request Body
+
+
+{
+ "resourceId":1
+}
+
+
+
@@ -30304,6 +30344,52 @@ GET https://DomainName/api/v1/roles/{roleId}/permissions
+
+
+
+
+
Enable Role
+
Description : Enable role in case role is disabled.
+
+
+
+POST https://DomainName/api/v1/roles/{roleId}?command=enable
+
+
+POST roles/1?command=enable
+Content-Type: application/json
+No Request Body
+
+
+{
+ "resourceId":1
+}
+
+
+
+
+
+
+
+
Disable Role
+
Description : Disable the role in case role is not associated with any users.
+
+
+
+POST https://DomainName/api/v1/roles/{roleId}?command=disable
+
+
+POST roles/1?command=disable
+Content-Type: application/json
+No Request Body
+
+
+{
+ "resourceId":1
+}
+
+
+
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/api/TellerApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/api/TellerApiResource.java
index 11aadacfa..dc806b97a 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/api/TellerApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/api/TellerApiResource.java
@@ -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")
@@ -43,7 +51,7 @@ public class TellerApiResource {
@Autowired
public TellerApiResource(PlatformSecurityContext securityContext, DefaultToApiJsonSerializer jsonSerializer,
- TellerManagementReadPlatformService readPlatformService, PortfolioCommandSourceWritePlatformService commandWritePlatformService) {
+ TellerManagementReadPlatformService readPlatformService, PortfolioCommandSourceWritePlatformService commandWritePlatformService) {
super();
this.securityContext = securityContext;
this.jsonSerializer = jsonSerializer;
@@ -52,7 +60,7 @@ public class TellerApiResource {
}
@GET
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getTellerData(@QueryParam("officeId") final Long officeId) {
final Collection foundTellers = this.readPlatformService.getTellers(officeId);
@@ -62,7 +70,7 @@ public class TellerApiResource {
@Path("{tellerId}")
@GET
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String findTeller(@PathParam("tellerId") final Long tellerId) {
final TellerData teller = this.readPlatformService.findTeller(tellerId);
@@ -71,7 +79,7 @@ public class TellerApiResource {
}
@POST
- @Consumes({MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String createTeller(final String tellerData) {
final CommandWrapper request = new CommandWrapperBuilder().createTeller().withJson(tellerData).build();
@@ -83,7 +91,7 @@ public class TellerApiResource {
@Path("{tellerId}")
@PUT
- @Consumes({MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String updateTeller(@PathParam("tellerId") final Long tellerId, final String tellerData) {
final CommandWrapper request = new CommandWrapperBuilder().updateTeller(tellerId).withJson(tellerData).build();
@@ -95,7 +103,7 @@ public class TellerApiResource {
@Path("{tellerId}")
@DELETE
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String deleteTeller(@PathParam("tellerId") final Long tellerId) {
final CommandWrapper request = new CommandWrapperBuilder().deleteTeller(tellerId).build();
@@ -107,10 +115,10 @@ public class TellerApiResource {
@GET
@Path("{tellerId}/cashiers")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
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 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 Collection cashiers = this.readPlatformService.getCashiersForTeller(tellerId, fromDate, toDate);
-
+
CashiersForTeller cashiersForTeller = new CashiersForTeller();
cashiersForTeller.cashiers = cashiers;
cashiersForTeller.tellerId = tellerId;
@@ -131,32 +139,31 @@ public class TellerApiResource {
@GET
@Path("{tellerId}/cashiers/{cashierId}")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String findCashierData(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) {
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
return this.jsonSerializer.serialize(cashier);
}
-
+
@GET
@Path("{tellerId}/cashiers/template")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String getCashierTemplate(@PathParam("tellerId") final Long tellerId) {
-
+
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);
}
@POST
@Path("{tellerId}/cashiers")
- @Consumes({MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String createCashier(@PathParam("tellerId") final Long tellerId, final String cashierData) {
final CommandWrapper request = new CommandWrapperBuilder().allocateTeller(tellerId).withJson(cashierData).build();
@@ -168,10 +175,12 @@ public class TellerApiResource {
@PUT
@Path("{tellerId}/cashiers/{cashierId}")
- @Consumes({MediaType.APPLICATION_JSON})
+ @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);
@@ -180,7 +189,7 @@ public class TellerApiResource {
@DELETE
@Path("{tellerId}/cashiers/{cashierId}")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
public String deleteCashier(@PathParam("tellerId") final Long tellerId, @PathParam("cashierId") final Long cashierId) {
final CommandWrapper request = new CommandWrapperBuilder().deleteAllocationTeller(tellerId, cashierId).build();
@@ -189,108 +198,102 @@ public class TellerApiResource {
return this.jsonSerializer.serialize(result);
}
-
+
@POST
@Path("{tellerId}/cashiers/{cashierId}/allocate")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @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);
return this.jsonSerializer.serialize(result);
}
-
+
@POST
@Path("{tellerId}/cashiers/{cashierId}/settle")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @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);
return this.jsonSerializer.serialize(result);
}
-
+
@GET
@Path("{tellerId}/cashiers/{cashierId}/transactions")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
- public String getTransactionsForCashier (@PathParam("tellerId") final Long tellerId,
- @PathParam("cashierId") final Long cashierId,
- final String fromDateStr, final String toDateStr) {
+ 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);
-
+
final Date fromDate = null;
final Date toDate = null;
-
- final Collection cashierTxns =
- this.readPlatformService.retrieveCashierTransactions(cashierId,
- true, fromDate, toDate);
-
+
+ final Collection cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, true,
+ fromDate, toDate);
+
return this.jsonSerializer.serialize(cashierTxns);
}
-
+
@GET
@Path("{tellerId}/cashiers/{cashierId}/summaryandtransactions")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @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) {
+ public String getTransactionsWtihSummaryForCashier(@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);
-
+
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);
}
-
+
@GET
@Path("{tellerId}/cashiers/{cashierId}/transactions/template")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@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})
+ @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 transactions =
- this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId, dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
+ final Collection transactions = this.readPlatformService.fetchTellerTransactionsByTellerId(tellerId,
+ dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
return this.jsonSerializer.serialize(transactions);
}
@GET
@Path("{tellerId}/transactions/{transactionId}")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @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);
@@ -298,25 +301,25 @@ public class TellerApiResource {
@GET
@Path("{tellerId}/journals")
- @Consumes({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
+ @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
- public String getJournalData(@PathParam("tellerId") final Long tellerId,
- @QueryParam("cashierId") final Long cashierDate,
- @QueryParam("dateRange") final String dateRange) {
+ 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 journals =
- this.readPlatformService.fetchTellerJournals(tellerId, cashierDate, dateRangeHolder.getStartDate(), dateRangeHolder.getEndDate());
+ final Collection 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;
- public String officeName;
- public Collection cashiers;
-
+
+ public Long tellerId;
+ public String tellerName;
+ public Long officeId;
+ public String officeName;
+ public Collection cashiers;
+
}
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/data/CashierTransactionData.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/data/CashierTransactionData.java
index 6a43bf0ea..134c46a19 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/data/CashierTransactionData.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/data/CashierTransactionData.java
@@ -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 {
@@ -40,6 +35,8 @@ public final class CashierTransactionData implements Serializable {
private final CashierData cashierData;
private final Date startDate;
private final Date endDate;
+
+ private final Collection 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 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 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() {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/domain/CashierTransaction.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/domain/CashierTransaction.java
index ba43847c3..725f9e907 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/domain/CashierTransaction.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/domain/CashierTransaction.java
@@ -54,6 +54,9 @@ public class CashierTransaction extends AbstractPersistable {
@Temporal(TemporalType.TIMESTAMP)
@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 {
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 {
this.entityId = entityId;
this.txnNote = txnNote;
this.createdDate = new Date();
+ this.currencyCode = currencyCode;
}
public Map update(final JsonCommand command) {
@@ -130,6 +135,13 @@ public class CashierTransaction extends AbstractPersistable {
actualChanges.put(txnNoteParamName, 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;
}
@@ -247,5 +259,13 @@ public class CashierTransaction extends AbstractPersistable {
public void setTxnNote (String txnNote) {
this.txnNote = txnNote;
}
+
+ public String getCurrencyCode() {
+ return this.currencyCode;
+ }
+
+ public void setCurrencyCode(String currencyCode) {
+ this.currencyCode = currencyCode;
+ }
}
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/serialization/TellerCommandFromApiJsonDeserializer.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/serialization/TellerCommandFromApiJsonDeserializer.java
index 9f7789f4d..865f5164e 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/serialization/TellerCommandFromApiJsonDeserializer.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/serialization/TellerCommandFromApiJsonDeserializer.java
@@ -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);
}
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
index 2af7c9c2b..211538081 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
@@ -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,24 +52,24 @@ 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 {
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.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;
final Integer status = rs.getInt("status");
if (status != null) {
- tellerStatus = TellerStatus.fromInt(status);
+ tellerStatus = TellerStatus.fromInt(status);
}
final Long debitAccountId = rs.getLong("debit_account_id");
final Long creditAccountId = rs.getLong("credit_account_id");
-
+
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);
}
}
@@ -131,16 +133,16 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
TellerStatus tellerStatus = null;
final Integer status = rs.getInt("status");
if (status != null) {
- tellerStatus = TellerStatus.fromInt(status);
+ tellerStatus = TellerStatus.fromInt(status);
}
final Long debitAccountId = rs.getLong("debit_account_id");
final Long creditAccountId = rs.getLong("credit_account_id");
-
+
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);
}
}
@@ -247,24 +249,23 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return extraCriteria.toString();
}
- @Override
- public Collection getTellers(Long officeId) {
- return retrieveAllTellers (false);
- }
-
- @Override
- public Collection getCashiersForTeller(Long tellerId,
- Date fromDate, Date toDate) {
- return retrieveCashiersForTellers (null, tellerId);
- }
-
- @Override
+ @Override
+ public Collection getTellers(Long officeId) {
+ return retrieveAllTellers(false);
+ }
+
+ @Override
+ public Collection getCashiersForTeller(Long tellerId, Date fromDate, Date toDate) {
+ return retrieveCashiersForTellers(null, tellerId);
+ }
+
+ @Override
public Collection retrieveCashiersForTellers(final String sqlSearch, final Long 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);
@@ -279,11 +280,11 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
if (StringUtils.isNotBlank(extraCriteria.toString())) {
extraCriteria.delete(0, 4);
}
-
+
return extraCriteria.toString();
}
- private Collection fetchCashiers (final String extraCriteria) {
+ private Collection fetchCashiers(final String extraCriteria) {
final CashierMapper cm = new CashierMapper();
String sql = "select " + cm.schema();
@@ -294,10 +295,9 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.query(sql, cm, new Object[] {});
}
-
- @Override
- public CashierData findCashier(Long cashierId) {
- try {
+ @Override
+ public CashierData findCashier(Long cashierId) {
+ try {
final CashierMapper cm = new CashierMapper();
final String sql = "select " + cm.schema() + " where c.id = ?";
@@ -305,48 +305,43 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} catch (final EmptyResultDataAccessException e) {
throw new StaffNotFoundException(cashierId);
}
- }
+ }
- @Override
- public Collection getCashierData(Long officeId, Long tellerId,
- Long staffId, Date date) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Collection getCashierData(Long officeId, Long tellerId, Long staffId, Date date) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public Collection getTellerCashiers(Long tellerId, Date date) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Collection getTellerCashiers(Long tellerId, Date date) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public TellerTransactionData findTellerTransaction(Long transactionId) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public TellerTransactionData findTellerTransaction(Long transactionId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public Collection fetchTellerTransactionsByTellerId(
- Long tellerId, Date fromDate, Date toDate) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Collection fetchTellerTransactionsByTellerId(Long tellerId, Date fromDate, Date toDate) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public Collection getJournals(Long officeId,
- Long tellerId, Long cashierId, Date dateFrom, Date dateTo) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public Collection getJournals(Long officeId, Long tellerId, Long cashierId, Date dateFrom, Date dateTo) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public Collection fetchTellerJournals(Long tellerId,
- Long cashierId, Date fromDate, Date toDate) {
- // TODO Auto-generated method stub
- return null;
- }
-
+ @Override
+ public Collection 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 retrieveAllTellers(final boolean includeAllTellers) {
@@ -364,22 +359,21 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
return this.jdbcTemplate.query(sql, tm, new Object[] { hierarchySearchString });
}
- @Override
- public CashierData retrieveCashierTemplate(Long officeId, Long tellerId,
- boolean staffInSelectedOfficeOnly) {
- final Long defaultOfficeId = defaultToUsersOfficeIfNull(officeId);
-
- final OfficeData officeData = this.officeReadPlatformService.retrieveOffice(defaultOfficeId);
- String officeName = "";
- if (officeData != null) {
- officeName = officeData.name();
- }
-
- TellerData tellerData = findTeller(tellerId);
- String tellerName = "";
- if (tellerData != null) {
- tellerName = tellerData.getName();
- }
+ @Override
+ public CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly) {
+ final Long defaultOfficeId = defaultToUsersOfficeIfNull(officeId);
+
+ final OfficeData officeData = this.officeReadPlatformService.retrieveOffice(defaultOfficeId);
+ String officeName = "";
+ if (officeData != null) {
+ officeName = officeData.name();
+ }
+
+ TellerData tellerData = findTeller(tellerId);
+ String tellerName = "";
+ if (tellerData != null) {
+ tellerName = tellerData.getName();
+ }
final Collection offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
@@ -396,43 +390,43 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
staffOptions = null;
}
- return CashierData.template(officeId, officeName,
- 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 CashierData.template(officeId, officeName, tellerId, tellerName, staffOptions);
+ }
- return CashierTransactionData.template(cashierId, tellerId, tellerName, officeId,
- officeName, cashierName, cashierData, startDate, endDate);
- }
-
- @Override
- public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary (
- final Long cashierId, final boolean includeAllTellers,
- final Date fromDate, final Date toDate) {
+ @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();
+ }
+ //Fetching all currency type from m_organisation_currency table
+ final Collection 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 String hierarchy = currentUser.getOffice().getHierarchy();
String hierarchySearchString = null;
@@ -441,61 +435,47 @@ 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 cashierTxnTypeTotals =
- this.jdbcTemplate.query(sql, ctsm, new Object[] {
- cashierId, hierarchySearchString,
- cashierId, hierarchySearchString,
- cashierId, hierarchySearchString });
-
+ Collection cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, new Object[] { cashierId,
+ hierarchySearchString, cashierId, hierarchySearchString, cashierId, hierarchySearchString });
+
Iterator itr = cashierTxnTypeTotals.iterator();
- BigDecimal allocAmount = new BigDecimal (0);
- BigDecimal cashInAmount = new BigDecimal (0);
- BigDecimal cashOutAmount = new BigDecimal (0);
- BigDecimal settleAmount = new BigDecimal (0);
-
- while(itr.hasNext()) {
- CashierTransactionTypeTotalsData total = itr.next();
- if (total != null) {
- if ( total.getCashierTxnType() == CashierTxnType.ALLOCATE.getId() ) {
- allocAmount = total.getCashTotal();
- } else if ( total.getCashierTxnType() == CashierTxnType.SETTLE.getId() ) {
- settleAmount = total.getCashTotal();
- } else if ( total.getCashierTxnType() == CashierTxnType.INWARD_CASH_TXN.getId() ) {
- cashInAmount = total.getCashTotal();
- } else if ( total.getCashierTxnType() == CashierTxnType.OUTWARD_CASH_TXN.getId() ) {
- cashOutAmount = total.getCashTotal();
- }
- }
+ BigDecimal allocAmount = new BigDecimal(0);
+ BigDecimal cashInAmount = new BigDecimal(0);
+ BigDecimal cashOutAmount = new BigDecimal(0);
+ BigDecimal settleAmount = new BigDecimal(0);
+
+ while (itr.hasNext()) {
+ CashierTransactionTypeTotalsData total = itr.next();
+ if (total != null) {
+ if (total.getCashierTxnType() == CashierTxnType.ALLOCATE.getId()) {
+ allocAmount = total.getCashTotal();
+ } else if (total.getCashierTxnType() == CashierTxnType.SETTLE.getId()) {
+ settleAmount = total.getCashTotal();
+ } else if (total.getCashierTxnType() == CashierTxnType.INWARD_CASH_TXN.getId()) {
+ cashInAmount = total.getCashTotal();
+ } else if (total.getCashierTxnType() == CashierTxnType.OUTWARD_CASH_TXN.getId()) {
+ cashOutAmount = total.getCashTotal();
+ }
+ }
}
-
- final Collection 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()
- );
+
+ final Collection 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());
return txnsWithSummary;
}
- @Override
- public Collection retrieveCashierTransactions (
- final Long cashierId, final boolean includeAllTellers,
- final Date fromDate, final Date toDate) {
+ @Override
+ public Collection 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();
String hierarchySearchString = null;
@@ -504,35 +484,28 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
} else {
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,
- new Object[] { cashierId, hierarchySearchString,
- cashierId, hierarchySearchString,
- cashierId, hierarchySearchString});
+ 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, new Object[] { cashierId, hierarchySearchString, cashierId, hierarchySearchString,
+ cashierId, hierarchySearchString });
}
- private static final class CashierMapper implements RowMapper {
+ private static final class CashierMapper implements RowMapper {
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.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 String staffName = rs.getString("staff_name");
final String description = rs.getString("description");
-
+
final LocalDate startDate = JdbcSupport.getLocalDate(rs, "start_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;
if (fullDayFromDB == 1) {
- fullDay = true;
+ fullDay = true;
}
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);
}
}
- private static final class CashierTransactionMapper implements RowMapper {
+ private static final class CashierTransactionMapper implements RowMapper {
public String cashierTxnSchema() {
-
- final StringBuilder sqlBuilder = new StringBuilder(400);
- sqlBuilder.append(" txn.id as txn_id, txn.cashier_id as cashier_id, ");
- 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(" 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 ");
+ final StringBuilder sqlBuilder = new StringBuilder(400);
+
+ sqlBuilder.append(" txn.id as txn_id, txn.cashier_id as cashier_id, ");
+ 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(" 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 ");
return sqlBuilder.toString();
}
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(" when renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge') ");
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(" else ");
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(" '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(" 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(" 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 ");
@@ -619,33 +595,36 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
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, ");
- sqlBuilder.append(" case ");
- sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') ");
- sqlBuilder.append(" then 103 ");
- sqlBuilder.append(" when renum.enum_value in ('Disbursement') ");
- sqlBuilder.append(" then 104 ");
- sqlBuilder.append(" else ");
- 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(" '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(" 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 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 ");
-
+ public String loansTxnSchema() {
+
+ final StringBuilder sqlBuilder = new StringBuilder(400);
+
+ sqlBuilder.append(" loan_txn.id as txn_id, c.id as cashier_id, ");
+ sqlBuilder.append(" case ");
+ sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') ");
+ sqlBuilder.append(" then 103 ");
+ sqlBuilder.append(" when renum.enum_value in ('Disbursement') ");
+ sqlBuilder.append(" then 104 ");
+ sqlBuilder.append(" else ");
+ 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(" '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(" 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 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();
}
@@ -662,65 +641,67 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final String entityType = rs.getString("entity_type");
final Long entityId = rs.getLong("entity_id");
final LocalDate createdLocalDate = JdbcSupport.getLocalDate(rs, "created_date");
-
+
Date txnDate = null;
if (txnLocalDate != null) {
- txnDate = txnLocalDate.toDate();
+ txnDate = txnLocalDate.toDate();
}
Date createdDate = null;
if (createdLocalDate != null) {
- createdDate = createdLocalDate.toDate();
+ createdDate = createdLocalDate.toDate();
}
-
+
final Long officeId = rs.getLong("office_id");
final String officeName = rs.getString("office_name");
final Long tellerId = rs.getLong("teller_id");
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);
+ 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);
}
}
-
- private static final class CashierTransactionSummaryMapper implements RowMapper {
+
+ private static final class CashierTransactionSummaryMapper implements RowMapper {
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(" (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_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(" 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(" 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(" 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(" 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(" (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(" when renum.enum_value in ('deposit','withdrawal fee', 'Pay Charge') ");
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(" else ");
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(" '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(" 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(" 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 ");
@@ -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_cashiers c on c.staff_id = staff.id ");
sqlBuilder.append(" where sav_txn.is_reversed = 0 and c.id = ? ");
- 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(" and o.hierarchy like ? and ");
+ sqlBuilder.append(" created_date between c.start_date and date_add(c.end_date, interval 1 day) ");
sqlBuilder.append(" ) ");
- sqlBuilder.append(" UNION ");
+ sqlBuilder.append(" UNION ");
sqlBuilder.append(" ( ");
- sqlBuilder.append(" select loan_txn.id as txn_id, c.id as cashier_id, ");
- sqlBuilder.append(" case ");
- sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') ");
- sqlBuilder.append(" then 103 ");
- sqlBuilder.append(" when renum.enum_value in ('Disbursement') ");
- sqlBuilder.append(" then 104 ");
- sqlBuilder.append(" else ");
- 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(" '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(" 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 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 ");
- 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(" select loan_txn.id as txn_id, c.id as cashier_id, ");
+ sqlBuilder.append(" case ");
+ sqlBuilder.append(" when renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment') ");
+ sqlBuilder.append(" then 103 ");
+ sqlBuilder.append(" when renum.enum_value in ('Disbursement') ");
+ sqlBuilder.append(" then 104 ");
+ sqlBuilder.append(" else ");
+ 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(" '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(" 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 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 ");
+ 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(" ) txns ");
sqlBuilder.append(" group by cash_txn_type ");
-
+
return sqlBuilder.toString();
}
@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");
-
- return CashierTransactionTypeTotalsData.instance(
- cashierTxnType, txnTotal);
+
+ return CashierTransactionTypeTotalsData.instance(cashierTxnType, txnTotal);
}
}
-
}
\ No newline at end of file
diff --git a/mifosng-provider/src/main/resources/sql/migrations/core_db/V231__m_cashier_transaction_added_currency_code.sql b/mifosng-provider/src/main/resources/sql/migrations/core_db/V231__m_cashier_transaction_added_currency_code.sql
new file mode 100644
index 000000000..10cbd2420
--- /dev/null
+++ b/mifosng-provider/src/main/resources/sql/migrations/core_db/V231__m_cashier_transaction_added_currency_code.sql
@@ -0,0 +1 @@
+ALTER TABLE `m_cashier_transactions` ADD COLUMN `currency_code` VARCHAR(3) NULL AFTER `txn_note`;
\ No newline at end of file