paint-brush
A Developer’s Guide: How to Automate a Financial Statement Analysis for Microfinanceby@davisdavid

A Developer’s Guide: How to Automate a Financial Statement Analysis for Microfinance

by Davis DavidApril 29th, 2024
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The importance of efficient analysis cannot be overstated. Whether it’s reconciling accounts, detecting fraudulent activities, tracking expenses, or determining creditworthiness, timely and accurate analysis is crucial for informed decision-making. However, traditional methods of analyzing transaction statements often fall short due to their labor-intensive nature and the complexity of modern financial systems.
featured image - A Developer’s Guide: How to Automate a Financial Statement Analysis for Microfinance
Davis David HackerNoon profile picture

In today’s fast-paced world, financial transactions are increasingly conducted electronically. This leads to a large volume of financial transaction statements generated daily from different financial service providers.


Analyzing these financial transaction statements manually can be time-consuming causes analysis errors and often lacks efficiency. Lending companies, businesses, and individuals alike face challenges in interpreting financial transaction statements to make data-driven decisions.


The importance of efficient analysis cannot be overstated. Whether it’s reconciling accounts, detecting fraudulent activities, tracking expenses, or determining creditworthiness, timely and accurate analysis is crucial for informed decision-making. However, traditional methods of analyzing transaction statements often fall short due to their labor-intensive nature and the complexity of modern financial systems.

Introduction to SAT

In response to the challenges posed by manual analysis, a revolutionary new tool has emerged: the Statement Analyzer Tool (SAT). SAT is a financial analysis tool developed by Tausi Africa that allows users based in Tanzania to upload their mobile money statements to gain actionable insights into their financial activities, such as cash flow, loan details, and bill payments.


SAT Dashboard


The primary purpose of the SAT is to simplify and speed up the analysis of financial transaction statements. SAT utilizes advanced algorithms and automation techniques to efficiently parse through large volumes of transaction data, identify patterns, and extract relevant information for decision-making.


Users can gain insights into:


  • Cash flow analysis

  • Loan details

  • Bill payments

  • Bank-to-wallet transactions

  • Peer-to-peer transactions

  • Agent activities


SAT provides a comprehensive analysis of financial transactions, helping users understand their spending habits, financial commitments, and overall financial health.

SAT Use Case for Lending Companies

The SAT tool enables micro-finance companies in Tanzania to streamline their loan approval process by analyzing customers’ mobile money transaction statements. When a borrower applies for a loan, they consent to share their mobile money data, which is securely uploaded to the SAT platform.


Loan Data Analysis

The tool then conducts a comprehensive analysis, extracting insights into the borrower’s financial behavior, cash flow, and existing obligations. Microfinance officers utilize this data to assess creditworthiness, evaluate risk, and make informed loan approval decisions


Micro-finance companies can effectively manage risk, enhance customer experience, and optimize loan portfolio performance through this integrated approach.

How to Use the SAT Tool

The SAT tool offers two access options. The initial method involves registering on the SAT website and completing the requisite form, which includes providing:


  1. Your name for the analysis.


  2. Selection of your mobile money service provider (MPESA, TIGOPESA, or AirtelMoney).


  3. Uploading of financial transaction statements from the chosen mobile money service provider.


New Analysis form.


The SAT tool will analyze your statement and provide a summary of the analysis.


SAT API Integration

The second method is integrating using the SAT API, this method is useful for developers who want to utilize the SAT solution in their own financial system to offer the service to their customers.


Here are the steps you need to follow:


  1. Access the Authorization Token: The initial step involves obtaining the authorization Bearer token from SAT. This token ensures your authentication before making API calls to SAT.


To acquire your personalized API Token, reach out to the SAT team via email at [email protected]


  1. Create a Python file

The second step is to create a Python file to write the code that will make API calls. You can name your file sat_api_calls.py.


  1. Import Python packages

    To make the API calls, you need to use two Python packages which are requests and JSON. By default, JSON is a built-in module in Python, but for requests, you need to install it in your environment.


Run the following command to install the requests python package.


pip install requests


Then you can import these two packages in your Python file.


import requests 
import json


  1. Define parameters

