diff --git a/client/src/i18n/en/form.json b/client/src/i18n/en/form.json index 3662896ff5..cd6ed0904c 100644 --- a/client/src/i18n/en/form.json +++ b/client/src/i18n/en/form.json @@ -664,6 +664,7 @@ "RECORDS": "Records (Rows)", "REFERENCE_GROUP": "Reference Group", "REFERENCE_PATIENT": "Patient Reference", + "REFERENCE_VOUCHER" : "Voucher Reference", "REFERENCE": "Reference", "REFERENCES": "References", "REGISTER_EMPLOYEE_PATIENT": "Save as an employee", diff --git a/client/src/i18n/fr/form.json b/client/src/i18n/fr/form.json index 96e9b965c4..dfa7a46f0d 100644 --- a/client/src/i18n/fr/form.json +++ b/client/src/i18n/fr/form.json @@ -665,6 +665,7 @@ "RECORDS": "Enregistrements (Lignes)", "REFERENCE_GROUP": "Groupe de référence", "REFERENCE_PATIENT": "Référence Patient", + "REFERENCE_VOUCHER": "Référence Bordereau", "REFERENCE": "Référence", "REFERENCES": "Références", "REGISTER_EMPLOYEE_PATIENT": "Enregistrer comme un employé", diff --git a/client/src/modules/stock/StockFilterer.service.js b/client/src/modules/stock/StockFilterer.service.js index f06d26b1ac..feeae706ba 100644 --- a/client/src/modules/stock/StockFilterer.service.js +++ b/client/src/modules/stock/StockFilterer.service.js @@ -32,6 +32,7 @@ function StockFiltererService(Filters, AppCache, $httpParamSerializer, Languages { key : 'is_expired', label : 'STOCK.EXPIRED' }, { key : 'is_expiry_risk', label : 'STOCK.STATUS.IS_IN_RISK_OF_EXPIRATION' }, { key : 'tag_uuid', label : 'TAG.LABEL' }, + { key : 'voucherReference', label : 'FORM.LABELS.REFERENCE_VOUCHER' }, { key : 'tags', label : 'TAG.LABEL' }, { key : 'show_only_risky', label : 'LOTS.SHOW_ONLY_RISKY_LOTS' }, { key : 'stock_requisition_uuid', label : 'FORM.LABELS.REQUISITION_REFERENCE' }, diff --git a/client/src/modules/stock/movements/modals/search.modal.html b/client/src/modules/stock/movements/modals/search.modal.html index b9fe40f851..26a99c39d7 100644 --- a/client/src/modules/stock/movements/modals/search.modal.html +++ b/client/src/modules/stock/movements/modals/search.modal.html @@ -33,17 +33,21 @@ - -
+
- + +
+
+
+
-
+ +
+ + + +
diff --git a/client/src/modules/stock/movements/modals/search.modal.js b/client/src/modules/stock/movements/modals/search.modal.js index 04679546b9..b8a38b931d 100644 --- a/client/src/modules/stock/movements/modals/search.modal.js +++ b/client/src/modules/stock/movements/modals/search.modal.js @@ -4,10 +4,10 @@ angular.module('bhima.controllers') SearchMovementsModalController.$inject = [ 'data', '$uibModalInstance', 'PeriodService', 'Store', 'util', 'StockService', - 'SearchModalUtilService', + 'SearchModalUtilService', 'SessionService', ]; -function SearchMovementsModalController(data, Instance, Periods, Store, util, Stock, SearchModal) { +function SearchMovementsModalController(data, Instance, Periods, Store, util, Stock, SearchModal, Session) { const vm = this; const displayValues = {}; const changes = new Store({ identifier : 'key' }); @@ -15,9 +15,11 @@ function SearchMovementsModalController(data, Instance, Periods, Store, util, St const searchQueryOptions = [ 'is_exit', 'depot_uuid', 'inventory_uuid', 'label', 'flux_id', 'dateFrom', 'dateTo', 'user_id', 'patientReference', 'service_uuid', 'invoice_uuid', - 'stock_requisition_uuid', + 'stock_requisition_uuid', 'voucherReference', ]; + vm.hasAutoStockAccounting = Session.stock_settings.enable_auto_stock_accounting; + vm.filters = data; vm.searchQueries = {}; vm.defaultQueries = {}; diff --git a/server/controllers/stock/core.js b/server/controllers/stock/core.js index 3e37b34764..fe0ba406d6 100644 --- a/server/controllers/stock/core.js +++ b/server/controllers/stock/core.js @@ -111,6 +111,13 @@ function getLotFilters(parameters) { filters.equals('tag_uuid', 'tags', 't'); filters.equals('stock_requisition_uuid', 'stock_requisition_uuid', 'm'); + // filter on the underlying voucher t + filters.custom('voucherReference', + `document_uuid = ( + SELECT DISTINCT vi.document_uuid FROM voucher_item AS vi + WHERE vi.voucher_uuid = (SELECT uuid FROM document_map WHERE document_map.text = ?) + )`); + // depot permission check filters.custom( 'check_user_id',