fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-reporting] 12/24: Teller, Loan skeleton, Tellerlisting query update
Date Mon, 22 Jan 2018 15:31:09 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-reporting.git

commit da105ea97c8a43e78be918ce8d889fe1e602ee3f
Author: Awasum Yannick <awasum.yannick@skylabase.com>
AuthorDate: Fri Aug 25 17:17:19 2017 +0100

    Teller, Loan skeleton, Tellerlisting query update
---
 ...InactiveCustomerAccountReportSpecification.java |  24 ---
 .../LoanListingReportSpecification.java            |  51 ++++++
 .../SavingListReportSpecification.java             |   2 +-
 ...llerCashierDailyBalanceReportSpecification.java |  72 +++++++++
 .../TellerListingReportSpecification.java          | 172 +++++++++++++++++++++
 5 files changed, 296 insertions(+), 25 deletions(-)

diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/InactiveCustomerAccountReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/InactiveCustomerAccountReportSpecification.java
deleted file mode 100644
index 148743b..0000000
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/InactiveCustomerAccountReportSpecification.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package io.mifos.reporting.service.internal.specification;
-
-import io.mifos.reporting.api.v1.domain.ReportDefinition;
-import io.mifos.reporting.api.v1.domain.ReportPage;
-import io.mifos.reporting.api.v1.domain.ReportRequest;
-import io.mifos.reporting.service.spi.Report;
-import io.mifos.reporting.service.spi.ReportSpecification;
-@Report(category = "Customer", identifier = "Inactive")
-public class InactiveCustomerAccountReportSpecification implements ReportSpecification {
-    @Override
-    public ReportDefinition getReportDefinition() {
-        return null;
-    }
-
-    @Override
-    public ReportPage generateReport(ReportRequest reportRequest, int pageIndex, int size)
{
-        return null;
-    }
-
-    @Override
-    public void validate(ReportRequest reportRequest) throws IllegalArgumentException {
-
-    }
-}
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListingReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListingReportSpecification.java
new file mode 100644
index 0000000..d90dd75
--- /dev/null
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/LoanListingReportSpecification.java
@@ -0,0 +1,51 @@
+package io.mifos.reporting.service.internal.specification;
+
+import io.mifos.reporting.api.v1.domain.ReportDefinition;
+import io.mifos.reporting.api.v1.domain.ReportPage;
+import io.mifos.reporting.api.v1.domain.ReportRequest;
+import io.mifos.reporting.service.ServiceConstants;
+import io.mifos.reporting.service.spi.Report;
+import io.mifos.reporting.service.spi.ReportSpecification;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+import javax.persistence.EntityManager;
+
+@Report(category = "Loan", identifier = "Listing")
+public class LoanListingReportSpecification implements ReportSpecification {
+
+    private static final String TOTAL_CASH_ON_HAND = "Cash on hand";
+
+
+    private final Logger logger;
+
+    private final EntityManager entityManager;
+
+    @Autowired
+    public LoanListingReportSpecification(@Qualifier(ServiceConstants.LOGGER_NAME) final
Logger logger,
+                                                        final EntityManager entityManager)
{
+        super();
+        this.logger = logger;
+        this.entityManager = entityManager;
+        this.initializeMapping();
+    }
+
+    private void initializeMapping() {
+    }
+
+    @Override
+    public ReportDefinition getReportDefinition() {
+        return null;
+    }
+
+    @Override
+    public ReportPage generateReport(ReportRequest reportRequest, int pageIndex, int size)
{
+        return null;
+    }
+
+    @Override
+    public void validate(ReportRequest reportRequest) throws IllegalArgumentException {
+
+    }
+}
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/SavingListReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/SavingListReportSpecification.java
index 1e8ccbe..a7f8e08 100644
--- a/service/src/main/java/io/mifos/reporting/service/internal/specification/SavingListReportSpecification.java
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/SavingListReportSpecification.java
@@ -246,7 +246,7 @@ public class SavingListReportSpecification implements ReportSpecification
{
             final Value lastActivityValue = new Value();
             lastActivityValue.setValues(val.toArray(new String[values.size()]));
             row.getValues().add(lastActivityValue);
-            
+
             rows.add(row);
         });
 
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerCashierDailyBalanceReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerCashierDailyBalanceReportSpecification.java
new file mode 100644
index 0000000..591351e
--- /dev/null
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerCashierDailyBalanceReportSpecification.java
@@ -0,0 +1,72 @@
+package io.mifos.reporting.service.internal.specification;
+
+import io.mifos.reporting.api.v1.domain.*;
+import io.mifos.reporting.service.ServiceConstants;
+import io.mifos.reporting.service.spi.Report;
+import io.mifos.reporting.service.spi.ReportSpecification;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+import javax.persistence.EntityManager;
+import java.util.List;
+
+@Report(category = "Teller" , identifier = "Transaction")
+public class TellerCashierDailyBalanceReportSpecification implements ReportSpecification
{
+
+    private static final String TOTAL_CASH_ON_HAND = "Cash on hand";
+    private static final String TOTAL_CASH_RECEIVED = "Cash received";
+    private static final String TOTAL_CASH_DISBURSED = "Cash Disbursed";
+    private static final String TOTAL_NEGOTIABLE_INSTRUMENT_RECEIVED = "Negotiable instrument
received";
+    private static final String TOTAL_CHEQUES_RECEIVED = "Total cheques received";
+    private static final String TELLER = "Teller";
+    private static final String EMPLOYEE = "Employee";
+    private static final String OFFICE = "Office";
+    private static final String CASHDRAW_LIMIT = "Cashdraw limit";
+
+    private final Logger logger;
+
+    private final EntityManager entityManager;
+
+    @Autowired
+    public TellerCashierDailyBalanceReportSpecification(@Qualifier(ServiceConstants.LOGGER_NAME)
final Logger logger,
+                                           final EntityManager entityManager) {
+        super();
+        this.logger = logger;
+        this.entityManager = entityManager;
+        this.initializeMapping();
+    }
+
+    private void initializeMapping() {
+    }
+
+    @Override
+    public ReportDefinition getReportDefinition() {
+        final ReportDefinition reportDefinition = new ReportDefinition();
+        reportDefinition.setIdentifier("Transactions");
+        reportDefinition.setName("Teller transactions");
+        reportDefinition.setDescription("List total teller/cashier transactions.");
+        reportDefinition.setQueryParameters(this.buildQueryParameters());
+        reportDefinition.setDisplayableFields(this.buildDisplayableFields());
+        return reportDefinition;
+    }
+
+    private List<DisplayableField> buildDisplayableFields() {
+        return null;
+    }
+
+    private List<QueryParameter> buildQueryParameters() {
+
+        return null;
+    }
+
+    @Override
+    public ReportPage generateReport(ReportRequest reportRequest, int pageIndex, int size)
{
+        return null;
+    }
+
+    @Override
+    public void validate(ReportRequest reportRequest) throws IllegalArgumentException {
+
+    }
+}
diff --git a/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListingReportSpecification.java
b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListingReportSpecification.java
new file mode 100644
index 0000000..34af570
--- /dev/null
+++ b/service/src/main/java/io/mifos/reporting/service/internal/specification/TellerListingReportSpecification.java
@@ -0,0 +1,172 @@
+package io.mifos.reporting.service.internal.specification;
+
+import io.mifos.core.api.util.UserContextHolder;
+import io.mifos.core.lang.DateConverter;
+import io.mifos.reporting.api.v1.domain.*;
+import io.mifos.reporting.service.ServiceConstants;
+import io.mifos.reporting.service.spi.CriteriaBuilder;
+import io.mifos.reporting.service.spi.Report;
+import io.mifos.reporting.service.spi.ReportSpecification;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.time.Clock;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Report(category = "Teller" , identifier = "Listing")
+public class TellerListingReportSpecification implements ReportSpecification {
+
+   // private static final String TOTAL_CASH_ON_HAND = "Cash on hand";
+   // private static final String TOTAL_CASH_RECEIVED = "Cash received";
+   // private static final String TOTAL_CASH_DISBURSED = "Cash Disbursed";
+   // private static final String TOTAL_NEGOTIABLE_INSTRUMENT_RECEIVED = "Negotiable instrument
received";
+   // private static final String TOTAL_CHEQUES_RECEIVED = "Total cheques received";
+    private static final String TELLER = "Teller";
+    private static final String EMPLOYEE = "Employee";
+    private static final String OFFICE = "Office";
+    private static final String CASHDRAW_LIMIT = "Cashdraw limit";
+    private static final String STATE = "State";
+
+    private final Logger logger;
+
+    private final EntityManager entityManager;
+
+    private final HashMap<String, String> tellerColumnMapping = new HashMap<>();
+    private final HashMap<String, String> allColumnMapping = new HashMap<>();
+
+
+    @Autowired
+    public TellerListingReportSpecification(@Qualifier(ServiceConstants.LOGGER_NAME) final
Logger logger,
+                                                        final EntityManager entityManager)
{
+        super();
+        this.logger = logger;
+        this.entityManager = entityManager;
+        this.initializeMapping();
+    }
+
+    private void initializeMapping() {
+        this.tellerColumnMapping.put(TELLER, "tl.identifier");
+        this.tellerColumnMapping.put(OFFICE, "tl.office_identifier");
+        this.tellerColumnMapping.put(CASHDRAW_LIMIT, "tl.cashdraw_limit");
+        this.tellerColumnMapping.put(EMPLOYEE, "tl.assigned_employee_identifier");
+        this.tellerColumnMapping.put(STATE, "tl.a_state");
+
+        this.allColumnMapping.putAll(tellerColumnMapping);
+    }
+
+    @Override
+    public ReportDefinition getReportDefinition() {
+        final ReportDefinition reportDefinition = new ReportDefinition();
+        reportDefinition.setIdentifier("Listing");
+        reportDefinition.setName("Teller Listing");
+        reportDefinition.setDescription("List of all Tellers.");
+        reportDefinition.setQueryParameters(this.buildQueryParameters());
+        reportDefinition.setDisplayableFields(this.buildDisplayableFields());
+        return reportDefinition;
+    }
+
+    private List<DisplayableField> buildDisplayableFields() {
+        return null;
+    }
+
+    private List<QueryParameter> buildQueryParameters() {
+        return null;
+    }
+
+    @Override
+    public ReportPage generateReport(ReportRequest reportRequest, int pageIndex, int size)
{
+        final ReportDefinition reportDefinition = this.getReportDefinition();
+        this.logger.info("Generating report {0}.", reportDefinition.getIdentifier());
+
+        final ReportPage reportPage = new ReportPage();
+        reportPage.setName(reportDefinition.getName());
+        reportPage.setDescription(reportDefinition.getDescription());
+        reportPage.setHeader(this.createHeader(reportRequest.getDisplayableFields()));
+
+        final Query tellerQuery = this.entityManager.createNativeQuery(this.buildTellerQuery(reportRequest,
pageIndex, size));
+        final List<?> tellerResultList =  tellerQuery.getResultList();
+        reportPage.setRows(this.buildRows(reportRequest, tellerResultList));
+
+        reportPage.setHasMore(
+                !this.entityManager.createNativeQuery(this.buildTellerQuery(reportRequest,
pageIndex + 1, size))
+                        .getResultList().isEmpty()
+        );
+
+        reportPage.setGeneratedBy(UserContextHolder.checkedGetUser());
+        reportPage.setGeneratedOn(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
+        return reportPage;
+    }
+
+    private String buildTellerQuery(ReportRequest reportRequest, int pageIndex, int size)
{
+        final StringBuilder query = new StringBuilder("SELECT ");
+
+        final List<DisplayableField> displayableFields = reportRequest.getDisplayableFields();
+        final ArrayList<String> columns = new ArrayList<>();
+        displayableFields.forEach(displayableField -> {
+            final String column = this.tellerColumnMapping.get(displayableField.getName());
+            if (column != null) {
+                columns.add(column);
+            }
+        });
+
+        query.append(columns.stream().collect(Collectors.joining(", ")))
+                .append(" FROM ")
+                .append("tajet_teller tl ");
+
+        final List<QueryParameter> queryParameters = reportRequest.getQueryParameters();
+        if (!queryParameters.isEmpty()) {
+            final ArrayList<String> criteria = new ArrayList<>();
+            queryParameters.forEach(queryParameter -> {
+                if(queryParameter.getValue() != null && !queryParameter.getValue().isEmpty())
{
+                    criteria.add(
+                            CriteriaBuilder.buildCriteria(this.tellerColumnMapping.get(queryParameter.getName()),
queryParameter)
+                    );
+                }
+            });
+
+            if (!criteria.isEmpty()) {
+                query.append(" WHERE ");
+                query.append(criteria.stream().collect(Collectors.joining(" AND ")));
+            }
+
+        }
+        query.append(" ORDER BY tl.identifier");
+
+        query.append(" LIMIT ");
+        query.append(size);
+        if (pageIndex > 0) {
+            query.append(" OFFSET ");
+            query.append(size * pageIndex);
+        }
+
+        return query.toString();
+    }
+
+    private List<Row> buildRows(ReportRequest reportRequest, List<?> tellerResultList)
{
+    return null;
+    }
+
+    private Header createHeader(List<DisplayableField> displayableFields) {
+        final Header header = new Header();
+        header.setColumnNames(
+                displayableFields
+                        .stream()
+                        .map(DisplayableField::getName)
+                        .collect(Collectors.toList())
+        );
+        return header;
+    }
+
+    @Override
+    public void validate(ReportRequest reportRequest) throws IllegalArgumentException {
+
+    }
+    
+}

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message