Skip to content

Commit

Permalink
Merge #2498
Browse files Browse the repository at this point in the history
2498: Add group in the inventory group registry r=jniles a=mbayopanda

This PR add the group column in the stock inventory registry
  • Loading branch information
bors[bot] committed Feb 2, 2018
2 parents 2391f15 + be45474 commit 77034be
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 33 deletions.
93 changes: 61 additions & 32 deletions client/src/modules/stock/inventories/registry.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
angular.module('bhima.controllers')
.controller('StockInventoriesController', StockInventoriesController);
.controller('StockInventoriesController', StockInventoriesController);

StockInventoriesController.$inject = [
'StockService', 'NotifyService',
'uiGridConstants', '$translate', 'StockModalService','LanguageService', 'SessionService',
'GridGroupingService', 'bhConstants', 'GridStateService', '$state', 'GridColumnService'
'uiGridConstants', '$translate', 'StockModalService', 'LanguageService', 'SessionService',
'GridGroupingService', 'bhConstants', 'GridStateService', '$state', 'GridColumnService',
];

/**
Expand All @@ -23,80 +23,109 @@ function StockInventoriesController(
var gridColumns;

var columns = [
{ field : 'depot_text',
{
field : 'depot_text',
displayName : 'STOCK.DEPOT',
headerCellFilter : 'translate' },
headerCellFilter : 'translate',
},

{ field : 'code',
{
field : 'code',
displayName : 'STOCK.CODE',
headerCellFilter : 'translate' },
headerCellFilter : 'translate',
},

{ field : 'text',
{
field : 'text',
displayName : 'STOCK.INVENTORY',
headerCellFilter : 'translate',
width : '20%' },
width : '20%',
},

{ field : 'quantity',
{
field : 'group_name',
displayName : 'STOCK.INVENTORY_GROUP',
headerCellFilter : 'translate',
},

{
field : 'quantity',
displayName : 'STOCK.QUANTITY',
headerCellFilter : 'translate',
cellClass : 'text-right'
cellClass : 'text-right',
},

{ field : 'unit_type',
{
field : 'unit_type',
width : 75,
displayName : 'TABLE.COLUMNS.UNIT',
headerCellFilter : 'translate',
cellTemplate : 'modules/stock/inventories/templates/unit.tmpl.html' },
cellTemplate : 'modules/stock/inventories/templates/unit.tmpl.html',
},

{ field : 'status',
{
field : 'status',
displayName : 'STOCK.STATUS.LABEL',
headerCellFilter : 'translate',
enableFiltering : false,
enableSorting : false,
cellTemplate : 'modules/stock/inventories/templates/status.cell.html' },
cellTemplate : 'modules/stock/inventories/templates/status.cell.html',
},

{ field : 'avg_consumption',
{
field : 'avg_consumption',
displayName : 'CMM',
enableFiltering : false,
enableSorting : false,
cellClass : 'text-right',
cellTemplate : '' },
cellTemplate : '',
},

{ field : 'S_MONTH',
{
field : 'S_MONTH',
displayName : 'MS',
enableFiltering : false,
enableSorting : false,
cellClass : 'text-right',
cellTemplate : '' },
cellTemplate : '',
},

{ field : 'S_SEC',
{
field : 'S_SEC',
displayName : 'SS',
enableFiltering : false,
enableSorting : false,
cellClass : 'text-right',
cellTemplate : '' },
cellTemplate : '',
},

{ field : 'S_MIN',
{
field : 'S_MIN',
displayName : 'MIN',
enableFiltering : false,
enableSorting : false,
cellClass : 'text-right',
cellTemplate : '' },
cellTemplate : '',
},

{ field : 'S_MAX',
{
field : 'S_MAX',
displayName : 'MAX',
enableFiltering : false,
enableSorting : false,
cellClass : 'text-right',
cellTemplate : '' },
cellTemplate : '',
},

{ field : 'S_Q',
{
field : 'S_Q',
displayName : 'STOCK.ORDERS',
headerCellFilter : 'translate',
enableFiltering : false,
enableSorting : false,
cellClass : 'text-right',
cellTemplate : 'modules/stock/inventories/templates/appro.cell.html' },
cellTemplate : 'modules/stock/inventories/templates/appro.cell.html',
},
];

vm.enterprise = Session.enterprise;
Expand All @@ -109,7 +138,7 @@ function StockInventoriesController(
enableSorting : true,
fastWatch : true,
flatEntityAccess : true,
onRegisterApi : onRegisterApi,
onRegisterApi,
};

vm.grouping = new Grouping(vm.gridOptions, true, 'depot_text', vm.grouped, true);
Expand Down Expand Up @@ -165,9 +194,9 @@ function StockInventoriesController(
vm.loading = true;

Stock.inventories.read(null, filters)
.then(function (rows) {
.then((rows) => {
// set status flags
rows.forEach(function (item) {
rows.forEach((item) => {
setStatusFlag(item);
});

Expand All @@ -176,7 +205,7 @@ function StockInventoriesController(
vm.grouping.unfoldAllGroups();
})
.catch(Notify.handleError)
.finally(function () {
.finally(() => {
vm.loading = false;
});
}
Expand All @@ -186,7 +215,7 @@ function StockInventoriesController(
var filtersSnapshot = stockInventoryFilters.formatHTTP();

Modal.openSearchInventories(filtersSnapshot)
.then(function (changes) {
.then((changes) => {
stockInventoryFilters.replaceFilters(changes);
Stock.cacheFilters(filterKey);
vm.latestViewFilters = stockInventoryFilters.formatView();
Expand Down
4 changes: 3 additions & 1 deletion server/controllers/stock/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,13 @@ function getInventoryQuantityAndConsumption(params) {
l.entry_date, i.code, i.text, BUID(m.depot_uuid) AS depot_uuid,
i.avg_consumption, i.purchase_interval, i.delay,
iu.text AS unit_type,
ig.name AS group_name,
dm.text AS documentReference
FROM stock_movement m
JOIN lot l ON l.uuid = m.lot_uuid
JOIN inventory i ON i.uuid = l.inventory_uuid
JOIN inventory_unit iu ON iu.id = i.unit_id
JOIN inventory_unit iu ON iu.id = i.unit_id
JOIN inventory_group ig ON ig.uuid = i.group_uuid
JOIN depot d ON d.uuid = m.depot_uuid
LEFT JOIN document_map dm ON dm.uuid = m.document_uuid
`;
Expand Down

0 comments on commit 77034be

Please sign in to comment.