yahya-s9 opened a new pull request, #4763:
URL: https://github.com/apache/fineract/pull/4763

   #### Yahya Qteishat ([email protected])
   - UC Berkeley Electrical Engineering & Computer Sciences '24
   - Software Engineer II @ Walmart 
   ----------------------------------------------------
   #### Task
   
   - Apache Fineract has an API layer on top of MariaDB 
   - Allow `/savingsaccounts` to return savings accounts by clients' birthdays
   #### Notes
   
   - API call to retrieve all savings accounts:
        
`https://localhost:8443/fineract-provider/api/v1/savingsaccounts?tenantIdentifier=default`
          
   - Example Response (after adding some test data):
   ```json
   {
     "id": 1,
     "accountNo": "000000001",
     "depositType": {
       ...
     },
     "clientId": 1,
     "clientName": "Yahya Qteishat",
     "savingsProductId": 1,
     "savingsProductName": "yahya_savings_product",
     ...
   }
   ```
   
   - Example endpoints from `SavingsAccountApiResource.java`
   
   | HTTP Method | Path                           | Purpose                     
       |
   | ----------- | ------------------------------ | 
---------------------------------- |
   | `GET`       | `/savingsaccounts`             | Retrieve all savings 
accounts      |
   | `POST`      | `/savingsaccounts`             | Create a new savings 
account       |
   | `PUT`       | `/savingsaccounts/{accountId}` | Modify an existing savings 
account |
   
   #### How API layer interacts w/ MariaDB:
   - For `/savingsaccounts`:
        - `searchParameters.forSavings()` wraps params in `SearchParameters` obj
        - `savingsAccountReadPlatformSrvce.retrieveAll(params)` builds SQL query
   #### Implementation
   
   - Add `birthdate` QueryParam to `/savingsaccounts` ✅
     
   - changes to `SearchParameters.java` ✅
        - add birthDate field
        - safely parse string birthDate into LocalDate obj (consistent with 
codebase)
        - new constructor overload for this function to return (consistent with 
codebase)
          
   - changes to `SavingsAccountReadPlatformServiceImpl.java`✅
        - in `retrieveAll()` ,  if the birthDate searchParam is specified.. 
        - add `and c.date_of_birth = ?` to the SQL query we're building
   
   #### Testing
   
   - Test clients on my MariaDB instance:
        - Yahya Qteishat, 2001-10-23
        - Youssef Qteishat, 2001-10-23
        - Salma Qteishat, 1997-09-04
   
   - Test calls:
        - 
`https://localhost:8444/fineract-provider/api/v1/savingsaccounts?tenantIdentifier=default&birthDate=1997-09-04`
 ✅
   
   ```json
   {
     "id": 4,
     "accountNo": "000000004",
     "depositType": {
       ...
     },
     "clientId": 3,
     "clientName": "Salma Qteishat",
     "savingsProductId": 1,
     "savingsProductName": "test_savings_product",
     ...
   }
   ```
   
   - 
`https://localhost:8444/fineract-provider/api/v1/savingsaccounts?tenantIdentifier=default&birthDate=2001-10-23`
 ✅
   
   ```json
   {
     "id": 2,
     "accountNo": "000000004",
     "depositType": {
       ...
     },
     "clientId": 1,
     "clientName": "Yahya Qteishat",
     "savingsProductId": 1,
     "savingsProductName": "test_savings_product",
     ...
   },
   {
     "id": 3,
     "accountNo": "000000003",
     "depositType": {
       ...
     },
     "clientId": 2,
     "clientName": "Youssef Qteishat",
     "savingsProductId": 1,
     "savingsProductName": "test_savings_product",
     ...
   }
   ```
   
   - incorrect format, invalid string -> behaves as if birthdate was not 
specified ✅
   
   
   
   #### Integration Tests
   
   
   
   #### Debugging 
   
   - When choosing to also run the Springboot application locally
        - Containerized: https://localhost:8443/fineract-provider
        - local instance: https://localhost:8444/fineract-provider
   
   - For local instance:
        - "Access denied for user 'root'@'192.168.65.1' (using password: YES)"
        - local app trying to connect from 192.168.65.1 
        - mariaDB inside the docker container, only allows root to log in from 
localhost
          
          - fix: allow root to connect from any IP
                  - enter mariaDB container
                          - "docker exec -it fineract-fineractmysql-1 bash"
                  - log into mariaDB inside the container
                          - "mariadb -u root -p"
                          - skdcnwauicn2ucnaecasdsajdnizucawencascdca
                  - Create a root user that can connect from any IP
                          - "ALTER USER 'root'@'%' IDENTIFIED BY 
'skdcnwauicn2ucnaecasdsajdnizucawencascdca';"
                          - "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH 
GRANT OPTION;"
                          - "FLUSH PRIVILEGES;"
          


-- 
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