Skip to content

Commit

Permalink
Added HCR Tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
srugano committed Oct 7, 2024
1 parent e8eee8f commit a3c7e8e
Show file tree
Hide file tree
Showing 64 changed files with 378 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/components/reporting/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ nav:
- index.md
- glossary.md
- tmp.md
- Tutorials: tutorials
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions docs/components/reporting/glossary.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Country Report

Reporting component of the HOPE ecosystem.
This components allows user to produce reports and keep them updated customizing filters and refreshing schedule.
Hope Country Report (HCR) is a pivotal component within the Hope platform, specifically designed to empower UNICEF country offices with the ability to generate customized reports tailored to their unique requirements. These reports are not mere static compilations of data, but rather dynamic representations of information extracted from the Hope Database.

At the core of this data retrieval process lies the utilization of Python and Django code. These programming languages provide the necessary tools to extract and manipulate data from the database, enabling the creation of reports that are both informative and visually appealing.

To gain a comprehensive understanding of the available data within the Hope Database, it is essential to refer to the GitHub repository at this


## Features

Expand All @@ -15,7 +19,7 @@ This components allows user to produce reports and keep them updated customizing

<report:Parametrizer/Argument>

: Dictionary used to create reports
Dataset : Dictionary used to create reports

System flagged are special arguments with related sync

Expand Down
6 changes: 3 additions & 3 deletions docs/components/reporting/tmp.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# HCR Components

python manage.py inspect_hope

Login in develop:
Anypassword login
user ->
admin ->

# Sections

## Home
# Home

[future] Overview of country dashboard

Expand Down
5 changes: 5 additions & 0 deletions docs/components/reporting/tutorials/.pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
nav:
- index.md
- Creating a simple report: simple.md
- Creating a Template Report for a bank: banks.md
- Generate a report from a list of HH: hh.md
146 changes: 146 additions & 0 deletions docs/components/reporting/tutorials/banks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Creating a Template Report for a Bank in Belarus


1\. Navigate to [https://reporting-hope-dev.unitst.org/admin/](https://reporting-hope-dev.unitst.org/admin/)


2\. Scroll down to "Queries"

![Image](../_screenshots/ascreenshot35.jpeg)


3\. Click on "ADD QUERY"

![Image](../_screenshots/ascreenshot36.jpeg)


4\. Add "Belarus" to country office field

![Image](../_screenshots/ascreenshot37.jpeg)


5\. Fill in the name of the query "Template for a bank"


6\. Paste this code in order to get the required information.

```python
from django.db.models import ExpressionWrapper, F, DecimalField
households=list(conn.select_related(
"head_of_household",
"business_area",
"parent",
"household"
).filter(
business_area__slug="belarus",
parent__unicef_id="PP-0630-24-00000017"
).values(
"entitlement_quantity",
"head_of_household__given_name",
"head_of_household__given_name",
"head_of_household__family_name",
"head_of_household__middle_name",
"head_of_household__sex",
"household__address",
"head_of_household__phone_no",
"household__unicef_id"
).annotate(
commission=ExpressionWrapper((F('entitlement_quantity')*5/100)*1.20, output_field=DecimalField(decimal_places=2) ))
)
result = []
for household in households:
address_no_spaces = household["household__address"].replace(" ", "")
household["locality"] = address_no_spaces[:29]
household["street_name"] = address_no_spaces[30:59]
result.append(household)
```
![Image](../_screenshots/ascreenshot38.jpeg)


7\. We will produce a report based on the Payments made recently in Belarus. So, we chose the **Payment**, table as target of our report.

![Image](../_screenshots/ascreenshot39.jpeg)


8\. Save and continue editing.

![Image](../_screenshots/ascreenshot40.jpeg)


9\. Click "Queue" button to generate the data.

![Image](../_screenshots/ascreenshot41.jpeg)


10\. Click "DATASETS" to preview the results and ensure things are correct

![Image](../_screenshots/ascreenshot42.jpeg)


11\. We now need to create a formater as requested by the bank. This will allow us to produce a text file that ressemble the one we required by our bank. Navigate to ***Home>Power*** Query and slick "**Add**" on the formater row

![Image](../_screenshots/ascreenshot43.jpeg)


12\. Give the template a name "Template for a bank in Belarus"


13\. Click here.

![Image](../_screenshots/ascreenshot44.jpeg)


14\. In the code area, paste the following html code:
```html
<table></table>
```


15\. Select the "text/html" option for the hile type since we want a simple html file. Save.

![Image](../_screenshots/ascreenshot45.jpeg)


16\. Go back to the **Menu > Power Query** and add a Report Configuration

![Image](../_screenshots/ascreenshot46.jpeg)


17\. Don't forget to chose the country office the report belongs to. Chose the report title and the appropriate query.

![Image](../_screenshots/ascreenshot47.jpeg)


18\. Click "Template for a bank in Belarus" as formatter and move it to the **Chosen formatters.**

![Image](../_screenshots/ascreenshot48.jpeg)


19\. Click "Choose"

![Image](../_screenshots/ascreenshot49.jpeg)


20\. Save.

![Image](../_screenshots/ascreenshot50.jpeg)


21\. And "Queue" in order to generate the requested template

![Image](../_screenshots/ascreenshot51.jpeg)


22\. Click "VIEW ON SITE" if you want to look at the result.

![Image](../_screenshots/ascreenshot52.jpeg)


23\. Click "view"

![Image](../_screenshots/ascreenshot53.jpeg)


24\. Click "Template Report For Bank"

![Image](../_screenshots/ascreenshot54.jpeg)
60 changes: 60 additions & 0 deletions docs/components/reporting/tutorials/hh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Generate a report on information related to a list of households


1\. Navigate to [https://reporting-hope-dev.unitst.org/admin/](https://reporting-hope-dev.unitst.org/admin/)


2\. Click "Add"

![Image](../_screenshots/ascreenshot25.jpeg)


3\. Type "Information in a list of Households" in the name field


4\. Click the target field and select "Household"

![Image](../_screenshots/ascreenshot26.jpeg)


5\. Switch to tab "Add query | HOPE Reporting site admin"


6\.
```python
hh_list= [
"HH-23-0271.6128",
"HH-23-0271.6129",
".......",
"HH-24-2546.2547"
]
result=list(conn.filter(unicef_id__in=hh_list).values("unicef_id", "program__name", "registration_data_import__name"))
```
we paste the list in the hh_list variable and filter the query for Households in that list.

![Image](../_screenshots/ascreenshot27.jpeg)


7\. Click this button.

![Image](../_screenshots/ascreenshot28.jpeg)


8\. Click "Queue"

![Image](../_screenshots/ascreenshot29.jpeg)


9\. Click "DATASETS"

![Image](../_screenshots/ascreenshot31.jpeg)


10\. Click "[ABSTRACT] Information in a list of Households"

![Image](../_screenshots/ascreenshot32.jpeg)


11\. Click "PREVIEW", you can view the data

![Image](../_screenshots/ascreenshot34.jpeg)
7 changes: 7 additions & 0 deletions docs/components/reporting/tutorials/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Database layout

At the core of this data retrieval process lies the utilization of Python and Django code. These programming languages provide the necessary tools to extract and manipulate data from the database, enabling the creation of reports that are both informative and visually appealing.

To gain a comprehensive understanding of the available data within the Hope Database, it is essential to refer to the GitHub repository at this [link](https://github.com/unicef/hope-country-report/blob/develop/src/hope_country_report/apps/hope/models/_inspect.py) .

![Image](../_screenshots/Pasted_image1.png)
Loading

0 comments on commit a3c7e8e

Please sign in to comment.