Skip to content

Commit

Permalink
feature(Implement rumer report)
Browse files Browse the repository at this point in the history
- Implement the rumer report
Note: This PR requires the execution of updates in the migrate file

closes #5395
  • Loading branch information
lomamech committed Apr 30, 2021
1 parent 5a9cffc commit 657b850
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 4 deletions.
8 changes: 8 additions & 0 deletions client/src/i18n/en/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@
"DESCRIPTION": "This report shows the difference between what we purchase with what we have entered in the stock.",
"TITLE": "Purchase Order Analysis"
},
"RUMER": {
"DESCRIPTION": "Drug Usage and Recipe Register",
"INCLUDE_OUT_STOCK_ITEMS": "Include out-of-stock items",
"STOCK_BEGINNING": "Stock at the beginning of the month",
"STOCK_END": "Stock at the end of the month",
"TITLE": "RUMER",
"TOTAL_ENTRIES": "Total entries for the month"
},
"STOCK_VALUE": {
"TITLE": "Stock value report",
"DESCRIPTION": "This report shows the current stock value for each inventory in a depot",
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/en/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"ROLE_MANAGEMENT" : "Role Management",
"ROOT" : "Root",
"RUBRIC_MANAGEMENT" : "Rubrics Management",
"RUMER_REPORT" : "Rumer",
"SERVICE" : "Services",
"SIMPLE_VOUCHER" : "Simple Voucher",
"STAFFING_INDICES_MANAGEMENT" : "Staffing indices management",
Expand Down
8 changes: 8 additions & 0 deletions client/src/i18n/fr/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@
"TITLE": "Situation financière d'un Patient",
"TOTAL_ALL_STOCK_MOV": "Total de tous les mouvements de stocks"
},
"RUMER": {
"DESCRIPTION": "Registre d’utilisation des médicaments et recettes",
"INCLUDE_OUT_STOCK_ITEMS": "Inclure les articles en rupture de stock",
"STOCK_BEGINNING": "Stock au début du mois",
"STOCK_END": "Stock à la fin du mois",
"TITLE": "RUMER",
"TOTAL_ENTRIES": "Total des entrées du mois"
},
"PURCHASE_ORDER_ANALYSIS": {
"DESCRIPTION": "Ce rapport permet de connaitre la différence entre ce la quantité commandée et la quantité entrée en stock",
"TITLE": "Analyse de commande d'achat"
Expand Down
1 change: 1 addition & 0 deletions client/src/i18n/fr/tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"ROLE_MANAGEMENT":"Gestion des rôles",
"ROOT":"Racine",
"RUBRIC_MANAGEMENT":"Gestion Rubriques",
"RUMER_REPORT" : "Rumer",
"SERVICE":"Services",
"SIMPLE_VOUCHER":"Bordereau de transfert",
"STAFFING_INDICES_MANAGEMENT" : "Gestion des indices de paie",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
angular.module('bhima.controllers')
.controller('rumer_reportController', rumerReportController);

rumerReportController.$inject = [
'$sce', 'NotifyService', 'BaseReportService', 'AppCache', 'reportData', '$state',
'LanguageService',
];

function rumerReportController($sce, Notify, SavedReports, AppCache, reportData, $state, Languages) {
const vm = this;
const cache = new AppCache('rumer_report');
const reportUrl = 'reports/stock/rumer_report';

// default values
vm.reportDetails = {
includePurchaseEntry : 1,
};
vm.previewGenerated = false;

// check cached configuration
checkCachedConfiguration();

vm.onSelectDepot = depot => {
vm.reportDetails.depotUuid = depot.uuid;
vm.reportDetails.depot_text = depot.text;
};

vm.onSelectFiscalYear = (fiscalYear) => {
vm.reportDetails.fiscal_id = fiscalYear.id;
vm.reportDetails.fiscalYearStart = fiscalYear.start_date;
};

vm.onSelectPeriod = (period) => {
vm.reportDetails.period_id = period.id;
vm.reportDetails.end_date = period.end_date;
vm.reportDetails.start_date = period.start_date;
};

vm.clear = key => {
delete vm[key];
};

vm.clearPreview = () => {
vm.previewGenerated = false;
vm.previewResult = null;
};

vm.preview = form => {
if (form.$invalid) {
return 0;
}

// update cached configuration
cache.reportDetails = angular.copy(vm.reportDetails);
angular.extend(vm.reportDetails, { lang : Languages.key });

return SavedReports.requestPreview(reportUrl, reportData.id, angular.copy(vm.reportDetails))
.then((result) => {
vm.previewGenerated = true;
vm.previewResult = $sce.trustAsHtml(result);
})
.catch(Notify.handleError);
};

vm.requestSaveAs = function requestSaveAs() {
const options = {
url : reportUrl,
report : reportData,
reportOptions : angular.copy(vm.reportDetails),
};

return SavedReports.saveAsModal(options)
.then(() => {
$state.go('reportsBase.reportsArchive', { key : options.report.report_key });
})
.catch(Notify.handleError);
};

function checkCachedConfiguration() {
vm.reportDetails = angular.copy(cache.reportDetails || {});
}

}
63 changes: 63 additions & 0 deletions client/src/modules/reports/generate/rumer_report/rumer_report.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<bh-report-preview
ng-if="ReportConfigCtrl.previewGenerated"
source-document="ReportConfigCtrl.previewResult"
on-clear-callback="ReportConfigCtrl.clearPreview()"
on-save-callback="ReportConfigCtrl.requestSaveAs()">
</bh-report-preview>

<div ng-show="!ReportConfigCtrl.previewGenerated">
<div class="row">
<div class="col-md-12">
<h3 translate>REPORT.RUMER.TITLE</h3>
<p class="text-info" translate>REPORT.RUMER.DESCRIPTION</p>
</div>
</div>

<div class="row" style="margin-top : 10px">
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<span translate>REPORT.UTIL.OPTIONS</span>
</div>

<div class="panel-body">

<form name="ConfigForm" bh-submit="ReportConfigCtrl.preview(ConfigForm)" novalidate autocomplete="off">

<!-- select depot -->
<bh-depot-select
depot-uuid="ReportConfigCtrl.reportDetails.depotUuid"
on-select-callback="ReportConfigCtrl.onSelectDepot(depot)"
required="true">
</bh-depot-select>

<bh-fiscal-year-select
fiscal-id="ReportConfigCtrl.reportDetails.fiscal_id"
on-select-fiscal-callback="ReportConfigCtrl.onSelectFiscalYear(fiscalYear)">
</bh-fiscal-year-select>

<bh-period-selection
fiscal-year-id="ReportConfigCtrl.reportDetails.fiscal_id"
period-id="ReportConfigCtrl.reportDetails.period_id"
on-select-callback="ReportConfigCtrl.onSelectPeriod(period)">
</bh-period-selection>

<!-- <hr>
<bh-yes-no-radios
label="REPORT.RUMER.INCLUDE_OUT_STOCK_ITEMS"
value="ReportConfigCtrl.includeEmptyLot"
name="includeEmptyLot"
help-text="STOCK.INCLUDE_ARTICLES_NOT_IN_STOCK_HELP"
on-change-callback="ReportConfigCtrl.onSelectIncludeEmptyLot(value)">
</bh-yes-no-radios> -->

<!-- preview -->
<bh-loading-button loading-state="ConfigForm.$loading">
<span translate>REPORT.UTIL.PREVIEW</span>
</bh-loading-button>
</form>
</div>
</div>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions client/src/modules/reports/reports.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ angular.module('bhima.routes')
'stock_movement_report',
'stock_expiration_report',
'stock_changes',
'rumer_report',
];

