Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

...

Summary

Stock imbalance report show stock availability of all products under a given program, reporting facilities in a specified period.
Each record of the report will let the viewer know if a specified product is Stocked Out, Under Stocked, Adequately Stocked, Over Stocked or there is no demand for a give facility under a specified period.

Components

The Stock imbalance report will have the following columns:

...


Table 1 - Report filters with description
To access this report, first the user needs to login and should have the right to access the report. Once the user browse to the report, a page with the list of report filters mentioned above will appear.

Validation

When the page loads for the first time, all report filters should be unselected except the 'All' check box from Reporting type check boxes and 'All' checkbox from the Stock status type checkbox list.
To see report data in the report, the report viewer needs to select all the required filters - Program, Schedule, Year and Period. Once all the required fields are selected, the report will try to fetch data from server. If there are some un-selected filters which are required, the report won't try to load a data until all the required fields are selected.
For all required filters an asterisk sign with red color coded (*) will be seen beside the filter label.

Fetching

Once all the required fields are selected the report will automatically loads the data and one can change the report filters to fine tune the report data.

...

Description

Value for 'Status' column. Font color and icons should be the same

Calculation

If the user checks 'No Demand' filter checkbox checked, the report will shows data with AMC equals to zero (0).

⚠No Demand (AMC=0)

AMC = 0

If the user checks 'Stocked Out' filter checkbox checked, the report will show only stocked out products for facilities.

Stocked Out

Stock on hand = 0

If the user checks 'Over Stocked' checkbox checked, the report will show only overstocked products for facilities.

Over Stocked

Stock on hand / amc > maximum month of stock

If the user checks 'Adequately Stocked' checkbox checked, the report will show only adequately stocked products for facilities.

Adequately Stocked

Stock on hand / amc >= minimum month of stock
And
Stock on hand / amc >= maximum month of stock

If the user checks 'Under Stocked' filter checkbox checked, the report will show only under stocked products for facilities.

Under Stocked

Stock on hand / amc < minimum month of stock


Table 2 - Status column of stock imbalance report calculation and formatting

Pagination

If there is a report data based on the selection, the data will be seen in a tabular format on the HTML page with pagination buttons at the bottom of the page. The pagination is on client side and requires all the data to be loaded prior. The pagination links will be based on the row count of the data.
Apart from the pagination, there are small, horizontally stacked list of buttons on the bottom of the page to define the number of rows to show in a single paginated page. The list of buttons will have the following labels 10, 25, 50 100 consecutively. For example, If user clicks button with label '10', the number of rows that will be shown in the current page will be 10.

Data Formatting

On the report, column values for AMC, Closing Balance, MOS and order quantity are numbers separated by thousands separator and visually right aligned. The rest column values should be left aligned. The formatting for column Status can be inferred from Table 2.

Exporting

On the upper side of the report there will be two buttons for exporting the current report to PDF or XLS format. When the user clicks the PDF button, PDF version of the report will be opened in a new tab or in a new page. When the Excel button clicked, XLS export of the report will be downloaded.
The PDF output will have the country logo and below to that Report filters data used to fetch the report.


eLMIS Implementation
Stock imbalance report on eLMIS can be accessed from UAT site at https://uat.zm.elmis-dev.org or by running eLMIS locally by checking out the source code from {+}https://bitbucket.org/elmis-tzm/open-lmis.git+ and one can follow the README.md file to quickly setup the project on local machine.
To access the report from UAT server, one needs to have a login account with role 'View Reports' attached to it.

...

The Consumption report is developed using Jasper report from PDF and XLS output and HTML and AngularJS for the HTML preview.
In the eLMIS code base, all the reports are place under module called 'reports '

https://bitbucket.org/elmis-tzm/open-lmis/src/develop/modules/report/src/main/java/org/openlmis/report/


Under the report module we have three folders

  1. Java - Java code for fetching data from the database and transforming it to REST API
  2. Resources - This folder hold compiled jasper reports
  3. Template - This folder hold Jasper JRXML files. This is the place where we can find the report design to change report implementation.

...

To compile report files, user should navigate to the home directory of the project and issue the following command.

gradle compileJasperReport

Apart from the above command, run gradle task also compiles the report files as part of running the application. compileJasperReport compiles the jrxml files found under Template folder and move the compiled file under folder Resources.

Report End point


Under java folder listed above, we can find all the back-end resources for fetching and transforming report data from db. Under this folder there a number of other dedicated folder that their name can give some meaning. Amount all the folder there is one called controller which we can find a REST controller for the starting point for most report data.
For Consumption report, the report will fetch data from InteractiveReportController. We can see lots of REST resource in the class but for our report we will focus on getStockImbalanceData method. All export format of the report will call this resource via URL {_}http://ip:port/reports/reportdata/stockimbalance.json_ with parameter query string.

Call hierarchy

org.openlmis.report.controller.InteractiveReportController#getStockImbalanceData
   > org.openlmis.report.service.StockImbalanceReportDataProvider#getReportBody
       > org.openlmis.report.mapper.StockImbalanceReportMapper#getReport
          > org.openlmis.report.builder.StockImbalanceQueryBuilder#getReportQuery


How is the HTML report organised

The HTML report is designed with HTML and AngularJS. Basically all report format PDF, XLS and HTML use the same java REST endpoint to fetch a report data from the db. All HTML reports gets loaded by the following file
modules/openlmis-web/src/main/webapp/public/pages/reports/main/index.html

All report related resources like js and css files and also html partial pages will be loaded in to the above file using AngularJS routing feature.

When one browse to the consumption report URL on the site, AngularJs will load index.html page and render
modules/openlmis-web/src/main/webapp/public/pages/reports/main/partials/stock-imbalance.html partial page in to it.

If one opens and see the stock-imbalance.html file its possible to see HTML section that will render the list of report filters that we saw on the screenshot. For example, to add a program filter in stock-imbalance.html we can add with the following code block.

<program-filter class="form-cell horizontalFilters" required="true"></program-filter>

The above code renders the program report filter in the report page. Each report filters are composed as angular directive. One can find the list of filter directive definitions at

modules/openlmis-web/src/main/webapp/public/js/reports/shared/directives/filters.js

Each report filter that one can see in the report can be found in filters.js. Those directives calls a backend service to populate the filter control with data. The angular services that will be called by each filters and reports are found in

modules/openlmis-web/src/main/webapp/public/js/shared/services/extension-services.js

Once the report get loaded and when the report viewer selected data on all required filters, $scope.OnFilterChanged method will be called in the following js file

modules/openlmis-web/src/main/webapp/public/js/reports/main/controller/stock-imbalance-controller.js

With in this AngularJS controller method, the java REST endpoint will be called to fetch the report data.


On the report page, there are two buttons at the top of the page for exporting the report on other formats. If a user wants to export the current HTML report to PDF, he/she need to click the button with the label PDF. When that button get clicked, $scope.exportReport method of the stock-imbalance-controller.js


file will be called.