Before initiating API calls, it’s essential to define four parameters: These parameters are


  • URL: This defines the endpoint for the API call.


  • headers: This signifies the Authorization bearer token provided by the SAT team.


  • files: This is the location of the PDF file that has your financial transactions statement to be uploaded and analyzed. For this example, the PDF filename is ‘Miamala_2024_04_04.pdf’.


  • data: This is just the name you want to give to your analysis in Python dictionary format.Example {"fullname:"davis"}.
url = "https://api.sat.tausi.africa/v1/mpesa/upload_pdf"
headers = {"Authorization": "Bearer your_token"}
files = {
    'file': ('Miamala_2024_04_04.pdf', open('Miamala_2024_04_04.pdf', 'rb'), 'application/pdf')
}
data = {"fullname": "davis"}


5. Make the API call

Then you can make the API call using the parameters you defined.


response = requests.post(url, headers=headers, data=data, files=files)


  1. Show the analysis results

The last step is to show the analysis result generated by the SAT tool. The output of the API will be in JSON format.

# Check if the request was successful
if response.status_code == 200:
    # Parse the JSON response
    output_data = response.json()

    # Print the output
    print(output_data)
else:
    print("Error occurred:", response.text)


The code above checks if the API call was successful and then prints out the analysis result in JSON format, otherwise, it will show the error occurred if not successful.


Here is the complete Python code that should be in your Python file: sat_api_calls.py.


# import packages
import requests
import json

# define parameters
url = "https://api.sat.tausi.africa/v1/mpesa/upload_pdf"
headers = {"Authorization": "Bearer your_token"}
files = {
    'file': ('Miamala_2024_04_04.pdf', open('Miamala_2024_04_04.pdf', 'rb'), 'application/pdf')
}
data = {"fullname": "davis"}

# make the api call
response = requests.post(url, headers=headers, data=data, files=files)

# Check if the request was successful
if response.status_code == 200:
    # Parse the JSON response
    output_data = response.json()

    # Print the output
    print(output_data)
else:
    print("Error occurred:", response.text)


Finally, you can run the Python file in your terminal to then view the output.


python sat_api_calls.py


Here is the Analysis from the SAT tool.



{
    "info": {
        "owners_number": "25575633XXXX",
        "start_date": "2023-06-30 03:25:00",
        "end_date": "2024-02-26 07:12:00",
        "total_days": 242,
        "total_active_days": 127
    },
    "profile": {
        "current_wallet_balance": 0.04,
        "turnover": 48594106.0,
        "number_of_transactions": 953
    },
    "cashin_flow": {
        "total_cash-in_flow": 24489861.0,
        "cash-in_flow_to_turnover_percentage": 50.4,
        "cash-in_flow_transactions": 324,
        "cash-in_trans_to_total_trans_percentage": 34.0
    },
    "cashout_flow": {
        "Total_cash-out_flow": 24104245.0,
        "Cash-out_flow_to_turnover_percentage": 49.6,
        "Cash-out_flow_transactions": 629,
        "Cash-out_trans_to_total_trans_percentage": 66.0
    },
    "CRDB_Summary": {
        "total_Amount_transfered_from_crdb_to_wallet": 2005500.0,
        "max_amount_transfered_from_crdb_to_wallet": 650000.0,
        "number_of_times_transfered_from_crdb_to_wallet": 16,
        "average_amount_transfered_from_crdb_to_wallet": 125343.75,
        "last_date_transferred_from_crdb": "2024-02-15 01:40:00",
        "last_amount_transferred_from_crdb_to_wallet": 15000.0
    },
    "NMB_Summary": {
        "total_Amount_transfered_from_nmb_to_wallet": 500000.0,
        "max_amount_transfered_from_nmb_to_wallet": 250000.0,
        "number_of_times_transfered_from_nmb_to_wallet": 2,
        "average_amount_transfered_from_nmb_to_wallet": 250000.0,
        "last_date_transferred_from_nmb": "2023-09-06 06:21:00",
        "last_amount_transferred_from_nmb_to_wallet": 250000.0
    },
    "Luku_Summary": {
        "last_date_bought_luku": "2024-02-26 07:12:00",
        "total_luku_amount": 197000.0,
        "max_amount_bought_luku": 40000.0,
        "number_of_times_bought_luku": 12,
        "last_amount_bought_luku": 2000.0,
        "average_amount_bought_luku": 16416.666666666668
    },
    "agent_deposit_summary": {
        "last_date_deposited": "2023-12-11 10:14:00",
        "total_amount_deposited": 4745000.0,
        "max_amount_deposited": 1000000.0,
        "number_of_times_deposited": 15,
        "last_amount_deposited": 290000.0,
        "average_amount_deposited": 316333.3333333333
    },
    "agent_withdraw_summary": {
        "last_date_of_withdrawal_via_agent": "2024-02-23 09:53:00",
        "total_amount_withdrawn_via_agent": 2387000.0,
        "max_amount_withdrawn_via_agent": 1180000.0,
        "number_of_times_withdrawn": 17,
        "last_amount_of_withdrawn_via_agent": 50000.0,
        "average_amount_withdrawn": 140411.76470588235
    },
    "money_sent_p2p_summary": {
        "last_date_of_money_sent_to_peer": "2023-12-05 09:44:00",
        "total_amount_sent_to_peer": 1610000.0,
        "max_amount_sent_to_peer": 665000.0,
        "number_of_times_sent_to_peer": 12,
        "last_amount_sent_to_peer": 125000.0,
        "average_amount_sent_to_peer": 134166.66666666666
    },
    "money_received_p2p_or_business": {
        "last_date_of_money_received_from_peer_or_business": "2023-12-16 02:17:00",
        "total_amount_received_from_peer_or_business": 1911345.0,
        "max_amount_received_from_peer_or_business": 515000.0,
        "last_amount_received_from_peer_or_business": 1426.0,
        "number_of_times_received_from_peer_or_business": 18,
        "average_amount_received_from_peer_or_business": 106185.83
    },
    "lipa_summary": {
        "last_date_paid_via_lipa": "2024-02-22 07:49:00",
        "total_amount_paid_via_lipa": 2640700.0,
        "max_amount_paid_via_lipa": 525000.0,
        "number_of_times_paid_via_lipa": 94,
        "last_amount_paid_via_lipa": 40000.0,
        "average_lipa_amount": 28092.55
    },
    "bill_payment_summary": {
        "last_date_paid_bills": "2024-02-26 07:12:00",
        "total_amount_paid_bills": 6400175.96,
        "max_amount_paid_bills": 1100000.0,
        "number_of_times_bills_paid": 116,
        "average_bills_amount": 55173.93,
        "last_amount_paid_bills": 2000.0
    },
    "songesha_summary": {
        "Total_songesha_Amount_Disbursed": 4612956.0,
        "Max_songesha_Amount_Disbursed": 103453.0,
        "Number_of_songesha_Loans_disbursed": 237,
        "average_songesha_amount_disbursed": 19463.95,
        "last_songesha_loan_amount": 2040.0,
        "last_day_borrowed_songesha": "2024-02-26 07:12:00",
        "Total_songesha_amount_Repaid": 4965529.0,
        "Max_songesha_Amount_repaid": 111729.0,
        "Number_of_times_repaid_songesha": 259,
        "average_songesha_amount_repaid": 19171.93,
        "last_day_repaid_songesha": "2024-02-23 09:14:00",
        "last_songesha_amount_repaid": 45320.0,
        "Total_songesha_Amount_Disbursed_Per_Repaid": 0.93
    },
    "chomoka_summary": {
        "Total_chomoka_amount_Repaid": 334150.0,
        "Max_chomoka_Amount_repaid": 73450.0,
        "Average_chomoka_amount_repaid": 55691.67,
        "Number_of_chomoka_Loans_repaid": 6,
        "last_day_repaid_chomoka": "2023-12-02 12:53:00",
        "last_chomoka_amount_repaid": 34500.0
    },
    "mpawa_summary": {
        "Total_mpawa_Amount_Disbursed": 214650.0,
        "Max_mpawa_Amount_Disbursed": 56700.0,
        "Number_of_mpawa_Loans_disbursed": 4,
        "Average_mpawa_amount_disbursed": 53662.5,
        "last_day_borrowed_mpawa": "2024-02-12 07:23:00",
        "last_mpawa_amount_disbursed": 44550.0,
        "Total_mpawa_amount_Repaid": 291000.0,
        "Max_mpawa_Amount_repaid": 77000.0,
        "average_mpawa_amount_repaid": 72750.0,
        "Number_of_times_repaid_mpawa": 4,
        "last_day_repaid_mpawa": "2023-12-02 12:52:00",
        "last_mpawa_amount_repaid": 77000.0,
        "total_mpawa_amount_disbursed_to_repaid": 0.7376288659793815
    },
    "mgodi_summary": {
        "Total_mgodi_Amount_Disbursed": 0.0,
        "Max_mgodi_Amount_Disbursed": 0.0,
        "Number_of_mgodi_Loans_disbursed": 0,
        "Average_mgodi_amount_disbursed": 0.0,
        "last_day_borrowed_mgodi": "N/A",
        "last_mgodi_amount_disbursed": 0.0,
        "Total_mgodi_amount_Repaid": 100000.0,
        "Max_mgodi_Amount_repaid": 100000.0,
        "average_mgodi_amount_repaid": 100000.0,
        "Number_of_times_repaid_mgodi": 1,
        "last_day_repaid_mgodi": "2023-07-26 01:54:00",
        "last_mgodi_amount_repaid": 100000.0,
        "total_mgodi_amount_disbursed_to_repaid": 0.0
    }
}


The output shows the following 17 analyses from the mobile money transactions statement for MPESA users.


  • Basic information about the owner of the mobile number
  • Profile details about the statement
  • Cashin flow
  • Cashout flow
  • CRDB summary
  • NMB summary
  • Luku summary
  • Agent deposit summary
  • Agent withdraw summary
  • Summary for Money sent to P2P
  • Summary of Money received from P2P or business
  • Lipa summary
  • Bill payment summary
  • Songesha summary
  • Chomoka summary
  • Mpawa summary
  • Mgodi summary

Conclusion

Congratulations 🎉, you have made it to the end of this article. In this article, you have learned how SAT solutions can be used to analyze financial transaction statements automatically.


The insights generated by SAT can help to support data-driven decision-making for micro-finance and financial institutions to understand more about their customers' behaviors and then offer financial services that fit them.


You can access SAT API documentation here for more details on SAT API. The source code can be downloaded here.


In the next article, you will learn how to integrate API using the PHP programming language.


If you learned something new or enjoyed reading this article, please share it so that others can see it. Until then, see you in the next post!