Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

FI-Python-Algorithms

  1. Create a new savings goal

    • Input: • User ID, • Target Date, • Target Amount, • Goal Name, • Amount Saved
    • Output: Return the new goal
  2. Update a savings goal

    • Input: Goal ID, New Target Amount
    • Output: Return the updated savings goal
  3. Record savings progress

    • Input: Goal ID, Amount to Add
    • Output: Store the updated savings progress and return the updated goal
  4. Retrieve savings goal status

    • Input: Goal ID
    • Output: Return the goal status (including current amount saved, target amount, target date, etc.)
  5. Check savings goal progress and notify if behind schedule

    • Input: Goal ID, Current Date
    • Output: Return a message indicating the number of days left until the target date and whether the user is on track (or a warning if the goal is at risk of not being met)
# ==========================================
# SAVINGS GOAL FUNCTIONS
# ==========================================

# Adds a new goal to the database for a specific user
FUNCTION addSavingsGoal(user_id, target_date, target_amount, goal_name):
    Find the user record using user_id
    Create a new entry in the 'goals' table with the provided details
    Set initial amount_saved to 0
    SAVE changes to database

# Updates the target amount of an existing goal
FUNCTION updateSavingsGoal(goal_id, new_target_amount):
    Find the specific goal in the database using goal_id
    UPDATE goal set target_amount = new_target_amount
    SAVE changes to database

# Returns the raw currency amount remaining to reach the goal
FUNCTION getSavingsProgressAmount(goal_id):
    goal = Find goal by goal_id
    remaining_balance = calculateDifference(goal.target_amount, goal.amount_saved)
    RETURN remaining_balance

# Returns the percentage of the goal completed
FUNCTION getSavingsStatusPercentage(goal_id):
    goal = Find goal by goal_id
    percentage = (goal.amount_saved / goal.target_amount) * 100
    RETURN percentage

# Notifies the user if the goal date has passed without meeting the target
FUNCTION checkGoalNotification(goal_id, current_date):
    goal = Find goal by goal_id
    IF goal.amount_saved < goal.target_amount AND current_date >= goal.target_date:
        days_past = current_date - goal.target_date
        RETURN "Goal not met. It is " + days_past + " days past your target date."
    ELSE:
        RETURN None

# ==========================================
# HELPERS
# ==========================================

# Calculates the remaining gap toward the target
FUNCTION calculateDifference(target, current):
    RETURN target - current

About

Develop a new feature for the company’s mobile banking app that enables users to set and track their savings goals.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors