Skip to content

Commit

Permalink
Added filters and action item for required inventory scans registry
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcameron committed Apr 4, 2022
1 parent 23b6214 commit 6a3b908
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 58 deletions.
3 changes: 3 additions & 0 deletions client/src/i18n/en/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"NOT_ASSIGNED" : "Not assigned",
"NO_ASSIGNMENT_HISTORY" : "No assignment history",
"REQUIRED_INVENTORY_SCAN" : "Required Inventory Scan",
"REQUIRED_INVENTORY_SCAN_CREATED" : "Required inventory scan successfully created",
"REQUIRED_INVENTORY_SCAN_DETAILS" : "Required Inventory Scan Details",
"REQUIRED_INVENTORY_SCAN_EDITED" : "Required inventory scan successfully edited",
"SCANNED_BY" : "Scanned by",
Expand All @@ -29,6 +30,8 @@
"SHOW_NOT_ASSIGNED" : "Unassigned assets",
"SHOW_ONLY" : "Show only",
"SHOW_ONLY_ASSIGNED" : "Assigned assets",
"SHOW_SCANNED_ASSETS" : "Show Scanned Assets",
"SHOW_UNSCANNED_ASSETS" : "Show Unscanned Assets",
"SUCCESSFULLY_EDITED":"Asset successfully updated",
"TITLE" : "Assets",
"VIEW_IN_INVENTORY" : "View Asset in Inventory",
Expand Down
3 changes: 3 additions & 0 deletions client/src/i18n/fr/asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"NOT_ASSIGNED" : "Aucune assignation",
"NO_ASSIGNMENT_HISTORY" : "Aucun historique des assignations",
"REQUIRED_INVENTORY_SCAN" : "Scan d'inventaire obligatoire",
"REQUIRED_INVENTORY_SCAN_CREATED" : "Scan d'inventaire obligatoire créé avec succès",
"REQUIRED_INVENTORY_SCAN_DETAILS" : "Détails de scan d'inventaire obligatoire",
"REQUIRED_INVENTORY_SCAN_EDITED" : "Scan d'inventaire obligatoire édité avec succès",
"SCANNED_BY" : "Scanné par",
Expand All @@ -29,6 +30,8 @@
"SHOW_NOT_ASSIGNED" : "Actifs non assigné",
"SHOW_ONLY" : "Montrer uniquement",
"SHOW_ONLY_ASSIGNED" : "Actifs assigné",
"SHOW_SCANNED_ASSETS" : "Montrer les actifs scannés",
"SHOW_UNSCANNED_ASSETS" : "Montrer les actifs non scannés",
"SUCCESSFULLY_EDITED":"L'actif a été modifié",
"TITLE" : "Actifs",
"VIEW_IN_INVENTORY" : "Visualiser l'actif dans l'inventaire",
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/services/PeriodService.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function PeriodService(Moment) {
},

