# Income Drive Calculator # Project Sheet
**Name** | IDC (Income Driver Calculator) |
**Project Scope** | A short description of the scope of the project from a sector and technical perspective. |
**Contract Link** | Link to the signed PDF document (PandaDoc) |
**Project Dashboard Link** | https://docs.google.com/spreadsheets/d/1wPSpzXuceDFZ4kdlrJoo\_J8n2PPRRNhAaTpW5mtsnPw/edit#gid=387463320 |
**Start Date** | 2023-07 |
**End Date** | 2024-04 |
**Repository Link** | [https://github.com/akvo/IDH-IDC](https://github.com/akvo/IDH-IDC) |
**Tech Stack** | List of technologies used to execute the technical scope of the project: - Front-end: Javascript with React Framework - Back-end: Python with FastAPI framework - BD - Testing - CI: Github Actions - Hosting: GKE - Database: PostgreSQL, Cloud-SQL - Storage: Cloud Storage Buckets |
**Asana Link** | [https://app.asana.com/0/1205513346619877/1207511953547471](https://app.asana.com/0/1205513346619877/1207511953547471) |
**Slack Channel Link** | [https://akvo.slack.com/archives/C05SPJ80HJ9](https://akvo.slack.com/archives/C05SPJ80HJ9) |
User Role | All Cases | BU | BU Role | Tag | Description |
Super Admin | true | - | null | - | |
Admin | true | BR | admin | - | - Rice in Indonesia: - edit - assign - Coffee in Vietnam: - view - edit (EPC, WRP) - Rice in Bangladesh: view |
Admin | false | BR | admin | rice | - Rice in Indonesia: - edit - assign - Coffee in Vietnam: - no access - edit (EPC, WRP) - Rice in Bangladesh: - view - edit (EPC, WRP) |
Admin | false | BR | admin | coffee | - Rice in Indonesia: - edit - assign - Coffee in Vietnam: - view - edit (EPC, WRP) - Rice in Bangladesh: - no access - edit (EPC, WRP) |
Admin | false | BR | admin | - | - Rice in Indonesia: - edit - assign - Coffee in Vietnam: - no access - edit (EPC, WRP) - Rice in Bangladesh: - no access - edit (EPC, WRP) |
Note that each question could have default calculation logic that can be loaded into the default\_value of the Question table to facilitate automatic computations on the front-end.
#### 12. Living Income Benchmark List of Living Income Benchmark ## Database Schema ### User TableColumn Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier. | Primary Key, Auto-Increment |
organization\_id | INT | Identifier for Organisation | Foreign Key (References organisation\_id) |
VARCHAR | Email of user | Not Null, Unique | |
full name | VARCHAR | Full name of user | Not Null |
password | TEXT | User Password | Nullable |
role | ENUM | Whether user is admin or business unit admin, etc. | Not Null, ENUM (super admin, admin, user) |
all\_cases | BOOLEAN | Whether all cases or only create | Not Null, Default False |
is\_active | BOOLEAN | Whether user is active | Not Null, Default False |
invitation\_id | VARCHAR | Invitation ID for new user | Nullable, Default (Random String) |
created\_at | DATETIME | Timestamp when the user was last created. | Not Null, Default Current Timestamp |
updated\_at | DATETIME | Timestamp when the user was last updated. | Nullable |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier. | Primary Key, Auto-Increment |
name | VARCHAR | Name of Business Unit | Not Null, Unique |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier. | Primary Key, Auto-Increment |
user\_id | INT | Identifier for the user. | Foreign Key (References user\_id) |
business\_unit\_id | INT | Identifier for the business unit | Foreign Key (References business\_unit\_id) |
role | ENUM | Whether admin or member | Not null, ENUM (admin, member) |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier. | Primary Key, Auto-Increment |
user\_id | INT | Identifier for the user. | Foreign Key (References user\_id) |
case\_id | INT | Identifier for the case | Foreign Key (References case\_id) |
permission | ENUM | Whether edit or view | Not null, ENUM (edit,view) |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each commodity. | Primary Key, Auto-Increment |
commodity\_category\_name | VARCHAR | Name of the commodity (e.g., "Land Commodity, Aquaculture, Livestock"). | Not Null, Unique |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each commodity. | Primary Key, Auto-Increment |
commodity\_category\_id | INT | Identifier for the commodity category. | Foreign Key (References commodity\_category\_id) |
commodity\_name | VARCHAR | Name of the commodity (e.g., "Coffee"). | Not Null, Unique |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each tags. | Primary Key, Auto-Increment |
name | VARCHAR | Name of the tag. | Not Null, Unique |
created\_at | DATETIME | Timestamp when the tag was created. | Not Null, Default Current Timestamp |
updated\_at | DATETIME | Timestamp when the tag was last updated. | Nullable |
created\_by | VARCHAR | User who created the tag. This can be an email or user ID, based on your user management system. | Not Null |
description | TEXT | Brief description or notes about the tag (Optional). | Nullable |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each case. | Primary Key, Auto-Increment |
case\_name | VARCHAR | Name of the case (e.g., "Country A Coffee Production Comparison"). | Not Null |
date | DATE | Date associated with the case. | Not Null |
year | INT | Year in the case timeline (from the dropdown). | Not Null |
country | INT | Country of focus for the case. | Foreign Key (References Country Table) |
focus\_commodity\_id | INT | Identifier for the commodity (focus). This could reference a master data table for commodities. | Foreign Key (References Commodity Master Table) |
currency | VARCHAR | Chosen currency for the case. | Not Null |
area\_size\_unit | VARCHAR | Unit for area size (e.g., hectare, m^2, are). | Not Null |
volume\_measurement\_unit | VARCHAR | Unit for volume measurement. | Not Null |
cost\_of\_production\_unit | VARCHAR | Unit for cost of production measurement (Per-area/Per-yield/Per-tree). | Not Null |
reporting\_period | VARCHAR | Reporting period (Per-season/Per-Year). | Not Null |
segmentation | BOOLEAN | Indicates if segmentation is on/off. | Not Null, Default False |
living\_income\_study | ENUM | Better Income or Living Income | Nullable |
multiple\_commodities | BOOLEAN | Indicates if multiple commodities option is on/off. | Not Null, Default False |
logo | VARCHAR | Stores the uploaded logo for the case. | Nullable |
private | BOOLEAN | Indicates if the case is private or public | Not Null, Default False |
created\_at | DATETIME | Timestamp when the case was created. | Not Null, Default Current Timestamp |
updated\_at | DATETIME | Timestamp when the case was last updated. | Nullable |
created\_by | VARCHAR | User who created the case. This can be an email or user ID, based on your user management. | Not Null |
Column Name | Data Type | Description | Constraint |
id | INT | Unique Identifier for each Diversified Commodity | Primary Key, Auto-Increment |
case\_id | INT | Identifier for the case. | Foreign Key (References Case Table) |
tag\_id | INT | Identifier for the tag. | Foreign Key (References Tag Table) |
Column Name | Data Type | Description | Constraint |
id | INT | Unique Identifier for each Diversified Commodity | Primary Key, Auto-Increment |
user\_id | INT | Identifier for the user. | Foreign Key (References User Table) |
tag\_id | INT | Identifier for the tag. | Foreign Key (References Tag Table) |
Column Name | Data Type | Description | Constraint |
id | INT | Unique Identifier for each Case Commodity | Primary Key, Auto-Increment |
case\_id | INT | Identifier for the case to which the case commodity belongs. | Foreign Key (References Case Table) |
commodity\_id | INT | Identifier for the commodity. This could reference a master data table for commodities. | Foreign Key (References Commodity Table) |
focus\_commodity | BOOLEAN | Whether it's focus commodity | True, Default: False |
breakdown | BOOLEAN | To define the question list | Not Null |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each segment. | Primary Key, Auto-Increment |
case\_id | INT | Identifier for the case to which the segment belongs. | Foreign Key (References Case Table) |
segment\_name | VARCHAR | Name or label of the segment (e.g., "City A"). | Not Null |
target | DECIMAL | Nullable | |
house\_hold\_size | DECIMAL | Average Household size: for calculating living income benchmark | Nullable |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each question. | Primary Key, Auto-Increment |
parent\_id | INT | Identifier for the parent question. NULL for top-level questions. | Foreign Key (References question\_id), Nullable |
code | VARCHAR | Code for the question | Nullable |
question\_text | VARCHAR | Text of the question or breakdown label. | Not Null |
descriptions | TEXT | Description text of the question | Nullable |
default\_value | TEXT | JavaScript string used for front-end calculations. | Nullable |
case\_commodity\_id | INT | Foreign Key | Nullable |
created\_by | INT | Identifier for the user to which the question belongs. | Foreign Key (References to user\_id), Nullable |
Case commodity Id only used for custom added specific question
If the default value is Null, then the children 1 level below the question should be added up as SUM.
Parent ID Null is the Income Drivers. Purpose: Selectively fetch values of Income Drivers for the visualization
### Commodity Category QuestionColumn Name | Data Type | Description | Constraints |
id | INT | Unique identifier for commodity question. | Primary Key, Auto-Increment |
commodity\_category\_id | INT | Identifier for the commodity category. | Foreign Key (References to commodity\_category\_id) |
question\_id | INT | Identifier for the question\_id. | Foreign Key (References to question\_id) |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each answer. | Primary Key, Auto-Increment |
case\_id | INT | Identifier for the case to which the answer belongs. | Foreign Key (References Case Table) |
segment\_id | INT | Identifier for the segment to which the answer belongs. | Foreign Key (References Segment Table) |
tab | ENUM | Enum for which tab this configuration belongs to | Enum (sensitivity\_analysis,scenario\_modeling) |
config | JSONB | Identifier for the segment to which the answer belongs. | JSONB |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier for each answer. | Primary Key, Auto-Increment |
case\_commodity\_id | INT | Unique Identifier for each commodity case commodity | Foreign Key (References Case Case Commodity Table) |
segment\_id | INT | Identifier for the segment to which the answer belongs. | Foreign Key (References Segment Table) |
question\_id | INT | Identifier for the question being answered. | Foreign Key (References Question Table) |
current\_value | DECIMAL | The response or current value given to the question. | Not Null |
feasible\_value | DECIMAL | The response or feasible value given to the question. | Nullable, Default: Current |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier. | Primary Key, Auto-Increment |
country\_id | INT | Identifier for the country. | Foreign Key (References country\_id) |
currency\_id | INT | Identifier for the currency. | Foreign Key (References currency\_id) |
year | INT | Year of the living income the benchmark. | Not Null |
value | DECIMAL | The benchmark value. | Not Null |
Column Name | Data Type | Description | Constraints |
---|---|---|---|
id | INT | Unique identifier. | Primary Key, Auto-Increment |
country\_id | INT | Identifier for the country. | Foreign Key (References country\_id) |
commodity\_id | INT | Identifier for the commodity. | Foreign Key (References commodity\_id) |
type | ENUM | Baseline / Segment Average | Enum |
year | INT | Year of the living income the benchmark. | Nullable |
farm\_size | DECIMAL | The Farm Land Size in Hectare | Nullable |
farmer\_production | DECIMAL | Farmer Production in KG | Nullable |
farmgate\_price | DECIMAL | Farm Gate Price USD / KG | Nullable |
farmer\_expenses | DECIMAL | Cost of Production in USD | Nullable |
diversified\_income | DECIMAL | Secondary or Tertiary Income | Nullable |