Skip to content

Commit

Permalink
Merge #5106 #5120 #5122
Browse files Browse the repository at this point in the history
5106: feat(stock): receipt component stock movements r=jniles a=jniles

Adds a component similar to `bhReceipt` specifically for stock movements.  We cannot use `bhReceipt` because stock movements have wildly different receipts depending on the kind of stock movement.

5120: Fix stockImport procedure r=jniles a=mbayopanda

This PR is about : 

- Update the `ImportStock` procedure to fix : 
  - MySQL data too long error when the `stockLotQuantity` and `inventoryUnitCost` are not in the good format
  - Error related to `inventory_uuid` is null during the importation
  - Error related to `inventory_unit` with its `abbr` column which must be unique during the importation

- Add inventories to `inventory_group` defined by its code instead of the inventory group name in the template file

NOTE:
- The CMM is not changed by the import since we are using the `stock_movement_status` table, the CMM defined in the template file is successfully saved in the `avg_consumption` column of the inventory.


5122: improvement(Break Even Report) r=jniles a=lomamech

- Eliminate whitespace and not necessary `<hr>`
- Remove property bold on checkboxes and radios buttons

closes #4940

Co-authored-by: Jonathan Niles <jonathanwniles@gmail.com>
Co-authored-by: mbayopanda <mbayopanda@gmail.com>
Co-authored-by: Chris Lomame <lomamech@gmail.com>
  • Loading branch information
4 people authored Nov 21, 2020
4 parents 97a5629 + 85791f0 + ef4dda7 + f25db13 commit c8bbc19
Show file tree
Hide file tree
Showing 14 changed files with 274 additions and 168 deletions.
2 changes: 2 additions & 0 deletions client/src/i18n/en/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"NO_EXCHANGE_RATE" : "No Exchange rate defined",
"NO_FISCAL_YEAR" : "You are missing a fiscal year for that date!",
"NOT_ALLOWED" : "You are not allowed to perform this action",
"NOT_A_NUMBER" : "You did not provide a number to a field intended for a number",
"NOT_A_TEXT" : "You did not provide valid text in a text field",
"NOT_FOUND" : "This record could not be found",
"NO_PERMISSIONS" : "The login succeeded, but you have no permissions. Please see a system administrator.",
"NO_PROJECT" : "No permissions for that project. Please see a system administrator",
Expand Down
2 changes: 2 additions & 0 deletions client/src/i18n/fr/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"NO_EXCHANGE_RATE" : "Aucun taux de change defini pour aujourd'hui!",
"NOT_ALLOWED" : "Vous n'etes pas authorisé à faire cette action",
"NOT_FOUND" : "Cet enregistrement n'a pas pu être trouvé",
"NOT_A_NUMBER" : "Vous n'avez pas fourni un nombre à un champs destiné à un nombre",
"NOT_A_TEXT" : "Vous n'avez pas fourni un texte valide dans un champs destiné à un texte",
"NO_PERMISSIONS" : "La connexion a réussi, mais vous n'avez aucune autorisation. Veuillez contacter un administrateur système.",
"NO_PROJECT" : "Aucune autorisation pour ce projet, Veuillez contacter un administrateur système",
"NO_FISCAL_YEAR" : "Aucune année fiscale pour cette date!",
Expand Down
32 changes: 32 additions & 0 deletions client/src/js/components/bhStockReceipt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const bhStockReceiptTemplate = `
<a ng-click="$ctrl.open()" href="" translate>
{{ $ctrl.displayValue }}
</a>`;

angular.module('bhima.components')
.component('bhStockReceipt', {
template : bhStockReceiptTemplate,
controller : bhStockReceiptController,
bindings : {
value : '<',
displayValue : '<',
fluxId : '<',
},
});

bhStockReceiptController.$inject = ['ReceiptModal', '$log'];

