# User Documentation of IPFM
## Index
- [Application Overview](#Application-Overview)
- [What IPFM Offers](#What-IPFM-Offers)
- [Getting Started](#Getting-Started)
- [Registration ](#Registration)
- [Login](#Login)
- [Dashboard](#Dashboard)
- [Accounts](#Accounts)
- [Transactions](#Transactions)
- [Recurring Payments](#Recurring-Payments)
## Application Overview
- In today's fast moving world, how will you manage all your different bank accounts without wasting a lot of time?
- ION's Personal Fincance Manager is a one stop solution that provides efficient personal finance management, and saves the time of end-user by bringing all the financial data under one application.
- We leverage Account Aggregators, which gather all the user's financial data from the banks, FIPs (Financial Information Providers) and give them to FIUs (Financial Information User).
## What IPFM Offers
- Consolidated view of all your bank accounts at one single place.
- Tracking of recurring subscriptions/installments efficiently and get timely notifications for the same.
- Get a broader view of your entire finances with a configurable dashboard.
- Search/filter through your historical transactions data across different bank accounts easily and efficiently.
## Getting Started
- These instructions will get you the project up and running on your local machine for development and testing purposes.
### Prerequisite
- Install the Angular CLI, open a terminal window and run the following command:
`npm install -g @angular/cli`
- Install the latest stable version of [NodeJs](https://nodejs.org/en/download/) on your local machine.
- Install the latest stable version of [Python](https://www.python.org/downloads/) on your local machine.
- Add the corresponding .env files into the backend and backend_analytics folders beforing starting the servers.
- Install [virtualenv](https://pypi.org/project/virtualenv/) python package. Create a virtual environment by using the command `virtualenv <virtual_env_name>` or `python -m virtualenv <virtual_env_name>`
- Pull the docker image [forwardsecrecy] (https://hub.docker.com/r/gsasikumar/forwardsecrecy/tags). Run the container based on this image by exposing the port 2000.
### Installing
- Clone the repo.
`$ git clone https://git.iontrading.com/ion-india-internship-2022/ta-ipfm.git`
- Install the dependencies for the frontend and start the server.
`$ cd IPFM_FRONTEND`
`$ npm install`
`$ ng serve`
### Backend
- Copy the firebase credentials file in the root folder of the backend folder
- Install the dependencies for the backend and start the server.
`$ cd backend`
`$ npm install`
`$ node app.js` or to skip the [SELF_SIGNED_CERT_IN_CHAIN](https://stackoverflow.com/questions/34498736/npm-self-signed-cert-in-chain) error due to the VPN, use
`$ NODE_TLS_REJECT_UNAUTHORIZED='0' node app.js`
- Or install nodemon as a Dev Dependency, to watch the server for changes.
`$ npm i -D nodemon`
`$ nodemon app.js`
- Activate the virtual environment and then install the dependencies of the backend_analytics server and start the server
`$ cd backend_analytics`
`$ source new_virt/Scripts/activate`
`$ pip install -r requirements.txt`
(the above command will not work if you are using ION network or VPN, so use the following command)
`$ pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org -r requirements.txt`
`$ python app.py`
### Setting Up Firebase Notifications
- Create a new Project in Firebase Console, and choose the Web App for the type of project.
- Move to the project settings and copy the configuration given inside the firebase-messaging-sw.js.
- Also go to the Service Accounts tab on the settings page and generate a new service account from there, which will download a JSON file containing the private and public key of the account.
- Save the JSON file in the root directory of the backend.
- Also go to the Cloud Messaging Tab on the settings page and enable the web push notifications and you will be good to go.
## Registration
- The following steps will take you through the registration flow of ION Personal Finance Manager Application
1. When you open the homepage of IPFM application, you will have to enter the mobile number and click submit.

2. The application will redirect to onemoney (Account Aggregator) authentication pages. You will get an error, if you try to login without first registring under onemoney.

3. To register under onemoney, click on register. You will have to enter the username, mobile number and use the mobile number as the customerID and then provide the OTP sent to the given mobile number.

4. If the registration is successful, you will be redirected to the login page. You can now login by entering the mobile number and the OTP sent to the given mobile number.

5. If you are logged in successfully, then you will be provided with the consent request.

6. As you have registered for the first time, you need to add accounts by clicking on the Add Accounts button under Account Types. Further, you need to select all the bank accounts to which this consent must be applied.


7. After the accounts are added, select the accounts and then click on approve button at the end of the consent request.


6. If the consent request is accepted, you will be redirected to the dashboard. The next section talks everything about the dashboard.
## Login
- The following step take you through the login flow in IPFM:
1. Open the landing page of IPFM application. Enter the mobile number in provided field and click enter. If you are a registered user, you will be redirected to dashboard page.


## Dashboard
- After the user is authenticated by Onemoney, the user is redirected to the dashboard, which displays all the user financial data in a concise and pictorial form.
- There are multiple sections on IPFM dashboard like, Net Worth which shows the current balance of all the user's accounts, recent transactions, spending, debits and credits by the user on different accounts, and mode of payments used by the user.


- The dashboard is fully configurable, with a vide variety of filters where the users are given the control to visualize the data.
- The filters can be applied on the data by first clicking on the 'Add Filters' button, then a modal is shown where the user can choose, between - "Start/End Date", "Type of Transactions" and "Mode of Payment".
- The data can also be grouped by user accounts from the filter section.

- There is a section to view the notifications recieved by the user, whenever the new financial data is available, or there is a recurring transaction which is going to trigger in the near future.
- 
- User can also refresh the financial data on it's own, by clicking the "Refresh Data" on the top right corner.
## Accounts
- This page lists all the users bank accounts with all the information about the bank account such as - Account Number, IFSC code,Type of account and current balance.
- The user can also refresh the bank account data, on its own by clicking the Refresh Data button present on the top right corner of the screen and the Accounts data is refreshed.

- The user can also add more bank accounts by linking them to Onemoney. This can be done by clicking the Add Account button, which redirects the user to the Onemoney screens where user can link the bank accounts.
- After clicking the Add Account button, the user has to first login to onemoney and the authentication screen is present to the user.


- The user has to select the account to link with onemoney. Once the link is made and the user clicks on "Approve", the bank account is linked and the user is redirected to the dashboard, and can see the newly linked bank accounts on the dashboard.


## Transactions
- In this page, you will be able to view all the transactions of all the accounts.
- You can use the filters to view specific transactions. The available filters are:
- Mode of payment
- Debit / Credit / ALL transactions
- Account Number
- From Date
- To Date

## Recurring Payments
- IPFM application has a separate page for managing , searching nad viewing recurring transactions.
- You will have to click on search recurring transactions button, for the application to analyze and show the potential recurring transactions.

- The application takes some time to search for the recurring transactions. So the application will send you a notificatoin when the search results are ready.


- After you receive the notification, you can view the recurring transactions. Select the bank and the required accounts. There are three options under mode and they are:
1. Recurring Transaction
2. Potential Recurring Transactions
3. Not Recurring Transactions
##### 1. Recurring Transactions Mode
- In this mode, you will be able to view the transactions which you have selected as recurring.
- You will be able to add a description to each recurring transaction, by clicking on add description.



- You can click on clear button to make a recurring transaction into a non recurring transaction and also to stop the notifications related to that transaction.
- You will see that there are no transactions because we had only one recurring transaction and after clearing it, it will be shifted to the Not Recurring Transaction section.

##### 2. Potential Recurring Transactions
- This mode contains all the transactions that are identified as potential recurring transactions by IPFM's analysis script.
- You can click the select button, to mark it as a recurring transaction. After the selection, the transaction is moved to the Recurring Transactions section and you will also be receiving the notifications 3 to 4 days prior to the day on which actual recurring transaction would take place.

##### 3. Not Recurring Transactions
- This mode contains all the transactions that were marked as not recurring.
- These transactions can again be marked as recurring transactions by clicking on the recurring button.
- The selected transaction would be moved to the recurring transactions section.