function resolveReportData($stateParams, SavedReports) {
Expand Down
1 change: 1 addition & 0 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ exports.configure = function configure(app) {
app.get('/reports/stock/sheet', stockReports.stockSheetReport);
app.get('/reports/stock/value', stockReports.stockValue);
app.get('/reports/stock/monthly_consumption', stockReports.monthlyConsumption.report);
app.get('/reports/stock/rumer_report', stockReports.rumer.report);

// stock receipts API
app.get('/receipts/stock/:uuid', stockReports.renderStockReceipt);
Expand Down
1 change: 0 additions & 1 deletion server/controllers/stock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ function updateQuantityInStockAfterMovement(inventoryUuids, mvmtDate, depotUuid)
*/
async function insertNewStock(session, params) {
const transaction = db.transaction();
const identifier = uuid();
const documentUuid = uuid();

const period = await Fiscal.lookupFiscalYearByDate(params.movement.date);
Expand Down
1 change: 1 addition & 0 deletions server/controllers/stock/reports/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ exports.stockChangesReport = stockChangesReport;
exports.stockAdjustmentReceipt = stockAdjustmentReceipt;
exports.stockExitAggregateConsumptionReceipt = stockExitAggregateConsumptionReceipt;
exports.monthlyConsumption = require('./stock/monthly_consumption');
exports.rumer = require('./stock/rumer');
54 changes: 54 additions & 0 deletions server/controllers/stock/reports/rumer.report.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{{> head title="REPORT.MONTHLY_CONSUMPTION.TITLE" }}

<body class="container-fluid">
{{> header}}

<!-- body -->
<div class="row">
<div class="col-xs-12">
<!-- page title -->
<h2 class="text-center text-uppercase">
{{translate 'REPORT.RUMER.TITLE'}}
</h2>

<h5 class="text-center">{{translate 'REPORT.RUMER.DESCRIPTION'}}</h5>

<h3 class="text-center">{{params.depot_text}}</h3>
<p class="text-center">{{date params.start_date}} - {{date params.end_date}}</p>

<table class="table table-striped table-condensed table-report table-bordered">
<thead>
<tr style="background-color:#ddd;">
<th style="min-width:100px;">{{translate 'FORM.LABELS.INVENTORY'}}</th>
<th class="text-center"> {{translate 'REPORT.RUMER.STOCK_BEGINNING'}} </th>
<th class="text-center"> {{translate 'REPORT.RUMER.TOTAL_ENTRIES'}} </th>
{{#each header as | key |}}
<th style="min-width:20px;" class="text-center">{{key}}</th>
{{/each}}
<th style="width: 7.5%;" class="text-center">{{translate 'FORM.LABELS.TOTAL'}} </th>
<th style="width: 7.5%;" class="text-center">{{translate 'REPORT.RUMER.STOCK_END'}}</th>
</tr>
</thead>

<tbody>
{{#each configurationData}}
<tr>
<td> {{ inventoryText }} </td>
<td><strong> {{ quantityOpening }} </strong></td>
<td> {{ quantityTotalEntry }} </td>
{{#each dailyConsumption }}
<td class="text-right">
{{#if value}}
{{ value }}
{{/if}}
</td>
{{/each}}
<td><strong> {{ quantityTotalExit }} </strong></td>
<td><strong> {{ quantityEnding }} </strong></td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</body>
Loading

0 comments on commit 657b850

Please sign in to comment.