Programs - Gary-Community-Ventures/benefits-api GitHub Wiki

Programs

Programs are the main thing that is displayed to the user on the results page. Text like the name, description, and apply link are handled in the admin, while rules for eligibility and value are handled in code. There are 2 methods for calculating eligibility and value.

  • Write our own rules
  • Use Policy Engine

This section will discuss programming the rules for a program, and how add/edit a program in the admin.

Admin

The Admin allows non developers to edit program information without the help of a developer.

Creating a program

  1. Go to the "Translation Admin".
  2. Go to "Programs".
  3. Click "Add New".

image

  1. Enter the "Name abbreviated" that corresponds to the calculator for the program (you may need to ask a developer for this).

image

  1. Add all of the text for the program by clicking the links, and replacing the placeholder text with the desired text.

  2. Click "Edit in Main Admin"

image

  1. Update the fields
    • Documentation for each field can be found in the Main Admin section.

Updating a program

Translation admin

To edit any of the text in the translation admin:

  1. Go to the "Translation Admin".
  2. Go to "Programs".
  3. Search the name of the program.
  4. Select "Go to".
  5. Select the field to update.

The translations can also be accessed through the main admin by clicking on the hamburger menu in the "Translate" column

image

Main Admin

  1. Go to "Programs.
  2. Search the name of the program.
  3. Click on the name.
  4. Update the fields.

image

What things mean

Translation admin

The following translated text can be edited in the translation admin:

  • Name: The name that is displayed to the user
  • Description: The description that is displayed to the user
  • Short description: Deprecated
  • Learn more link: Deprecated
  • Apply button link: The link that will take the user to the application. This is a translation, because there can be different links for different languages
  • Value type: Deprecated
  • Estimated delivery time: Deprecated
  • Estimated application time: The estimated amount of time it would take for the user to apply
  • Category: The category that this benefit is in. If it is the same as another program, then those programs will be grouped together
  • Website description: The description on the page that lists all of the MFB benefits
  • Estimated value: If this value is not empty, then the program value will be set to this value. Can be text

Main admin

The following things can be edited in the main admin:

  • Name abbreviated: The rules to use
  • External name: Syncs programs across environments
  • Legal status required: The citizenship statuses that are eligible for this program
  • Documents: The documents that are needed to apply for this program
  • Active: Only active programs are showed to the user
  • Low confidence: Display a flag to the user that reads "Low Confidence"
  • Fpl: The year that the program should be calculated for. For the custom calculators, this is used for choosing what FPL year to use. For the Policy Engine calculators, this is used to determine which period to use.

Other program related features

The following can be added to a program.

  • Navigator: An organization that will help the user apply the program.
  • Warning message: An additional message to display to the user under certain conditions.
  • Translation override: Override translated text of the program under certain conditions.

Development

Base classes are provided for both writing custom rules, and fetching rules from Policy Engine.

Custom rules

Create a new folder with the name of the new program in one of the state (or federal) folders in /programs/programs/. In that folder add the files __init__.py and calculator.py.

To create a program calculator in the calculator.py, create a new class that inherits from ProgramCalculator in /programs/programs/calc.py.

The following methods and attributes can be overridden:

  • household_eligible (method): Eligibility rules that apply to the whole household.
    • An Eligibility object is passed as a parameter. To add a condition, call e.condition(bool). A program will be marked as eligible if all of the conditions are True. There is an additional condition that at least one household member must be eligible.
  • member_eligible (method): Eligibility rules that apply to individual household members.
    • An MemberEligibility object is passed as a parameter. To add a condition, call e.condition(bool). A member will be marked as eligible if all of the conditions are True.
  • household_value (method): The household value of the program if eligible.
  • member_value (method): The value of the program for each eligible household member.
  • amount (attribute): The value returned by household_value if it is not overridden.
  • member_amount (attribute): The value returned by member_value if it is not overridden.
  • dependencies (attribute): A list of fields needed so that the program does not through an error when run. If the screen is missing one of these fields, then the program will be skipped. Syntax:
    • Screen and HouseholdMember fields: {field}
    • IncomeStream fields: income_{field}
    • Expense fields: expense_{field}

Import and add the calculator to the dictionary in the __init__.py file in the corresponding state folders /programs/programs/. The key used is matched to the name_abbreviated of a program.

Policy Engine rules

TODO

Brief technical overview