// components will make an exception for all time - no period has to be selected
// on the server this simple removes the WHERE condition
// on the server this simply removes the WHERE condition
allTime : {
key : 'allTime',
translateKey : 'PERIODS.ALL_TIME',
Expand Down
20 changes: 12 additions & 8 deletions client/src/modules/asset_scans/asset-scans-registry.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,27 @@ function AssetsScansRegistryService(Session, Filters, AppCache, bhConstants, Per
headerCellClass : 'wrappingColHeader',
visible : false,
}, {
field : 'updated_at',
field : 'created_at',
type : 'date',
displayName : 'ASSET.SCAN_DATE',
headerTooltip : 'ASSET.SCAN_DATE',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
cellFilter : 'date',
}, {
field : 'updated_at',
type : 'date',
displayName : 'FORM.LABELS.UPDATED',
headerTooltip : 'FORM.LABELS.UPDATED',
headerCellFilter : 'translate',
cellFilter : 'date',
visible : false,
}, {
field : 'assigned_to_name',
displayName : 'ENTITY.ASSIGNED_TO',
headerTooltip : 'ENTITY.ASSIGNED_TO',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
}, {
field : 'created_at',
type : 'date',
displayName : 'FORM.LABELS.SERVER_DATE',
headerCellFilter : 'translate',
cellTemplate : 'modules/journal/templates/created_at.cell.html',
visible : false,
}, {
field : 'action',
displayName : '',
Expand Down Expand Up @@ -162,6 +164,8 @@ function AssetsScansRegistryService(Session, Filters, AppCache, bhConstants, Per

if (!periodDefined) {
scansFilters.assignFilters(Periods.defaultFilters());
// Force the default period to be this year
scansFilters.assignFilter('period', 'year', 'PERIODS.THIS_YEAR');
}
}

Expand Down
3 changes: 1 addition & 2 deletions client/src/modules/asset_scans/modals/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ angular.module('bhima.controllers')

// dependencies injections
AssetScansSearchModalController.$inject = [
'data', 'util', 'Store', '$uibModalInstance', 'StockService',
'SearchModalUtilService', 'PeriodService',
'data', 'util', 'Store', '$uibModalInstance', 'StockService', 'SearchModalUtilService', 'PeriodService',
];

function AssetScansSearchModalController(data, util, Store, Instance, Stock, SearchModal, Periods) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ function RequiredInventoryScanEditModalController(Data, ReqInvScansService,
function submit(form) {
if (form.$invalid) { return 0; }

// ???
// // Set up is_asset (based on html radio element values)
// if (vm.model.is_asset) {
// vm.model.is_asset = vm.model.is_asset === 1;
// }

if (vm.model.uuid) {
return ReqInvScansService.update(Data.uuid, vm.model)
.then(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,27 @@
<bh-clear on-clear="$ctrl.clear('depot_uuid')"></bh-clear>
</bh-depot-select>

<div class="form-group">
<label class="control-label" translate>FORM.LABELS.REFERENCE_NUMBER_OPTIONAL</label>
<bh-clear on-clear="$ctrl.clear('reference_number')"></bh-clear>
<input ng-model="$ctrl.searchQueries.reference_number"
class="form-control"
type="text"
name="reference_number">
</div>

</div>
</uib-tab>

<uib-tab index="1" heading="{{ 'FORM.LABELS.DEFAULTS' | translate }}" data-default-filter-tab>
<div class="tab-body">

<!-- end date selection -->
<bh-period-select
default-period="{{$ctrl.filters.period}}"
on-select-callback="$ctrl.onSelectEndPeriod(period)">
</bh-period-select>

<div class="form-group" ng-class="{ 'has-error' : ModalForm.limit.$invalid }">
<label class="control-label" translate>FORM.LABELS.LIMIT</label>
<input
Expand Down
22 changes: 18 additions & 4 deletions client/src/modules/required_inventory_scans/modals/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ angular.module('bhima.controllers')
// dependencies injections
RequiredInventoryScansSearchModalController.$inject = [
'data', 'util', 'Store', '$uibModalInstance', 'StockService',
'SearchModalUtilService',
'SearchModalUtilService', 'PeriodService',
];

function RequiredInventoryScansSearchModalController(data, util, Store, Instance, Stock, SearchModal) {
function RequiredInventoryScansSearchModalController(
data, util, Store, Instance, Stock,
SearchModal, Periods) {

const vm = this;
const changes = new Store({ identifier : 'key' });

Expand All @@ -16,7 +19,7 @@ function RequiredInventoryScansSearchModalController(data, util, Store, Instance
vm.defaultQueries = {};

const searchQueryOptions = [
'depot_uuid',
'depot_uuid', 'reference_number',
];

// displayValues will be an id:displayValue pair
Expand All @@ -32,6 +35,18 @@ function RequiredInventoryScansSearchModalController(data, util, Store, Instance
displayValues.depot_uuid = depot.text;
};

// custom filter reference_number
vm.onChangeReferenceNumber = function onChangeReferenceNumber(refNum) {
vm.searchQueries.reference_number = refNum;
};

vm.onSelectEndPeriod = function onSelectEndPeriod(period) {
const periodFilters = Periods.processFilterChanges(period);
periodFilters.forEach((filterChange) => {
changes.post(filterChange);
});
};

// default filter limit - directly write to changes list
vm.onSelectLimit = function onSelectLimit(value) {
// input is type value, this will only be defined for a valid number
Expand All @@ -57,7 +72,6 @@ function RequiredInventoryScansSearchModalController(data, util, Store, Instance
vm.cancel = () => Instance.dismiss();

vm.submit = () => {

const loggedChanges = SearchModal.getChanges(vm.searchQueries, changes, displayValues, lastDisplayValues);

return Instance.close(loggedChanges);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ angular.module('bhima.controllers')
.controller('RequiredInventoryScansRegistryController', RequiredInventoryScansRegistryController);

RequiredInventoryScansRegistryController.$inject = [
'StockService', 'RequiredInventoryScansService',
'RequiredInventoryScansRegistryService',
'StockModalService', 'DepotService', 'BarcodeService',
'RequiredInventoryScansService', 'RequiredInventoryScansRegistryService',
'StockModalService', 'DepotService',
'GridStateService', 'GridColumnService', 'GridGroupingService',
'NotifyService', '$state',
];
Expand All @@ -14,9 +13,8 @@ RequiredInventoryScansRegistryController.$inject = [
* This module is a registry page for assets
*/
function RequiredInventoryScansRegistryController(
Stock, RequiredInventoryScans,
ReqInvScansRegistryService,
StockModal, Depots, Barcode,
RequiredInventoryScans, ReqInvScansRegistryService,
StockModal, Depots,
GridState, Columns, Grouping,
Notify, $state,
) {
Expand Down Expand Up @@ -73,6 +71,8 @@ function RequiredInventoryScansRegistryController(
vm.latestViewFilters = vm.filters.formatView();
}

// { key : 'period', value : 'allTime', displayValue : 'PERIODS.ALL_TIME', cacheable: false },

// load the assets scans into the grid
function load(filters) {
if (vm.defaultDepot) {
Expand Down Expand Up @@ -174,6 +174,37 @@ function RequiredInventoryScansRegistryController(
});
};

/**
* Go to the Assets Registry and show a
* @param {object} scan - required inventory scan object
*/
vm.showScannedAssets = function showScannedAssets(scan) {
const filters = [{
key : 'period',
value : 'custom',
cacheable : false,
}, {
key : 'custom_period_start',
value : scan.start_date,
cacheable : false,
}, {
key : 'custom_period_end',
value : scan.end_date,
cacheable : false,
}];

if (scan.depot_uuid) {
filters.push({
key : 'depot_uuid',
value : scan.depot_uuid,
displayValue : scan.depot_name,
cacheable : false,
});
}

$state.go('stockAssetsScans', { filters });
};

// This function opens a modal through column service to let the user toggle
// the visibility of the lots registry's columns.
vm.openColumnConfigModal = function openColumnConfigModal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ angular.module('bhima.services')
.service('RequiredInventoryScansRegistryService', RequiredInventoryScansRegistryService);

RequiredInventoryScansRegistryService.$inject = [
'SessionService', 'FilterService', 'appcache', 'bhConstants',
'FilterService', 'PeriodService', 'appcache', 'bhConstants', 'util',
];

/**
* This service encapsulates some common methods of assets scans registry
*/
function RequiredInventoryScansRegistryService(Session, Filters, AppCache, bhConstants) {
function RequiredInventoryScansRegistryService(Filters, Periods, AppCache, bhConstants, util) {
const service = this;

/**
Expand Down Expand Up @@ -68,8 +68,8 @@ function RequiredInventoryScansRegistryService(Session, Filters, AppCache, bhCon
visible : false,
}, {
field : 'updated_at',
displayName : 'ASSET.SCAN_DATE',
headerTooltip : 'ASSET.SCAN_DATE',
displayName : 'FORM.LABELS.UPDATED',
headerTooltip : 'FORM.LABELS.UPDATED',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
cellFilter : 'date',
Expand All @@ -95,6 +95,7 @@ function RequiredInventoryScansRegistryService(Session, Filters, AppCache, bhCon
scansFilters.registerCustomFilters([
{ key : 'uuid', label : 'FORM.LABELS.REFERENCE' },
{ key : 'depot_uuid', label : 'STOCK.DEPOT' },
{ key : 'reference_number', label : 'FORM.LABELS.REFERENCE_NUMBER' },
]);

if (filterCache.filters) {
Expand All @@ -112,6 +113,16 @@ function RequiredInventoryScansRegistryService(Session, Filters, AppCache, bhCon
if (assignedKeys.indexOf('limit') === -1) {
scansFilters.assignFilter('limit', 100);
}

// assign default period filter (for the end date of the inventory scan)
const periodKeys = ['period', 'custom_period_start', 'custom_period_end'];
const periodDefined = util.arrayIncludes(assignedKeys, periodKeys);

if (!periodDefined) {
scansFilters.assignFilters(Periods.defaultFilters());
// Force the default period to be this year
scansFilters.assignFilter('period', 'year', 'PERIODS.THIS_YEAR');
}
}

// Remove a filter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
</li>

<li role="separator" class="divider"></li>
<li >
<a data-method="show-unscanned-assets" ng-click="grid.appScope.showScannedAssets(row.entity)" href>
<i class="fa fa-list-alt"></i> <span translate>ASSET.SHOW_SCANNED_ASSETS</span>
</a>
</li>


<!-- links for various reports here -->

Expand Down
16 changes: 8 additions & 8 deletions server/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const period = require('../controllers/finance/period');
const lots = require('../controllers/stock/lots');

// assets
const assets = require('../controllers/stock/asset');
const assetScans = require('../controllers/stock/asset_scan');
const reqInvScans = require('../controllers/stock/required_inventory_scans');

// todo: the indicator folder must not be inside the finance folder
Expand Down Expand Up @@ -803,13 +803,13 @@ exports.configure = function configure(app) {
app.get('/stock/status', stock.listStatus);

// API for asset scan related queries
app.get('/asset/conditions', assets.conditions);
app.get('/asset/scans', assets.getAssetScans);
app.get('/asset/scan/:uuid', assets.getAssetScan);
app.get('/asset/scans/reports/', assets.report);
app.post('/asset/scan', assets.createAssetScan);
app.put('/asset/scan/:uuid', assets.updateAssetScan);
app.delete('/asset/scan/:uuid/delete', assets.deleteAssetScan);
app.get('/asset/conditions', assetScans.conditions);
app.get('/asset/scans', assetScans.getAssetScans);
app.get('/asset/scan/:uuid', assetScans.getAssetScan);
app.get('/asset/scans/reports/', assetScans.report);
app.post('/asset/scan', assetScans.createAssetScan);
app.put('/asset/scan/:uuid', assetScans.updateAssetScan);
app.delete('/asset/scan/:uuid/delete', assetScans.deleteAssetScan);

// API for required asset inventory scans
app.get('/inventory/required/scans', reqInvScans.getRequiredInventoryScans);
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/inventory/inventory/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ async function getItemsMetadata(params) {
filters.equals('note');
filters.equals('importance');
filters.equals('is_asset');
filters.equals('reference_number');
filters.fullText('reference_number');
filters.equals('manufacturer_brand');
filters.equals('manufacturer_model');
filters.custom('tags', 't.uuid IN (?)', [params.tags]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ function getAssetScanFilters(parameters) {
filters.equals('inventory_uuid', 'inventory_uuid', 'l');
filters.equals('scanned_by');
filters.equals('condition_id', 'id', 'ac');
filters.dateFrom('start_date', 'updated_at');
filters.dateTo('end_date', 'updated_at');
filters.period('period', 'updated_at');
filters.dateFrom('custom_period_start', 'updated_at');
filters.dateTo('custom_period_end', 'updated_at');
filters.period('period', 'created_at');
filters.dateFrom('custom_period_start', 'created_at');
filters.dateTo('custom_period_end', 'created_at');

return filters;
}
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/stock/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function getLotFilters(parameters) {
filters.equals('text', 'text', 'i');
filters.equals('label', 'label', 'l');
filters.equals('is_asset', 'is_asset', 'i');
filters.equals('reference_number', 'reference_number', 'l');
filters.fullText('reference_number', 'reference_number', 'l');
filters.equals('period_id', 'period_id', 'm');
filters.equals('is_exit', 'is_exit', 'm');
filters.equals('flux_id', 'flux_id', 'm', true);
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/stock/lots.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function getDupes(req, res, next) {
filters.equals('inventory_uuid');
filters.equals('entry_date');
filters.equals('expiration_date');
filters.equals('reference_number');
filters.fullText('reference_number');
filters.equals('serial_number');

const query = filters.applyQuery(detailsQuery);
Expand Down

0 comments on commit 6a3b908

Please sign in to comment.