From adffb399b1fdbb23da9ebe55bda285f0c408ccd1 Mon Sep 17 00:00:00 2001 From: AJITHKUMAR12 <48044092+AJITHKUMAR12@users.noreply.github.com> Date: Wed, 16 Sep 2026 12:56:55 +0530 Subject: [PATCH] Implemented communtiy hall revenue report --- .../configuration/DataSourceConfig.java | 12 +- .../controller/CommunityHallController.java | 7 + .../controller/MainController.java | 4 + .../service/CommunityHallService.java | 341 +++++++ .../templates/modules/communityrevenue.html | 916 ++++++++++++++++++ 5 files changed, 1274 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/templates/modules/communityrevenue.html diff --git a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java index 9d155d2..e41a056 100644 --- a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java +++ b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java @@ -17,8 +17,8 @@ import org.springframework.transaction.annotation.EnableTransactionManagement; @EnableTransactionManagement public class DataSourceConfig { -// private static String host = "localhost:3306"; -// private static String dbpassword = "root"; + //private static String host = "localhost:3306"; + //private static String dbpassword = "root"; private static String host = "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; private static String dbpassword = "gcc-facial-password"; @@ -233,8 +233,8 @@ public class DataSourceConfig { dataSource.setPassword(dbpassword); return dataSource; } - - //////////RoadWar ////////////////////// + + ////////// RoadWar ////////////////////// @Bean(name = "mysqlRoadWarDataSource") public DataSource mysqlRoadWarDataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); @@ -289,7 +289,7 @@ public class DataSourceConfig { dataSource.setPassword(dbpassword); return dataSource; } - + /////////////// Shelter Inspection ///////////////////// @Bean(name = "mysqlShelterinspectionDataSource") public DataSource mysqlShelterinspectionDataSource() { @@ -300,7 +300,7 @@ public class DataSourceConfig { dataSource.setPassword(dbpassword); return dataSource; } - + ////////////////////////////// For Shelter //////////////////////// @Bean(name = "mysqlShelterDataSource") public DataSource mysqlShelterDataSource() { diff --git a/src/main/java/com/gcc/commissionerreview/controller/CommunityHallController.java b/src/main/java/com/gcc/commissionerreview/controller/CommunityHallController.java index 7dfa40c..fc6e8eb 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/CommunityHallController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/CommunityHallController.java @@ -104,5 +104,12 @@ public class CommunityHallController { region, status); } + @GetMapping("/refund-summary-report") +public List> getRefundSummaryReport( + @RequestParam String reportDate) { + + // System.out.println("reportDate"+reportDate); + return communityHallService.getRefundSummaryReport(reportDate); +} } diff --git a/src/main/java/com/gcc/commissionerreview/controller/MainController.java b/src/main/java/com/gcc/commissionerreview/controller/MainController.java index 4f1a105..1a1c4c0 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/MainController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/MainController.java @@ -419,5 +419,9 @@ public class MainController { public String ResuceList() { return "modules/shelterinspection/resucelist"; } + @GetMapping("/communityhallrevenue") + public String Revenue() { + return "modules/communityrevenue"; + } } diff --git a/src/main/java/com/gcc/commissionerreview/service/CommunityHallService.java b/src/main/java/com/gcc/commissionerreview/service/CommunityHallService.java index 6397f17..57bde74 100644 --- a/src/main/java/com/gcc/commissionerreview/service/CommunityHallService.java +++ b/src/main/java/com/gcc/commissionerreview/service/CommunityHallService.java @@ -723,4 +723,345 @@ public class CommunityHallService { sql.toString(), params.toArray()); } + public List> getRefundSummaryReport( + String reportDate) { + + String sql = """ + + SELECT + hd.hall_id, + hd.hall_name, + + /* ========================================================= + 1. TOTAL BOOKINGS / AMOUNT RECEIVED / DEPOSIT RECEIVED + ========================================================= */ + + COUNT( + CASE + WHEN bd.booking_status NOT IN ( + 'PENDING', + 'GCC_UNBLOCKED', + 'REFUNDED' + ) + AND bd.booking_status != 'GCC_BLOCKED' + AND bd.amount_received != 0 + THEN bd.booking_id + END + ) AS TotalBookingCount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status NOT IN ( + 'PENDING', + 'GCC_UNBLOCKED', + 'REFUNDED' + ) + AND bd.booking_status != 'GCC_BLOCKED' + AND bd.amount_received != 0 + THEN bd.amount_received + ELSE 0 + END + ), + 0 + ), + 2 + ) AS TotalAmountReceived, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status NOT IN ( + 'PENDING', + 'GCC_UNBLOCKED', + 'REFUNDED' + ) + AND bd.booking_status != 'GCC_BLOCKED' + AND bd.amount_received != 0 + THEN bd.deposit_amount + ELSE 0 + END + ), + 0 + ), + 2 + ) AS DepositAmountReceived, + + + /* ========================================================= + 2. REFUND DETAILS + ========================================================= */ + + SUM( + CASE + WHEN bd.booking_status IN ( + 'APPROVED', + 'COMPLETED', + 'CANCELED', + 'REJECTED' + ) + AND bd.refund_status = 'COMPLETED' + THEN 1 + ELSE 0 + END + ) AS TotalRefundedCount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status IN ( + 'APPROVED', + 'COMPLETED' + ) + AND bd.refund_status = 'COMPLETED' + THEN COALESCE(s.refunded_amount, 0) + ELSE 0 + END + ), + 0 + ), + 2 + ) AS RefundAmount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status = 'CANCELED' + AND bd.refund_status = 'COMPLETED' + THEN bd.deposit_amount + ELSE 0 + END + ), + 0 + ), + 2 + ) AS RefundedDepositAmount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status = 'REJECTED' + AND bd.refund_status = 'COMPLETED' + THEN bd.amount_received + ELSE 0 + END + ), + 0 + ), + 2 + ) AS RejectedRefundAmount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status IN ( + 'APPROVED', + 'COMPLETED' + ) + AND bd.refund_status = 'COMPLETED' + THEN COALESCE(s.refunded_amount, 0) + + WHEN bd.booking_status = 'CANCELED' + AND bd.refund_status = 'COMPLETED' + THEN bd.deposit_amount + + WHEN bd.booking_status = 'REJECTED' + AND bd.refund_status = 'COMPLETED' + THEN bd.amount_received + + ELSE 0 + END + ), + 0 + ), + 2 + ) AS TotalRefundAmount, + + + /* ========================================================= + 3. EB READING NOT ENTERED + ========================================================= */ + + COUNT( + CASE + WHEN bd.booking_status NOT IN ( + 'PENDING', + 'GCC_UNBLOCKED', + 'WAITING_FOR_NOC', + 'WAITING_FOR_NOC_APPROVAL' + ) + AND bd.booking_status != 'GCC_BLOCKED' + AND bd.amount_received != 0 + AND eb.booking_details_booking_id IS NULL + THEN bd.booking_id + END + ) AS EBReadingNotEnteredCount, + + + /* ========================================================= + 4. SRO PENDING + APPROVED + EB EXISTS + SETTLEMENT NOT EXISTS + ========================================================= */ + + COUNT( + CASE + WHEN bd.booking_status = 'APPROVED' + AND bd.amount_received != 0 + AND eb.booking_details_booking_id IS NOT NULL + AND st.booking_details_booking_id IS NULL + THEN bd.booking_id + END + ) AS SROPendingCount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status = 'APPROVED' + AND bd.amount_received != 0 + AND eb.booking_details_booking_id IS NOT NULL + AND st.booking_details_booking_id IS NULL + THEN bd.deposit_amount - COALESCE(eb.eb_amount, 0) + ELSE 0 + END + ), + 0 + ), + 2 + ) AS SROPendingAmount, + + + /* ========================================================= + 5. USER CANCELLED - SRO PENDING + ========================================================= */ + + COUNT( + CASE + WHEN bd.booking_status = 'CANCELED' + AND bd.amount_received != 0 + AND st.booking_details_booking_id IS NULL + THEN bd.booking_id + END + ) AS UserCancelledSROPendingCount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status = 'CANCELED' + AND bd.amount_received != 0 + AND st.booking_details_booking_id IS NULL + THEN bd.deposit_amount + ELSE 0 + END + ), + 0 + ), + 2 + ) AS UserCancelledSROPendingAmount, + + + /* ========================================================= + 6. GCC BLOCKED + REJECTED - SRO PENDING + ========================================================= */ + + COUNT( + CASE + WHEN bd.booking_status IN ( + 'GCC_BLOCKED', + 'REJECTED' + ) + AND bd.amount_received != 0 + AND st.booking_details_booking_id IS NULL + THEN bd.booking_id + END + ) AS GCCBlockedRejectedSROPendingCount, + + ROUND( + COALESCE( + SUM( + CASE + WHEN bd.booking_status IN ( + 'GCC_BLOCKED', + 'REJECTED' + ) + AND bd.amount_received != 0 + AND st.booking_details_booking_id IS NULL + THEN bd.deposit_amount + ELSE 0 + END + ), + 0 + ), + 2 + ) AS GCCBlockedRejectedSROPendingAmount + + +FROM booking_details bd + +LEFT JOIN hall_details hd + ON bd.hall_details_hall_id = hd.hall_id + + +/* ============================================================= + EB DETAILS - ONE ROW PER BOOKING + ============================================================= */ + +LEFT JOIN ( + SELECT + booking_details_booking_id, + SUM(eb_amount) AS eb_amount + FROM eb_details + GROUP BY booking_details_booking_id +) eb + ON bd.booking_id = eb.booking_details_booking_id + + +/* ============================================================= + SETTLEMENT - ONE ROW PER BOOKING + ============================================================= */ + +LEFT JOIN ( + SELECT + booking_details_booking_id, + SUM(refunded_amount) AS refunded_amount + FROM settlement + GROUP BY booking_details_booking_id +) s + ON bd.booking_id = s.booking_details_booking_id + + +/* Used only to check whether settlement exists */ +LEFT JOIN ( + SELECT DISTINCT + booking_details_booking_id + FROM settlement +) st + ON bd.booking_id = st.booking_details_booking_id + + +WHERE bd.start_date < ? + +GROUP BY + hd.hall_id, + hd.hall_name + +ORDER BY + CAST(hd.hall_id AS UNSIGNED); + + """; + + + return jdbcTemplate.queryForList( + sql, + reportDate + + ); +} } diff --git a/src/main/resources/templates/modules/communityrevenue.html b/src/main/resources/templates/modules/communityrevenue.html new file mode 100644 index 0000000..05c90e0 --- /dev/null +++ b/src/main/resources/templates/modules/communityrevenue.html @@ -0,0 +1,916 @@ + + + + + + + + Community Hall Revenue Summary Report + + + + + + + + + + + + + + + + + + +
+ + + +
+

+ Community Hall Revenue Summary Report +

+
+ + + + +
+ +
+ +
+ + + + + +
+ + +
+ + + + + + +
+ +
+ +
+ + +
+ + Note: + The booking count may differ from the total number of bookings + due to various booking statuses, such as + Waiting for NOC, + Waiting for NOC Approval etc. +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ S.No + + Hall ID + + Hall Name + + Booking Details + + Refund Details + + Caretaker EB Reading
+ Not Entered +
+ SRO Pending + + User Cancelled - SRO Pending + + GCC Blocked / Rejected - SRO Pending +
+ Total
+ Booking Count +
+ Total Amount
+ Received +
+ Deposit Amount
+ Received +
+ Total Refunded
+ Count +
+ Total
+ Refund Amount +
+ Pending
+ Count +
+ Pending
+ Amount +
+ Pending
+ Count +
+ Pending
+ Amount +
+ Pending
+ Count +
+ Pending
+ Amount +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file