teller-cashier management with currency
This commit is contained in:
+4
@@ -60,4 +60,8 @@ public class OfficeData implements Serializable {
|
|||||||
public String name() {
|
public String name() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHierarchy() {
|
||||||
|
return this.hierarchy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+5
-1
@@ -84,6 +84,10 @@ public class StaffData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getJoiningDate() {
|
public LocalDate getJoiningDate() {
|
||||||
return this.joiningDate;
|
return this.joiningDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getOfficeId() {
|
||||||
|
return this.officeId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+6
-5
@@ -233,15 +233,16 @@ public class TellerApiResource {
|
|||||||
@Path("{tellerId}/cashiers/{cashierId}/transactions")
|
@Path("{tellerId}/cashiers/{cashierId}/transactions")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces(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,
|
||||||
|
@QueryParam("currencyCode") final String currencyCode) {
|
||||||
final TellerData teller = this.readPlatformService.findTeller(tellerId);
|
final TellerData teller = this.readPlatformService.findTeller(tellerId);
|
||||||
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
|
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
|
||||||
|
|
||||||
final Date fromDate = null;
|
final Date fromDate = null;
|
||||||
final Date toDate = null;
|
final Date toDate = null;
|
||||||
|
|
||||||
final Collection<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, true,
|
final Collection<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, false,
|
||||||
fromDate, toDate);
|
fromDate, toDate, currencyCode);
|
||||||
|
|
||||||
return this.jsonSerializer.serialize(cashierTxns);
|
return this.jsonSerializer.serialize(cashierTxns);
|
||||||
}
|
}
|
||||||
@@ -251,7 +252,7 @@ public class TellerApiResource {
|
|||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public String getTransactionsWtihSummaryForCashier(@PathParam("tellerId") final Long tellerId,
|
public String getTransactionsWtihSummaryForCashier(@PathParam("tellerId") final Long tellerId,
|
||||||
@PathParam("cashierId") final Long cashierId) {
|
@PathParam("cashierId") final Long cashierId, @QueryParam("currencyCode") final String currencyCode) {
|
||||||
final TellerData teller = this.readPlatformService.findTeller(tellerId);
|
final TellerData teller = this.readPlatformService.findTeller(tellerId);
|
||||||
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
|
final CashierData cashier = this.readPlatformService.findCashier(cashierId);
|
||||||
|
|
||||||
@@ -259,7 +260,7 @@ public class TellerApiResource {
|
|||||||
final Date toDate = null;
|
final Date toDate = null;
|
||||||
|
|
||||||
final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.readPlatformService.retrieveCashierTransactionsWithSummary(
|
final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.readPlatformService.retrieveCashierTransactionsWithSummary(
|
||||||
cashierId, true, fromDate, toDate);
|
cashierId, false, fromDate, toDate, currencyCode);
|
||||||
|
|
||||||
return this.jsonSerializer.serialize(cashierTxnWithSummary);
|
return this.jsonSerializer.serialize(cashierTxnWithSummary);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-8
@@ -27,7 +27,7 @@ public interface TellerManagementReadPlatformService {
|
|||||||
|
|
||||||
public Collection<CashierData> getTellerCashiers(Long tellerId, Date date);
|
public Collection<CashierData> getTellerCashiers(Long tellerId, Date date);
|
||||||
|
|
||||||
public CashierData retrieveCashierTemplate (Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly);
|
public CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly);
|
||||||
|
|
||||||
public CashierTransactionData retrieveCashierTxnTemplate(Long cashierId);
|
public CashierTransactionData retrieveCashierTxnTemplate(Long cashierId);
|
||||||
|
|
||||||
@@ -45,14 +45,12 @@ public interface TellerManagementReadPlatformService {
|
|||||||
|
|
||||||
public Collection<CashierData> getCashiersForTeller(Long tellerId, Date fromDate, Date toDate);
|
public Collection<CashierData> getCashiersForTeller(Long tellerId, Date fromDate, Date toDate);
|
||||||
|
|
||||||
public Collection<CashierData> retrieveCashiersForTellers(String sqlSearch,
|
public Collection<CashierData> retrieveCashiersForTellers(String sqlSearch, Long tellerId);
|
||||||
Long tellerId);
|
|
||||||
|
|
||||||
public Collection<CashierTransactionData> retrieveCashierTransactions(
|
public Collection<CashierTransactionData> retrieveCashierTransactions(Long cashierId, boolean includeAllTellers, Date fromDate,
|
||||||
Long cashierId, boolean includeAllTellers, Date fromDate,
|
Date toDate, String currencyCode);
|
||||||
Date toDate);
|
|
||||||
|
|
||||||
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary (
|
public CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(Long cashierId, boolean includeAllTellers,
|
||||||
Long cashierId, boolean includeAllTellers, Date fromDate, Date toDate);
|
Date fromDate, Date toDate, String currencyCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-20
@@ -426,20 +426,24 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
|
|
||||||
@Override
|
@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 Date fromDate, final Date toDate, final String currencyCode) {
|
||||||
final AppUser currentUser = this.context.authenticatedUser();
|
CashierData cashierData = findCashier(cashierId);
|
||||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
Long staffId = cashierData.getStaffId();
|
||||||
|
StaffData staffData = staffReadPlatformService.retrieveStaff(staffId);
|
||||||
|
OfficeData officeData = officeReadPlatformService.retrieveOffice(staffData.getOfficeId());
|
||||||
|
final String hierarchy = officeData.getHierarchy();
|
||||||
String hierarchySearchString = null;
|
String hierarchySearchString = null;
|
||||||
if (includeAllTellers) {
|
if (includeAllTellers) {
|
||||||
hierarchySearchString = "." + "%";
|
hierarchySearchString = "." + "%";
|
||||||
} else {
|
} else {
|
||||||
hierarchySearchString = hierarchy + "%";
|
hierarchySearchString = hierarchy;
|
||||||
}
|
}
|
||||||
final CashierTransactionSummaryMapper ctsm = new CashierTransactionSummaryMapper();
|
final CashierTransactionSummaryMapper ctsm = new CashierTransactionSummaryMapper();
|
||||||
final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000";
|
final String sql = "select " + ctsm.cashierTxnSummarySchema() + " limit 1000";
|
||||||
|
|
||||||
Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, new Object[] { cashierId,
|
Collection<CashierTransactionTypeTotalsData> cashierTxnTypeTotals = this.jdbcTemplate.query(sql, ctsm, new Object[] { cashierId,
|
||||||
hierarchySearchString, cashierId, hierarchySearchString, cashierId, hierarchySearchString });
|
currencyCode, hierarchySearchString, cashierId, currencyCode, hierarchySearchString, cashierId, currencyCode,
|
||||||
|
hierarchySearchString });
|
||||||
|
|
||||||
Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator();
|
Iterator<CashierTransactionTypeTotalsData> itr = cashierTxnTypeTotals.iterator();
|
||||||
BigDecimal allocAmount = new BigDecimal(0);
|
BigDecimal allocAmount = new BigDecimal(0);
|
||||||
@@ -463,7 +467,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Collection<CashierTransactionData> cashierTransactions = retrieveCashierTransactions(cashierId, includeAllTellers, fromDate,
|
final Collection<CashierTransactionData> cashierTransactions = retrieveCashierTransactions(cashierId, includeAllTellers, fromDate,
|
||||||
toDate);
|
toDate, currencyCode);
|
||||||
|
|
||||||
CashierTransactionData cashierTxnTemplate = retrieveCashierTxnTemplate(cashierId);
|
CashierTransactionData cashierTxnTemplate = retrieveCashierTxnTemplate(cashierId);
|
||||||
|
|
||||||
@@ -475,30 +479,35 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
|
|
||||||
@Override
|
@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 Date fromDate, final Date toDate, final String currencyCode) {
|
||||||
final AppUser currentUser = this.context.authenticatedUser();
|
CashierData cashierData = findCashier(cashierId);
|
||||||
final String hierarchy = currentUser.getOffice().getHierarchy();
|
Long staffId = cashierData.getStaffId();
|
||||||
|
StaffData staffData = staffReadPlatformService.retrieveStaff(staffId);
|
||||||
|
OfficeData officeData = officeReadPlatformService.retrieveOffice(staffData.getOfficeId());
|
||||||
|
final String hierarchy = officeData.getHierarchy();
|
||||||
String hierarchySearchString = null;
|
String hierarchySearchString = null;
|
||||||
if (includeAllTellers) {
|
if (includeAllTellers) {
|
||||||
hierarchySearchString = "." + "%";
|
hierarchySearchString = "." + "%";
|
||||||
} else {
|
} else {
|
||||||
hierarchySearchString = hierarchy + "%";
|
hierarchySearchString = hierarchy;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CashierTransactionMapper ctm = new CashierTransactionMapper();
|
final CashierTransactionMapper ctm = new CashierTransactionMapper();
|
||||||
|
|
||||||
final String sql = "select * from (select " + ctm.cashierTxnSchema()
|
final String sql = "select * from (select " + ctm.cashierTxnSchema()
|
||||||
+ " where txn.cashier_id = ? and o.hierarchy like ? ) cashier_txns " + " union (select " + ctm.savingsTxnSchema()
|
+ " where txn.cashier_id = ? and txn.currency_code = ? and o.hierarchy like ? ) cashier_txns " + " union (select "
|
||||||
+ " where sav_txn.is_reversed = 0 and c.id = ? and o.hierarchy like ? and "
|
+ ctm.savingsTxnSchema()
|
||||||
+ " created_date between c.start_date and date_add(c.end_date, interval 1 day) "
|
+ " where sav_txn.is_reversed = 0 and c.id = ? and sav.currency_code = ? and o.hierarchy like ? and "
|
||||||
|
+ " sav_txn.transaction_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 "
|
+ " 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 "
|
+ ctm.loansTxnSchema()
|
||||||
+ " created_date between c.start_date and date_add(c.end_date, interval 1 day) "
|
+ " where loan_txn.is_reversed = 0 and c.id = ? and loan.currency_code = ? and o.hierarchy like ? and "
|
||||||
|
+ " loan_txn.transaction_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') ) "
|
+ " and renum.enum_value in ('Repayment At Disbursement','Repayment', 'Recovery Payment','Disbursement') ) "
|
||||||
+ " order by created_date ";
|
+ " 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, currencyCode, hierarchySearchString, cashierId, currencyCode,
|
||||||
cashierId, hierarchySearchString });
|
hierarchySearchString, cashierId, currencyCode, hierarchySearchString });
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class CashierMapper implements RowMapper<CashierData> {
|
private static final class CashierMapper implements RowMapper<CashierData> {
|
||||||
@@ -682,6 +691,7 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
sqlBuilder.append(" left join m_office o on o.id = t.office_id ");
|
sqlBuilder.append(" left join m_office o on o.id = t.office_id ");
|
||||||
sqlBuilder.append(" left join m_staff s on s.id = c.staff_id ");
|
sqlBuilder.append(" left join m_staff s on s.id = c.staff_id ");
|
||||||
sqlBuilder.append(" where txn.cashier_id = ? ");
|
sqlBuilder.append(" where txn.cashier_id = ? ");
|
||||||
|
sqlBuilder.append(" and txn.currency_code = ? ");
|
||||||
sqlBuilder.append(" and o.hierarchy like ? ) cashier_txns ");
|
sqlBuilder.append(" and o.hierarchy like ? ) cashier_txns ");
|
||||||
sqlBuilder.append(" UNION ");
|
sqlBuilder.append(" UNION ");
|
||||||
sqlBuilder.append(" (select sav_txn.id as txn_id, c.id as cashier_id, ");
|
sqlBuilder.append(" (select sav_txn.id as txn_id, c.id as cashier_id, ");
|
||||||
@@ -709,8 +719,9 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
|
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
|
||||||
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
|
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
|
||||||
sqlBuilder.append(" where sav_txn.is_reversed = 0 and c.id = ? ");
|
sqlBuilder.append(" where sav_txn.is_reversed = 0 and c.id = ? ");
|
||||||
sqlBuilder.append(" and o.hierarchy like ? and ");
|
sqlBuilder.append(" and sav.currency_code = ? ");
|
||||||
sqlBuilder.append(" created_date between c.start_date and date_add(c.end_date, interval 1 day) ");
|
sqlBuilder.append(" and o.hierarchy like ? ");
|
||||||
|
sqlBuilder.append(" and sav_txn.transaction_date between c.start_date and date_add(c.end_date, interval 1 day) ");
|
||||||
sqlBuilder.append(" ) ");
|
sqlBuilder.append(" ) ");
|
||||||
sqlBuilder.append(" UNION ");
|
sqlBuilder.append(" UNION ");
|
||||||
sqlBuilder.append(" ( ");
|
sqlBuilder.append(" ( ");
|
||||||
@@ -739,8 +750,9 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
|
sqlBuilder.append(" left join m_staff staff on user.staff_id = staff.id ");
|
||||||
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
|
sqlBuilder.append(" left join m_cashiers c on c.staff_id = staff.id ");
|
||||||
sqlBuilder.append(" where loan_txn.is_reversed = 0 and c.id = ? ");
|
sqlBuilder.append(" where loan_txn.is_reversed = 0 and c.id = ? ");
|
||||||
|
sqlBuilder.append(" and loan.currency_code = ? ");
|
||||||
sqlBuilder.append(" and o.hierarchy like ? ");
|
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(" and loan_txn.transaction_date between c.start_date and date_add(c.end_date, interval 1 day) ");
|
||||||
sqlBuilder.append(" ) ");
|
sqlBuilder.append(" ) ");
|
||||||
sqlBuilder.append(" ) txns ");
|
sqlBuilder.append(" ) txns ");
|
||||||
sqlBuilder.append(" group by cash_txn_type ");
|
sqlBuilder.append(" group by cash_txn_type ");
|
||||||
|
|||||||
Reference in New Issue
Block a user