Payment and File Processing
+---------------------+
| Users/Clients |
+----------+----------+
|
v
+----------+----------+
| API Endpoints |
+----------+----------+
|
v
+-----------------------+-----------------------+
| |
+-------------+-------------+ +-----------+-----------+
| Fetch Transactions | | Fetch Transaction by ID|
| (GET /) | | (GET /:id) |
+-------------+-------------+ +-----------+-----------+
| |
v v
+-------------+-------------+ +-----------+-----------+
| Get Transactions from DB | | Get Transaction by ID |
+-------------+-------------+ +-----------+-----------+
| |
v v
+-------------+-------------+ +-----------+-----------+
| Transactions Table | | Transactions Table |
+---------------------------+ +-----------------------+
|
v
+-------------+-------------+
| Get Accounts and Categories|
+---------------------------+
|
v
+-------------+-------------+
| Accounts and Categories |
+---------------------------+
+---------------------------------------+
| |
+-------------+-------------+ +---------------+-------------+
| Create Transaction | | Bulk Create Transactions |
| (POST /) | | (POST /bulk-create) |
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Insert Transaction into DB| | Insert Transactions into DB|
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Transactions Table | | Transactions Table |
+---------------------------+ +-----------------------------+
|
v
+-------------+-------------+
| Log Audit Change |
+---------------------------+
|
v
+-------------+-------------+
| Audit Logs Table |
+---------------------------+
+---------------------------------------+
| |
+-------------+-------------+ +---------------+-------------+
| Delete Transaction | | Bulk Delete Transactions |
| (DELETE /:id) | | (POST /bulk-delete) |
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Delete Transaction from DB| | Delete Transactions from DB|
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Transactions Table | | Transactions Table |
+---------------------------+ +-----------------------------+
+---------------------------------------+
| |
+-------------+-------------+ +---------------+-------------+
| Update Transaction | | Fetch Proof of Payments |
| (PATCH /:id) | | (GET /payments) |
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Update Transaction in DB | | Get Payments from DB |
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Transactions Table | | Payments Table |
+---------------------------+ +-----------------------------+
|
v
+-------------+-------------+
| Log Audit Change |
+---------------------------+
|
v
+-------------+-------------+
| Audit Logs Table |
+---------------------------+
+---------------------------------------+
| |
+-------------+-------------+ +---------------+-------------+
| Process Proof of Payment | | Resolve Proof of Payment |
| (PATCH /payments/:id) | | (PATCH /payments/:id/resolve)|
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Update Payment Status | | Update Payment Status |
| in DB | | in DB |
+-------------+-------------+ +---------------+-------------+
| |
v v
+-------------+-------------+ +---------------+-------------+
| Payments Table | | Payments Table |
+---------------------------+ +-----------------------------+
|
v
+-------------+-------------+
| Log Audit Change |
+---------------------------+
|
v
+-------------+-------------+
| Audit Logs Table |
+---------------------------+
==============================================
Table of Contents
- Overview
- API Endpoints
- Database Models
- Relational Flow Diagram
- Implementation Details
- Error Handling
- Conclusion
Overview
The system provides functionalities to manage financial transactions, handle proof of payments, and update financial records for students. It includes:
- Fetching transactions based on various filters.
- Retrieving transaction details by ID.
- Creating single and bulk transactions.
- Deleting transactions.
- Updating transaction details.
- Processing proof of payments and updating their statuses.
API Endpoints
Fetch Transactions
- Purpose: Retrieve a list of transactions filtered by date range and account ID.
- Endpoint:
GET / - Parameters: Optional query parameters (
from,to,accountId) to filter transactions. - Response: Returns a list of transactions with details like date, category, payee, amount, and account.
Get Transaction by ID
- Purpose: Retrieve details of a specific transaction.
- Endpoint:
GET /:id - Parameters: Transaction ID.
- Response: Returns the details of the specified transaction.
Create Transaction
- Purpose: Create a new transaction.
- Endpoint:
POST / - Body: Transaction details excluding the ID.
- Response: Returns the created transaction details.
Bulk Create Transactions
- Purpose: Create multiple transactions at once.
- Endpoint:
POST /bulk-create - Body: Array of transaction details.
- Response: Returns the IDs of the created transactions.
Bulk Delete Transactions
- Purpose: Delete multiple transactions at once.
- Endpoint:
POST /bulk-delete - Body: Array of transaction IDs to be deleted.
- Response: Returns the IDs of the deleted transactions.
Update Transaction
- Purpose: Update the details of an existing transaction.
- Endpoint:
PATCH /:id - Parameters: Transaction ID.
- Body: Updated transaction details excluding the ID.
- Response: Returns the updated transaction details.
Delete Transaction
- Purpose: Delete a specific transaction.
- Endpoint:
DELETE /:id - Parameters: Transaction ID.
- Response: Returns the ID of the deleted transaction.
Database Models
The primary database models involved in this system are:
- Transactions: Records details of financial transactions.
- Accounts: Stores account information.
- Categories: Defines transaction categories.
- Students: Contains student details.
- Registration Numbers: Stores student registration numbers.
- Financial Statements: Tracks financial statements for students.
- Payments: Manages payment records.
Relational Flow Diagram
Here is an ASCII representation of the relational flow diagram:
+---------------------+ +----------------------+
| Accounts | | Categories |
+---------------------+ +----------------------+
| id | | id |
| name | | name |
| userId | | createdAt |
| createdAt | | updatedAt |
| updatedAt | +----------------------+
+---------------------+
|
v
+---------------------+
| Transactions |
+---------------------+
| id |
| studentId |
| date |
| categoryId |
| payee |
| amount |
| notes |
| accountId |
| madeBy |
| createdAt |
| updatedAt |
+---------------------+
|
v
+---------------------+
| Students |
+---------------------+
| id |
| registrationNumberId|
| userId |
| currentProgramLevelId|
| createdAt |
| updatedAt |
+---------------------+
|
v
+-----------------------------+
| Registration Numbers |
+-----------------------------+
| id |
| number |
| createdAt |
| updatedAt |
+-----------------------------+
|
v
+-----------------------------+
| Financial Statements |
+-----------------------------+
| id |
| studentId |
| semesterId |
| date |
| description |
| debit |
| credit |
| balance |
| createdAt |
| updatedAt |
+-----------------------------+
|
v
+-----------------------------+
| Payments |
+-----------------------------+
| id |
| studentId |
| userId |
| amount |
| description |
| date |
| createdAt |
| updatedAt |
+-----------------------------+
Implementation Details
Transaction Management
- Fetching Transactions: The system allows filtering transactions by date range and account ID, ensuring users can retrieve relevant financial data.
- Transaction Details: Users can retrieve detailed information about specific transactions using their unique IDs.
- Creating Transactions: The system supports both single and bulk creation of transactions. For each transaction, it logs the creation for audit purposes.
- Deleting Transactions: Transactions can be deleted individually or in bulk. The deletion process ensures that only authorized users can perform this action.
- Updating Transactions: Users can update transaction details. The system logs changes to maintain a history of modifications for auditing.
Proof of Payment (POP) Management
- Fetching Files: The system retrieves and displays proof of payments uploaded by students.
- Processing POPs: The system allows marking POPs as resolved, updating their statuses accordingly.
- Audit Logging: Changes made to transaction records and POP statuses are logged for audit purposes.
Error Handling
The system incorporates comprehensive error handling mechanisms to ensure smooth operations:
- Unauthorized Access: Ensures only authenticated and authorized users can access or modify data.
- Missing Data: Handles cases where required data is missing or invalid.
- Database Errors: Catches and logs database errors to facilitate troubleshooting.
- User Feedback: Provides clear feedback to users on the success or failure of their actions.