diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index d2a4cbc..6ed7875 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -62,6 +62,14 @@ The initial price of the product or service. | | | | - `initial_quantity` (float): The initial quantity demanded of the product or service. | | | | - `final_quantity` (float): The final quantity demanded of the product or service. | |----------------------------|----------------------------------------|----------------------------------------------------------------------| +| GET /loan_eligibility_check | Loan Eligibility Calculator | - `credit_score` (float): + An individual's credit score. | +| | | - `monthly_income` (float): The total income earned by the individual on a monthly basis. | +| | | - `existing_debt` (float): The amount of debt the individual already owes. | +| | | - `loan_amount` (float): TThe requested amount of money the individual wants to borrow as a loan. | +|----------------------------|----------------------------------------|----------------------------------------------------------------------| + + | GET /average_payment_period | Calculate Average Payment Period | - `beginning_accounts_payable` (float): The amount of accounts payable beginning the cycle. | | | | - `ending_inventory` (float): The final amount of accounts payable ending the cycle. | | | | - `total_credit_purchases` (float): The amount of purchases on credit during the cycle. | diff --git a/ENDPOINTS.md b/ENDPOINTS.md index be417c0..2bc7e01 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2269,17 +2269,33 @@ Sample Output "price_elasticity": -1.5 } ``` + +**POST** `/loan_eligibility` + +- Request body : `{ + "credit_score": 700, + "monthly_income": 4000, + "existing_debt": 1500, + "loan_amount": 20000 + **POST** `/average_payment_period` - Request body : `{ "beginning_accounts_payable": 110000, "ending_accounts_payable": 95000, "total_credit_purchases": 1110000 + }` - Sample output ```py { + "Tag": "Loan Eligibility check", + "loan_eligibility": -1.5 + "loan_terms": 5 years + "loan_amount": 20000 + "interest_rate": 5.5 + "monthly_payment": 375.8333333333333 "Tag": "Average Payment Period", "Beginning Accounts Payable": 110000, "Ending Accounts Payable": 95000, diff --git a/helpers/functions.py b/helpers/functions.py index ebfbbb7..4e11f50 100644 --- a/helpers/functions.py +++ b/helpers/functions.py @@ -2047,6 +2047,15 @@ def calculate_price_elasticity(initial_price: float, final_price: float, initial return price_elasticity +# Function to Calculate Loan Eligibility check + +def loan_eligibility_check(credit_score: float, monthly_income: float, existing_debt: float, loan_amount: float): + max_debt_to_income_ratio = 0.4 + max_loan_amount = monthly_income * max_debt_to_income_ratio + if loan_amount > max_loan_amount: + return False + else: + return True # Function to Calculate Average Payment Period def average_payment_period(beginning_accounts_payable: float, ending_accounts_payable: float, diff --git a/main.py b/main.py index 2f5cefc..2582923 100644 --- a/main.py +++ b/main.py @@ -135,6 +135,13 @@ from tasks.cash_conversion_cycle import cash_conversion_cycle_task from tasks.financialAssestRatio import financial_assest_ratio from tasks.PolicyPremium import calculate_policy_premium +from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, LoanEligibility +from tasks.financialAssestRatio import financial_assest_ratio +from tasks.PriceElasticity import calculate_price_elasticity +from tasks.loan_eligibility import loan_eligibility_check +from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod +from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod, ModifiedInternalRateOfReturn +from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod, ModifiedInternalRateOfReturn, SavingGoal, InterestCoverageRatio from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod, ModifiedInternalRateOfReturn, SavingGoal, InterestCoverageRatio, MarginOfSafety, TaxBracketCalculator from tasks.financialAssestRatio import financial_assest_ratio from tasks.PriceElasticity import calculate_price_elasticity @@ -1980,6 +1987,19 @@ def price_elasticity(request: PriceElasticity): request.initial_quantity, request.final_quantity ) +# Endpoint to calculate Loan Eligibility + +@app.post( + "/loan_eligibility_check", + tags=["loan_eligibility_check"], + description="Calculate Loan Eligibility", +) +def loan_eligibility_check(request: LoanEligibility): + return loan_eligibility_check(request.credit_score , + request.monthly_income , + request.existing_debt, + request.loan_amount ) + # Endpoint to calculate Average Payment Period @app.post( "/average_payment_period", diff --git a/tasks/loan_eligibility.py b/tasks/loan_eligibility.py new file mode 100644 index 0000000..c3c84bb --- /dev/null +++ b/tasks/loan_eligibility.py @@ -0,0 +1,30 @@ +from fastapi import HTTPException, status + +def loan_eligibility_check(credit_score: float, monthly_income: float, loan_amount:float): + + try: + max_debt_to_income_ratio = 0.4 + max_loan_amount = monthly_income * max_debt_to_income_ratio + + if loan_amount > max_loan_amount: + loan_eligibility = -1 + loan_terms = "" + interest_rate = 0 + monthly_payment = 0 + loan_agreement = "" + else: + loan_eligibility = loan_amount / 1000 + loan_terms = "5 years" + interest_rate = 5.5 + monthly_payment = (loan_amount * (1 + interest_rate / 100)) / (5 * 12) + loan_agreement = "Loan agreement details" + return { + "loan_eligibility": loan_eligibility, + "loan_terms": loan_terms, + "loan_amount": loan_amount, + "interest_rate": interest_rate, + "monthly_payment": monthly_payment, + "loan_agreement": loan_agreement + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) diff --git a/validators/request_validators.py b/validators/request_validators.py index 96bd688..7a2bbfc 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -644,12 +644,18 @@ class PriceElasticity(BaseModel): initial_quantity: float final_quantity: float +class LoanEligibility(BaseModel): + credit_score: float + monthly_income: float + existing_debt: float + loan_amount: float + class AveragePaymentPeriod(BaseModel): beginning_accounts_payable: float ending_accounts_payable: float total_credit_purchases: float -class SavingGoal(BaseModel): + class SavingGoal(BaseModel): current_savings: float monthly_contributions : float interest_rate: float