galovics commented on code in PR #3881:
URL: https://github.com/apache/fineract/pull/3881#discussion_r1808340247


##########
fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java:
##########
@@ -801,8 +776,8 @@ public String cashierTxnSummarySchema() {
             sqlBuilder.append(" or acnttrans.to_loan_transaction_id = 
loan_txn.id) ");
             sqlBuilder.append("    where loan_txn.is_reversed = false and c.id 
= ? ");
             sqlBuilder.append(" and loan.currency_code = ? ");
-            sqlBuilder.append("    and o.hierarchy like ? ");
-            sqlBuilder.append("    and loan_txn.transaction_date between 
c.start_date and date_add(c.end_date, interval 1 day) ");
+            // sqlBuilder.append(" and o.hierarchy like ? ");

Review Comment:
   Same as above.



##########
fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java:
##########
@@ -762,8 +737,8 @@ public String cashierTxnSummarySchema() {
             sqlBuilder.append(" or acnttrans.to_savings_transaction_id = 
sav_txn.id) ");
             sqlBuilder.append("    where sav_txn.is_reversed = false and c.id 
= ? ");
             sqlBuilder.append(" and sav.currency_code = ? ");
-            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(" and o.hierarchy like ? ");

Review Comment:
   Same as above.



##########
fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java:
##########
@@ -707,29 +683,28 @@ public CashierTransactionData mapRow(final ResultSet rs, 
final int rowNum) throw
 
     private static final class CashierTransactionSummaryMapper implements 
RowMapper<CashierTransactionTypeTotalsData> {
 
-        public String cashierTxnSummarySchema() {
+        public String cashierTxnSummarySchema(String nextDay) {
 
             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("    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(" 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("  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 ");
+                    "  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 (( case when c.full_day then 
Date(txn.created_date) between c.start_date AND c.end_date ");
-            sqlBuilder.append(
-                    " else ( Date(txn.created_date) between c.start_date AND 
c.end_date) and  ( TIME(txn.created_date) between TIME(c.start_time) AND 
TIME(c.end_time))  end) or txn.txn_type = 101) ");
+            sqlBuilder.append(" AND ((  txn.created_date between c.start_date 
AND c.end_date ) or txn.txn_type = 101) ");
             sqlBuilder.append(" and   txn.currency_code = ? ");
-            sqlBuilder.append("    and o.hierarchy like ?  ) cashier_txns ");
+            // sqlBuilder.append(" and o.hierarchy like ? ");

Review Comment:
   Let's get rid of this commented line if it's not needed.



##########
integration-tests/src/test/java/org/apache/fineract/integrationtests/organization/teller/CashierTransactionsHelper.java:
##########
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests.organization.teller;
+
+import com.google.gson.Gson;
+import io.restassured.specification.RequestSpecification;
+import io.restassured.specification.ResponseSpecification;
+import java.util.HashMap;
+import java.util.Map;
+import 
org.apache.fineract.client.models.GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse;
+import 
org.apache.fineract.client.models.GetTellersTellerIdCashiersCashiersIdTransactionsResponse;
+import org.apache.fineract.integrationtests.client.IntegrationTest;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CashierTransactionsHelper extends IntegrationTest {
+
+    private final ResponseSpecification responseSpecification;
+    private final RequestSpecification requestSpecification;
+
+    private static final String CREATE_CASHIER_URL = 
"/fineract-provider/api/v1/tellers/1/cashiers";
+    private static final String CREATE_TELLER_URL = 
"/fineract-provider/api/v1/tellers";
+    private static final Logger LOG = 
LoggerFactory.getLogger(CashierTransactionsHelper.class);
+
+    public CashierTransactionsHelper(final RequestSpecification 
requestSpecification, final ResponseSpecification responseSpecification) {
+        this.requestSpecification = requestSpecification;
+        this.responseSpecification = responseSpecification;
+    }
+
+    public GetTellersTellerIdCashiersCashiersIdTransactionsResponse 
getTellersTellerIdCashiersCashiersIdTransactionsResponse(Long tellerId,
+            Long cashierId, String currencyCode, int offset, int limit, String 
orderBy, String sortOrder) {
+        return ok(fineract().tellers.getTransactionsForCashier(tellerId, 
cashierId, currencyCode, offset, limit, orderBy, sortOrder));
+    }
+
+    public GetTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse 
getTellersTellerIdCashiersCashiersIdSummaryAndTransactionsResponse(
+            Long tellerId, Long cashierId, String currencyCode, int offset, 
int limit, String orderBy, String sortOrder) {
+        return 
ok(fineract().tellers.getTransactionsWithSummaryForCashier(tellerId, cashierId, 
currencyCode, offset, limit, orderBy,
+                sortOrder));
+    }
+
+    public static Integer createTeller(final RequestSpecification requestSpec, 
final ResponseSpecification responseSpec) {
+        return (Integer) createTellerWithJson(requestSpec, responseSpec, 
createTellerAsJSON()).get("resourceId");
+    }
+
+    public static Map<String, Object> createTellerWithJson(final 
RequestSpecification requestSpec, final ResponseSpecification responseSpec,
+            final String json) {
+
+        final String url = CREATE_TELLER_URL + "?" + Utils.TENANT_IDENTIFIER;
+        return Utils.performServerPost(requestSpec, responseSpec, url, json, 
"");
+    }
+
+    public static String createTellerAsJSON() {
+
+        final Map<String, Object> map = getMapWithStartDate();
+
+        map.put("officeId", 1);
+        map.put("name", Utils.uniqueRandomStringGenerator("Teller 1", 5));
+        map.put("description", Utils.uniqueRandomStringGenerator("Teller For 
Testing", 4));
+        map.put("status", 300);
+
+        LOG.info("map :  {}", map);
+        return new Gson().toJson(map);
+    }
+
+    public static Map<String, Object> getMapWithStartDate() {
+        HashMap<String, Object> map = new HashMap<>();
+
+        map.put("locale", "en");
+        map.put("dateFormat", "dd MMMM yyyy");
+        map.put("startDate", "20 September 2011");
+
+        return map;
+    }
+
+    public static Integer createCashier(final RequestSpecification 
requestSpec, final ResponseSpecification responseSpec) {
+        return (Integer) createCashierWithJson(requestSpec, responseSpec, 
createCashierAsJSON()).get("resourceId");
+    }
+
+    public static Map<String, Object> createCashierWithJson(final 
RequestSpecification requestSpec,
+            final ResponseSpecification responseSpec, final String json) {
+        final String url = CREATE_CASHIER_URL + "?" + Utils.TENANT_IDENTIFIER;
+        return Utils.performServerPost(requestSpec, responseSpec, url, json, 
"");

Review Comment:
   Don't we have generated APIs for the create APIs?



##########
fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java:
##########
@@ -828,15 +803,15 @@ public String cashierTxnSummarySchema() {
                     "    left join r_enum_value renum ON 
cli_txn.transaction_type_enum = renum.enum_id AND renum.enum_name = 
'client_transaction_type_enum' ");
             sqlBuilder.append("    left join m_client cl ON cli_txn.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 
cli_txn.created_by = user.id ");
-            sqlBuilder.append("    left join m_staff staff ON user.staff_id = 
staff.id ");
+            sqlBuilder.append("    left join m_appuser user_ ON 
cli_txn.created_by = 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(" left join m_payment_detail payDetails on 
payDetails.id = cli_txn.payment_detail_id ");
             sqlBuilder.append(" left join m_payment_type payType on payType.id 
= payDetails.payment_type_id ");
             sqlBuilder.append("    where cli_txn.is_reversed = false AND c.id 
= ?    ");
             sqlBuilder.append(" and cli_txn.currency_code = ? ");
-            sqlBuilder.append("    and o.hierarchy LIKE ? ");
-            sqlBuilder.append("    and cli_txn.transaction_date between 
c.start_date and date_add(c.end_date, interval 1 day) ");
+            // sqlBuilder.append(" and o.hierarchy LIKE ? ");

Review Comment:
   Same as above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to