Skip to content

Commit

Permalink
add more option on satifsaction rate report
Browse files Browse the repository at this point in the history
  • Loading branch information
mbayopanda committed Feb 5, 2024
1 parent 2580145 commit c334497
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 21 deletions.
1 change: 1 addition & 0 deletions client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@
"QUANTITY_ORDERED": "Quantity ordered",
"QUANTITY": "Quantity",
"QUANTITY_VALIDATED": "Quantity validated",
"QUANTITY_ORDERED_VALIDATED": "Validated order",
"RANK": "Rank",
"RATE": "Rate",
"RECEIPT_RENDERER_SETTING": "Receipt Format",
Expand Down
6 changes: 5 additions & 1 deletion client/src/i18n/en/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@
"TOTAL_DAYS" : "Total Days",
"RATIO" : "Ratio"
},
"SATISFACTION_RATE_REPORT" : "Satisfaction rate report",
"SATISFACTION_RATE_REPORT": {
"TITLE": "Satisfaction rate report",
"INCLUDE_SUMMARY": "Include satisfaction summary",
"INCLUDE_QUANTITY_DETAILS": "Include quantity details"
},
"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/fr/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@
"QUANTITY_ORDERED": "Quantité commandée",
"QUANTITY": "Quantité",
"QUANTITY_VALIDATED": "Quantité validée",
"QUANTITY_ORDERED_VALIDATED": "Commande validée",
"RANK": "Rang",
"RATE": "TAUX",
"RECEIPT_RENDERER_SETTING": "Format du Reçu",
Expand Down
6 changes: 5 additions & 1 deletion client/src/i18n/fr/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@
"TITLE": "Consommations mensuelles",
"DESCRIPTION": "Rapport de consommations mensuelles par dépôt et pour une période données"
},
"SATISFACTION_RATE_REPORT" : "Rapport des taux de satisfaction",
"SATISFACTION_RATE_REPORT": {
"TITLE": "Rapport des taux de satisfaction",
"INCLUDE_SUMMARY": "Inclure le resumé de la satisfaction",
"INCLUDE_QUANTITY_DETAILS": "Inclure les détails des quantités"
},
"SYSTEM_USAGE_STAT" : {
"TITLE" : "Statistique d'utilisation du système",
"DESCRIPTION" : "Ce rapport produit, pour une période donnée, les statistiques suivantes: total des patients enregistrés par heure de la journée, total des factures établies par heure de la journée et total des paiements en espèces effectués par heure de la journée"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,22 @@ <h3 class="text-capitalize" translate>TREE.SATISFACTION_RATE_REPORT</h3>
required="true"
limit-min-fiscal>
</bh-date-interval>
<hr>

<div class="checkbox">
<label>
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.includeSummary" ng-true-value="1" ng-false-value="0">
<span translate>REPORT.SATISFACTION_RATE_REPORT.INCLUDE_SUMMARY</span>
</label>
</div>

<div class="checkbox">
<label>
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.includeQuantityDetails" ng-true-value="1" ng-false-value="0">
<span translate>REPORT.SATISFACTION_RATE_REPORT.INCLUDE_QUANTITY_DETAILS</span>
</label>
</div>

<br>

<bh-loading-button loading-state="ConfigForm.$loading">
<span translate>REPORT.UTIL.PREVIEW</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,60 @@
<div class="row">
<div class="col-xs-12">

{{#if option.includeSummary}}
<table class="table table-condensed table-report">
<tr>
<th>&nbsp;</th>
{{#if option.includeQuantityDetails}}<th>{{translate 'FORM.LABELS.SATISFACTION_RATE_QUANTITY_GRANTED'}}</th>{{/if}}
<th>{{translate 'FORM.LABELS.SATISFACTION_RATE_BY_ITEMS_GRANTED'}}</th>
</tr>
<tr>
<td>Nombre des structures</td>
{{#if option.includeQuantityDetails}}<td>{{ option.summary.totalBeneficiary}}</td>{{/if}}
<td>{{ option.summary.totalBeneficiary}}</td>
</tr>
<tr>
<td>Nombre des structures ayant satisfait (>= 80%)</td>
{{#if option.includeQuantityDetails}}<td>{{ option.summary.totalSatisfactionQuantity}}</td>{{/if}}
<td>{{ option.summary.totalSatisfactionItem}}</td>
</tr>
<tr>
<td>Satisfaction des structures</td>
{{#if option.includeQuantityDetails}}<td>{{percentage option.summary.totalSatisfactionQuantityRate}}</td>{{/if}}
<td>{{percentage option.summary.totalSatisfactionItemRate}}</td>
</tr>
</table>
<br>
{{/if}}

{{#each depotsListSupplier}}
<table class="table table-condensed table-report">
<thead>
<tr style="background-color: #DEDEDE;">
<th colspan="9">{{ depot_text}}</th>
<th colspan="{{#if ../option.includeQuantityDetails}}9{{else}}8{{/if}}">{{ depot_text}}</th>
</tr>
</thead>
<tr style="background-color: #1F1F1F;">
<th colspan="9"> </th>
<th colspan="{{#if ../option.includeQuantityDetails}}9{{else}}8{{/if}}"> </th>
</tr>
{{#if ../option.includeQuantityDetails}}
<tr>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #DEDEDE; text-transform: uppercase;" colspan="8"> {{translate 'FORM.LABELS.SATISFACTION_RATE_QUANTITY_GRANTED'}} </td>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #DEDEDE; text-transform: uppercase;"><strong>{{percentage satisfaction_rate_quantity}} </strong></td>
</tr>
{{/if}}
<tr>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #DEDEDE; text-transform: uppercase;" colspan="8"> {{translate 'FORM.LABELS.SATISFACTION_RATE_BY_ITEMS_GRANTED'}} </td>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #DEDEDE; text-transform: uppercase;" colspan="{{#if ../option.includeQuantityDetails}}8{{else}}7{{/if}}"> {{translate 'FORM.LABELS.SATISFACTION_RATE_BY_ITEMS_GRANTED'}} </td>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #DEDEDE; text-transform: uppercase;"><strong>{{percentage satisfaction_rate_item }}</strong></td>
</tr>
<tr style="background-color: #000;">
<th colspan="9"> </th>
<th colspan="{{#if ../option.includeQuantityDetails}}9{{else}}8{{/if}}"> </th>
</tr>
{{#each data}}
<thead>
<tr style="background-color: #EFEFEF;">
<th colspan="1" width="2%"> {{ add @index 1 }} </th>
<th colspan="8" width="98%"> {{ depot_requisition.beneficiary }} </th>
<th colspan="{{#if ../../option.includeQuantityDetails}}8{{else}}7{{/if}}" width="98%"> {{ depot_requisition.beneficiary }} </th>
</tr>
</thead>

Expand All @@ -48,8 +76,10 @@
<td width="10%"> {{translate 'FORM.LABELS.REQUISITION' }} </td>
<td width="10%"> {{translate 'FORM.LABELS.MOVEMENT'}} </td>
<td width="25%"> {{translate 'FORM.LABELS.PRODUCT'}} </td>
{{#if ../../option.includeQuantityDetails}}
<td width="10%"> {{translate 'FORM.LABELS.QUANTITY_ORDERED'}} </td>
<td width="10%"> {{translate 'FORM.LABELS.QUANTITY_VALIDATED'}} </td>
{{/if}}
<td width="10%"> {{translate 'FORM.LABELS.QUANTITY_ORDERED_VALIDATED'}} </td>
<td width="10%"> {{translate 'FORM.LABELS.QUANTITY_DELIVERED'}} </td>
<td width="10%"> {{translate 'FORM.LABELS.SATISFACTION_RATE'}} </td>
</tr>
Expand All @@ -60,22 +90,26 @@
<td> {{ requisition_reference }} </td>
<td> {{ stock_movement_text }} </td>
<td> {{ inventory_text }} </td>
<td style="text-align: right;"> {{ quantity_requested }} </td>
{{#if ../../../option.includeQuantityDetails}}
<td style="text-align: right;"> {{ quantity_requested }} </td>
{{/if}}
<td style="text-align: right;"> {{ quantity_validated }} </td>
<td style="text-align: right;"> {{ quantity_delivered }} </td>
<td style="text-align: right;"><strong>{{percentage satisfaction_rate }}</strong></td>
</tr>
{{/each}}
{{#if ../../option.includeQuantityDetails}}
<tr>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #EBEBEB; text-transform: uppercase;" colspan="8"> {{translate 'FORM.LABELS.SATISFACTION_RATE_QUANTITY_GRANTED'}} </td>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #EBEBEB; text-transform: uppercase;"><strong>{{percentage depot_requisition.satisfaction_rate_quantity }} </strong></td>
</tr>
{{/if}}
<tr>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #ECECEC; text-transform: uppercase;" colspan="8"> {{translate 'FORM.LABELS.SATISFACTION_RATE_BY_ITEMS_GRANTED'}} </td>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #ECECEC; text-transform: uppercase;" colspan="{{#if ../../option.includeQuantityDetails}}8{{else}}7{{/if}}"> {{translate 'FORM.LABELS.SATISFACTION_RATE_BY_ITEMS_GRANTED'}} </td>
<td style="font-weight: bold; font-style: italic; text-align: right; background-color: #ECECEC; text-transform: uppercase;"><strong>{{percentage depot_requisition.satisfaction_rate_item }}</strong></td>
</tr>
<tr style="background-color: #000;">
<th colspan="9"> </th>
<th colspan="{{#if ../../option.includeQuantityDetails}}9{{else}}8{{/if}}"> </th>
</tr>
</tbody>
{{/each}}
Expand Down
58 changes: 49 additions & 9 deletions server/controllers/stock/reports/stock/satisfaction_rate_report.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const {
_, ReportManager, SATISFACTION_RATE_REPORT_TEMPLATE,
_,
ReportManager,
SATISFACTION_RATE_REPORT_TEMPLATE,
} = require('../common');

const satisfaction = require('./satisfaction');
Expand All @@ -17,27 +19,65 @@ const satisfaction = require('./satisfaction');
* @param {object} next - next middleware object to pass control to
*/
function satisfactionRateReport(req, res, next) {

reporting(req.query, req.session).then(result => {

res.set(result.headers).send(result.report);
}).catch(next);
reporting(req.query, req.session)
.then((result) => {
res.set(result.headers).send(result.report);
})
.catch(next);
}

async function reporting(_options, session) {
const { dateFrom, dateTo } = _options;
const {
dateFrom, dateTo, includeQuantityDetails, includeSummary,
} = _options;

const optionReport = _.extend(_options, {
filename : 'TREE.SATISFACTION_RATE_REPORT',
});

const report = new ReportManager(SATISFACTION_RATE_REPORT_TEMPLATE, session, optionReport);
const report = new ReportManager(
SATISFACTION_RATE_REPORT_TEMPLATE,
session,
optionReport,
);

const { depotUuids } = optionReport;

const data = await satisfaction.getSatisfactionData({ dateFrom, dateTo, depotUuids });
const data = await satisfaction.getSatisfactionData({
dateFrom,
dateTo,
depotUuids,
});

optionReport.suppliersListe = data.suppliersList;
optionReport.includeQuantityDetails = includeQuantityDetails === '1';
optionReport.includeSummary = includeSummary === '1';

let totalBeneficiary = 0;
let totalSatisfactionItem = 0;
let totalSatisfactionQuantity = 0;
data.depotsListSupplier.map(supplier => {
supplier.data.forEach(beneficiary => {
totalBeneficiary += 1;
if (beneficiary.depot_requisition && beneficiary.depot_requisition.satisfaction_rate_item * 100 >= 80) {
totalSatisfactionItem += 1;
}
if (beneficiary.depot_requisition && beneficiary.depot_requisition.satisfaction_rate_quantity * 100 >= 80) {
totalSatisfactionQuantity += 1;
}
});
return supplier;
});

const summary = {};
summary.totalBeneficiary = totalBeneficiary;
summary.totalSatisfactionItem = totalSatisfactionItem;
summary.totalSatisfactionItemRate = totalSatisfactionItem / (!totalBeneficiary ? 1 : totalBeneficiary);
summary.totalSatisfactionQuantity = totalSatisfactionQuantity;
summary.totalSatisfactionQuantityRate = totalSatisfactionQuantity / (!totalBeneficiary ? 1 : totalBeneficiary);
optionReport.summary = summary;

// export option
data.option = optionReport;

return report.render(data);
Expand Down

0 comments on commit c334497

Please sign in to comment.