function bhStockReceiptController(ReceiptModal, $log) {
const $ctrl = this;

$ctrl.$onInit = () => {
// make sure the receipt type exists before it is clicked
const hasCallbackFn = ReceiptModal.getReceiptFnByFluxId($ctrl.fluxId);

if (!hasCallbackFn) {
$log.error(`Warning: Cannot find a stock receipt for flux ${$ctrl.fluxId} in ReceiptModalService!`);
}
};

$ctrl.open = () => ReceiptModal.getReceiptFnByFluxId($ctrl.fluxId)($ctrl.value);
}
25 changes: 22 additions & 3 deletions client/src/js/services/receipts/ReceiptModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ ReceiptModal.$inject = [
* This service is responsible for combining receipt service data with the
* receipts modal controller and providing a clean interface to be used within
* module controllers.
*
* @module services/receipts/ReceiptModal
*/
* @module services/receipts/ReceiptModal */
function ReceiptModal(Modal, Receipts, Invoice, Cash, Voucher) {
const service = this;

Expand Down Expand Up @@ -335,6 +333,7 @@ function ReceiptModal(Modal, Receipts, Invoice, Cash, Voucher) {
service.stockAdjustmentReport = stockAdjustmentReport;
service.stockAssignReceipt = stockAssignReceipt;
service.stockRequisitionReceipt = stockRequisitionReceipt;
service.getReceiptFnByFluxId = getReceiptFnByFluxId;

/**
* @method stockRequisitionReceipt
Expand Down Expand Up @@ -502,6 +501,26 @@ function ReceiptModal(Modal, Receipts, Invoice, Cash, Voucher) {
return ReceiptFactory(promise, opts);
}

const mapFlux = {
1 : stockEntryPurchaseReceipt,
2 : stockEntryDepotReceipt,
3 : stockAdjustmentReceipt,
6 : stockEntryDonationReceipt,
8 : stockExitDepotReceipt,
9 : stockExitPatientReceipt,
10 : stockExitServiceReceipt,
11 : stockExitLossReceipt,
12 : stockAdjustmentReceipt,
13 : stockEntryIntegrationReceipt,
14 : stockAdjustmentReceipt,
15 : stockAdjustmentReceipt,
};

//
function getReceiptFnByFluxId(fluxId) {
return mapFlux[fluxId];
}

/**
* @method ReceiptFactory
* @description A factory for receipts
Expand Down
12 changes: 4 additions & 8 deletions client/src/modules/reports/generate/breakEven/breakEven.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ <h3 class="text-capitalize" translate>TREE.BREAK_EVEN_REPORT</h3>
period-id="ReportConfigCtrl.reportDetails.period_id"
on-select-callback="ReportConfigCtrl.onSelectPeriod(period)">
</bh-period-selection>
<hr>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.breakEvenProject" ng-true-value="1" ng-false-value="0">
Expand All @@ -40,7 +39,6 @@ <h3 class="text-capitalize" translate>TREE.BREAK_EVEN_REPORT</h3>
</div>

<div ng-if="ReportConfigCtrl.reportDetails.breakEvenProject" class="checkbox">
<hr>
<label style="margin-left: 2.5%;">
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.includeManual" ng-true-value="1" ng-false-value="0">
<strong><em>
Expand All @@ -49,7 +47,6 @@ <h3 class="text-capitalize" translate>TREE.BREAK_EVEN_REPORT</h3>
</label>
</div>

<hr>
<!-- type -->
<div class="panel-body" ng-class="{'has-error' : ConfigForm.$submitted && ConfigForm.type.$invalid }">
<div class="radio">
Expand All @@ -61,9 +58,9 @@ <h3 class="text-capitalize" translate>TREE.BREAK_EVEN_REPORT</h3>
ng-model="ReportConfigCtrl.reportDetails.type"
id="use_patient_visit"
required>
<strong translate>
<span translate>
FORM.INFO.USE_PATIENT_VISIT
</strong>
</span>
</label>
</div>
<div class="radio">
Expand All @@ -75,16 +72,15 @@ <h3 class="text-capitalize" translate>TREE.BREAK_EVEN_REPORT</h3>
ng-model="ReportConfigCtrl.reportDetails.type"
id="use_dashboard"
required>
<strong translate>
<span translate>
FORM.INFO.USE_INDICATOR_DASHBOARD
</strong>
</span>
</label>
<div class="help-block" ng-messages="ConfigForm.type.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>
<hr>

<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 @@ -31,8 +31,7 @@ <h3 translate>TREE.BREAK_EVEN_FEE_CENTER_REPORT</h3>
period-id="ReportConfigCtrl.reportDetails.period_id"
on-select-callback="ReportConfigCtrl.onSelectPeriod(period)">
</bh-period-selection>
<hr>
<!-- type -->

<div class="panel-body" ng-class="{'has-error' : ConfigForm.$submitted && ConfigForm.type.$invalid }">
<div class="radio">
<label class="radio-inline">
Expand All @@ -43,9 +42,9 @@ <h3 translate>TREE.BREAK_EVEN_FEE_CENTER_REPORT</h3>
ng-model="ReportConfigCtrl.reportDetails.type"
id="use_patient_visit"
required>
<strong translate>
<span translate>
FORM.INFO.USE_PATIENT_VISIT
</strong>
</span>
</label>
</div>
<div class="radio">
Expand All @@ -57,25 +56,22 @@ <h3 translate>TREE.BREAK_EVEN_FEE_CENTER_REPORT</h3>
ng-model="ReportConfigCtrl.reportDetails.type"
id="use_dashboard"
required>
<strong translate>
<span translate>
FORM.INFO.USE_INDICATOR_DASHBOARD
</strong>
</span>
</label>
<div class="help-block" ng-messages="ConfigForm.type.$error" ng-show="ConfigForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<hr>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.includeManual" ng-true-value="1" ng-false-value="0">
<span translate>TABLE.COLUMNS.INCLUDE_MANUAL_DISTRIBUTIONS</span>
</label>
</div>

<hr>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.defineFeeCenters" ng-true-value="1" ng-false-value="0">
Expand All @@ -88,11 +84,10 @@ <h3 translate>TREE.BREAK_EVEN_FEE_CENTER_REPORT</h3>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="ReportConfigCtrl.reportDetails.feeCenters[fee.id]" ng-true-value="{{fee.id}}" ng-false-value="0">
<span> <strong> {{fee.label}} </strong> </span>
<span> {{fee.label}} </span>
</label>
</div>
</div>
</hr>

<bh-loading-button loading-state="ConfigForm.$loading">
<span translate>REPORT.UTIL.PREVIEW</span>
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/import/stockImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ StockImportController.$inject = [
* This module helps to import stock from a file
*/
function StockImportController(
Notify, Stock, Upload, $state
Notify, Stock, Upload, $state,
) {
const vm = this;

Expand Down
39 changes: 18 additions & 21 deletions client/src/modules/stock/movements/modals/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
<uib-tabset>
<uib-tab index="0" heading="{{'FORM.LABELS.SEARCH_QUERIES' | translate}}" data-custom-filter-tab>
<div class="tab-body">
<!-- movements -->
<div class="form-group">
<bh-clear on-clear="$ctrl.clear('is_exit')"></bh-clear>
<br/>
<div id="movement_orientation" class="form-group">

<!-- movement direction -->
<div id="movement_orientation" class="form-group">
<label class="control-label" translate>STOCK.DIRECTION</label>
<div class="col-md-12">
<bh-clear on-clear="$ctrl.clear('is_exit')"></bh-clear>
<div>
<label class="radio-inline">
<input type="radio" name="movement_direction" id="entry" value="0" ng-model="$ctrl.searchQueries.is_exit">
<span translate>STOCK.INPUT</span>
Expand All @@ -33,8 +32,6 @@
</label>
</div>
</div>
</div>
<br/>

<!-- reference -->
<div class="form-group" ng-class="{ 'has-error' : ModalForm.reference.$invalid }">
Expand All @@ -59,19 +56,19 @@
<bh-clear on-clear="$ctrl.clear('depot_uuid')"></bh-clear>
</bh-depot-select>

<!-- inventory -->
<bh-inventory-select
inventory-uuid="$ctrl.searchQueries.inventory_uuid"
on-select-callback="$ctrl.onSelectInventory(inventory)"
required="false">
<bh-clear on-clear="$ctrl.clear('inventory_uuid')"></bh-clear>
</bh-inventory-select>

<!-- lot number -->
<div class="form-group">
<label class="control-label" translate>STOCK.LOT</label>
<bh-clear on-clear="$ctrl.clear('label')"></bh-clear>
<input type="text" class="form-control" name="label" ng-model="$ctrl.searchQueries.label">
<!-- inventory -->
<bh-inventory-select
inventory-uuid="$ctrl.searchQueries.inventory_uuid"
on-select-callback="$ctrl.onSelectInventory(inventory)"
required="false">
<bh-clear on-clear="$ctrl.clear('inventory_uuid')"></bh-clear>
</bh-inventory-select>

<!-- lot number -->
<div class="form-group">
<label class="control-label" translate>STOCK.LOT</label>
<bh-clear on-clear="$ctrl.clear('label')"></bh-clear>
<input type="text" class="form-control" name="label" ng-model="$ctrl.searchQueries.label">
</div>

<!-- Requisition -->
Expand Down
24 changes: 1 addition & 23 deletions client/src/modules/stock/movements/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ function StockMovementsController(
// add in FLUX identifiers
vm.flux = bhConstants.flux;

// bind flux id with receipt
const mapFlux = {
1 : { receipt : ReceiptModal.stockEntryPurchaseReceipt },
2 : { receipt : ReceiptModal.stockEntryDepotReceipt },
3 : { receipt : ReceiptModal.stockAdjustmentReceipt },
6 : { receipt : ReceiptModal.stockEntryDonationReceipt },
8 : { receipt : ReceiptModal.stockExitDepotReceipt },
9 : { receipt : ReceiptModal.stockExitPatientReceipt },
10 : { receipt : ReceiptModal.stockExitServiceReceipt },
11 : { receipt : ReceiptModal.stockExitLossReceipt },
12 : { receipt : ReceiptModal.stockAdjustmentReceipt },
13 : { receipt : ReceiptModal.stockEntryIntegrationReceipt },
14 : { receipt : ReceiptModal.stockAdjustmentReceipt },
15 : { receipt : ReceiptModal.stockAdjustmentReceipt },
};

// grouping box
vm.groupingBox = [
{ label : 'STOCK.IO', value : 'io' },
Expand Down Expand Up @@ -118,7 +102,7 @@ function StockMovementsController(
vm.openColumnConfigModal = openColumnConfigModal;
vm.onRemoveFilter = onRemoveFilter;
vm.getFluxName = getFluxName;
vm.openReceiptModal = openReceiptModal;
vm.openReceiptModal = (uuid, fluxId) => ReceiptModal.getReceiptFnByFluxId(fluxId)(uuid);
vm.toggleGroup = toggleGroup;
vm.selectGroup = selectGroup;
vm.getQueryString = getQueryString;
Expand Down Expand Up @@ -154,12 +138,6 @@ function StockMovementsController(
}
}

// generate document by type of flux
function openReceiptModal(documentUuid, fluxId) {
if (!mapFlux[fluxId]) { return; }
mapFlux[fluxId].receipt(documentUuid);
}

// on remove one filter
function onRemoveFilter(key) {
stockMovementsFilters.remove(key);
Expand Down
6 changes: 3 additions & 3 deletions client/src/modules/stock/movements/templates/action.cell.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="ui-grid-cell-contents text-action" uib-dropdown dropdown-append-to-body uib-dropdown-toggle ng-if="!row.groupHeader">
<div class="ui-grid-cell-contents text-right" uib-dropdown dropdown-append-to-body uib-dropdown-toggle ng-if="!row.groupHeader">
<a href>
<span data-method="action" translate>FORM.BUTTONS.ACTIONS</span>
<span class="caret"></span>
</a>

<ul data-action="{{rowRenderIndex}}" class="dropdown-menu-right" bh-dropdown-menu-auto-dropup uib-dropdown-menu>
<ul class="dropdown-menu-right" bh-dropdown-menu-auto-dropup uib-dropdown-menu>
<li class="bh-dropdown-header">{{row.entity.documentReference}}</li>
<li>
<a data-method="receipt" ng-click="grid.appScope.openReceiptModal(row.entity.document_uuid, row.entity.flux_id)" data-link-receipt="{{ ::row.entity.document_uuid }}" href>
<a data-method="receipt" ng-click="grid.appScope.openReceiptModal(row.entity.document_uuid, row.entity.flux_id)" data-link-receipt="{{ row.entity.document_uuid }}" href>
<i class="fa fa-file-pdf-o"></i> <span translate>STOCK.DOCUMENT</span>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div class="ui-grid-cell-contents">
<a href ng-click="grid.appScope.openReceiptModal(row.entity.document_uuid, row.entity.flux_id)">{{row.entity.documentReference}}</a>
<div class="ui-grid-cell-contents" ng-if="!row.groupHeader">
<bh-stock-receipt
value="row.entity.document_uuid"
flux-id="row.entity.flux_id"
display-value="row.entity.documentReference">
</bh-stock-receipt>
</div>
Loading

0 comments on commit c8bbc19

Please sign in to comment.