Bug #2814
User Ledger Report with Debit, Credit & Running Balance
Added by Prashant Jain about 2 months ago.
Updated about 1 month ago.
Description
Description:
Develop a User Ledger Report to provide a complete transaction history for each user, including all debit and credit entries with a running balance.
Requirements
Filters
Date Range (From Date – To Date)
User (Optional)
If no user_id is selected, display ledger data for all users.
If user_id is provided, display the ledger only for the selected user.
Station (Optional)
Transaction Type (Debit/Credit/All)
Voucher Number (Optional)
Status (Optional)
Report Columns
Transaction Date
Voucher No.
User ID
User Name
Station Name
Transaction Type (Debit/Credit)
Debit Amount
Credit Amount
Opening Balance
Running Balance
Closing Balance
Reference No.
Description/Remarks
Created By
Report Logic
Calculate Opening Balance based on the balance before the selected date range.
Display all debit and credit transactions in chronological order.
Maintain a Running Balance for each transaction.
Calculate Closing Balance at the end of the selected period.
Support consolidated reports for all users as well as individual user ledger reports.
API Requirements
Support filtering by:
from_date
to_date
user_id
station_id
transaction_type
voucher_no
status
Pagination support.
Sorting by transaction date.
Export to Excel and CSV.
Expected Outcome
Users should be able to view a complete ledger containing all debit and credit transactions, voucher details, opening balance, running balance, and closing balance. The report should support both consolidated and user-specific views and be suitable for finance, audit, and reconciliation purposes.
I implemented and updated the export functionality, reviewed the CSV and Excel export services, and modified the export API to return ledger data in JSON format instead of CSV based on the new requirement. I also verified the service, repository, and controller flow to ensure the export endpoint correctly returns all filtered ledger records while keeping the existing Excel export functionality unchanged. Additionally, I tested the API responses and validated the end-to-end data retrieval flow for the User Ledger Report.
Today I implemented the complete User Ledger page for the Expenses module, following the existing UI patterns from Claims, Advances, and Approvals pages. I created the page component with full filtering support including date range, status, transaction type, and employee filters, along with proper pagination and loading states. I added the necessary route configuration in rolebasedroute.tsx and integrated the page into the sidebar navigation under the Expenses section with the reporting.employee.user_ledger.view permission. The summary cards were removed as requested, and the employee name display was fixed to show the username directly instead of using the displayEmployeeName function. I also implemented CSV export functionality with proper error handling and created the required API service and type definitions for the ledger data. All changes are consistent with the existing codebase and maintain the same UI/UX patterns as the other expense pages.
some changes need to be test which is in progress
also I try to understand the fundamentals of GraphQL and explored how it is integrated into React applications using Apollo Client. I tried to understood the concepts of queries
also I researched the getPartnerPayoutProcessPartnershipdetail API to understand where the data comes from and how it is stored, analyzing the table structures and data flow for partner payout .
implementation of the User Ledger page for the Expenses module, following the existing UI pattern of Claims, Advances, and Approvals pages.
Key Accomplishments:
Created complete User Ledger page with filters (Date range, Status, Transaction Type, User), summary cards (Opening Balance, Total Expenses, Total Received, Closing Balance), and transaction details table with proper styling.
Integrated API endpoints - Main data fetch (/user-ledger) with proper parameter handling (userid instead of employeeUserId), and export functionality (/export) with JSON to CSV conversion.
Customized UI elements - Renamed columns (Debit → Received, Credit → Expenses ), added arrow icons, and set default values (₹0.00).
Fixed multiple issues - Default user selection (first employee auto-selected), status filter default to "All Statuses", pagination handling, and resolved 400 error by preventing API calls without userId.
Implemented export functionality - Successfully integrated the export endpoint, converting JSON response to CSV format with proper headers and data mapping for all transaction fields.
Added permission constants - Created and integrated view and export permissions in the expense permissions file for proper access control.
and did some extra changes which is needed for user-ledger according to requirements.
I worked on the Employee User Ledger report by updating the filtering logic to support vouchers based on both party_user_id and approved employee advances created or posted by the selected user. I modified the repository queries to return debit entries, added station details in the response, removed the employee cash ledger restriction to include all relevant ledger entries, and tested the API with multiple users. I also validated the returned data against database records, investigated missing voucher entries by comparing API results with accounting vouchers and voucher lines, and continued debugging the remaining discrepancies in the ledger report.
I completed significant refactoring of the ledger API to resolve double entry accounting bugs and ensure precise chronological running balances. I updated the data filtration logic to strictly exclude draft entries while properly categorizing approved and rejected transactions. Additionally I Implemented TotalHoldAmount to track pending expenses and introduced a TotalAvailableBalance metric, providing the frontend with a highly accurate representation of the user's real time spendable cash
Learning & Skill Development:
continued learning React with TypeScript by understanding core concepts such as useState and Props, including why they are used and how they work in real-world projects. I related these concepts company codebase to better understand component reusability and state management, which helped me write cleaner and more maintainable code.
Frontend Work — User Ledger Page:
continued working on the User Ledger page and completed several enhancements. Added 3 new summary cards - Hold Balance, Total Balance, and Available Balance, making it a total of 7 cards in a single responsive row with proper color coding. Fixed column labels and colors - Swapped "Received" and "Expenses" columns with correct data binding and updated summary card labels accordingly. Enhanced status chips with proper color coding for all statuses Fixed TypeScript errors by updating UserLedgerSummary interface to include totalHoldAmount and totalAvailableBalance optional fields. Also updated UI responsiveness to make summary cards responsive across all screen sizes
Backend Work — Ledger Report API:
On the backend side, I worked on creating a new Ledger Report API that fetches transactions from accounting vouchers and voucher lines, calculates running balances, and returns paginated data with summary. Created all required DTOs, Repository, Service, Controller, and ExportHelper layers. Some testing is still pending, Also need to complete comprehensive testing across different ledger types and verify the running balance calculation logic with real accounting data.
and also some work in progress
today I development and testing of the Ledger Report API module. This involved creating a comprehensive reporting solution that fetches transactions from accounting vouchers and voucher lines for any given ledger, calculates running balances based on the ledger's balance nature (DEBIT/CREDIT), and returns paginated data with summary statistics. The API supports multiple filters including date range, voucher type, voucher number, status, and station ID, along with sorting and pagination.
Export Functionality — CSV & JSON
I implemented export endpoints — JSON export (all records without pagination), CSV file download. All exports include the same transaction data with running balance and summary information. The CSV export downloads a formatted file with proper headers, while the JSON export returns all records in a single API response for integration purposes.
worked on the Ledger Report feature development, including frontend UI implementation and backend integration. The feature allows users to view ledger transactions with running balances and export reports in CSV/JSON format.
What Has Been Completed
Backend Migration Script - Created V0083_ledger_report_permissions.sql to add two new permissions: reporting.ledger.view and reporting.ledger.export in all tenant schemas
C# Permission Constants - Added ViewLedgerReport and ExportLedgerReport constants in SystemPermissions.cs
Backend Controller - Implemented LedgerReportController with [RequirePermission] attributes for both GET and EXPORT endpoints
Frontend Implementation - Built complete LedgerReportPage following the same pattern as User Ledger, including summary cards, filters, and pagination
some changes in progress
Sidebar Integration - Added "Ledger Report" menu item under Stations → Expenses section with proper permission checks
Route Configuration - Added route in Router.tsx with ProtectedRoute using LEDGER_REPORT_VIEW and LEDGER_REPORT_EXPORT permissions
Today I integrated the Ledger Report API with the frontend and completed the full UI implementation. I built the complete Ledger Report page with summary cards , implemented dynamic ledger dropdown fetching all ledgers from the /api/v1/station/ledgers endpoint, and added filter functionality I also implemented CSV export functionality using the /export endpoint and added a Station Name column in the transaction table to display station details from the API response. Additionally, I optimized the UI by making summary cards responsive across all screen sizes, adjusting card sizes with reduced padding and typography, and reordering filters to place the Ledger dropdown first for better user experience. The page now supports pagination with configurable rows per page and handles loading states, error states, and empty states gracefully. Some testing is still pending for different ledger IDs and edge cases, and the Excel export functionality needs verification. I also continued learning React with TypeScript, concepts and relating them to our company codebase for better component reusability and state management
Also available in: Atom
PDF