Skip to content

Creating a Template Report for a Bank in Belarus

1. Navigate to https://reporting-hope-dev.unitst.org/admin/ ⧉

2. Scroll down to "Queries"

Image

3. Click on "ADD QUERY"

Image

4. Add "Belarus" to the "Country office" field.

Image

5. Fill in the "Name" field with "Template for a bank".

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

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

7. We will produce a report based on the Payments made recently in Belarus. So, we choose the Payment table as the target for our report.

Image

8. Save and continue editing.

Image

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

Image

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

Image

11. We now need to create a formatter as requested by the bank. This will allow us to produce a text file that resembles the one required by the bank. Navigate to Home > Power Query and click "Add" on the "Formatters" row.

Image

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

13. Click the "Code" area.

Image

14. In the code area, paste the following html code:

<table></table>

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

Image

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

Image

17. Don't forget to choose the country office the report belongs to. Choose the report title and the appropriate query.

Image

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

Image

19. Click "Choose"

Image

20. Save.

Image

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

Image

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

Image

23. Click "view"

Image

24. Click "Template Report For Bank"

Image