Skip to content

Commit

Permalink
Merge #6830
Browse files Browse the repository at this point in the history
6830: Improvement shipment stock exit r=mbayopanda a=lomamech

- Display shipment register to descending order by reference number
- Automatically import shipment description in stock exit modules
- Fix code for hidden expiry date for asset and other non perimable inventory

- Filter shipment by project
closes #6824

Co-authored-by: lomamech <lomamech@gmail.com>
  • Loading branch information
bors[bot] and lomamech committed Oct 3, 2022
2 parents e7bee1f + 76d959f commit c7014bf
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 5 deletions.
7 changes: 7 additions & 0 deletions client/src/modules/shipment/modals/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
<bh-clear on-clear="$ctrl.clear('destination_depot_uuid')"></bh-clear>
</bh-depot-select>

<bh-project-select
project-id="$ctrl.searchQueries.project_id"
name="project_id"
on-select-callback="$ctrl.onSelectProject(project)">
<bh-clear on-clear="$ctrl.clear('project_id')"></bh-clear>
</bh-project-select>

<!-- status -->
<div class="form-group">
<p class="control-label" style="margin-bottom:5px;">
Expand Down
5 changes: 5 additions & 0 deletions client/src/modules/shipment/modals/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ function SearchShipmentModalController(
}
};

vm.onSelectProject = (project) => {
displayValues.project_id = project.name;
vm.searchQueries.project_id = project.id;
};

// deletes a filter from the custom filter object,
// this key will no longer be written to changes on exit
vm.clear = function clear(key) {
Expand Down
1 change: 1 addition & 0 deletions client/src/modules/shipment/shipment.filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function ShipmentFilterService(Filters, AppCache, $httpParamSerializer, Language
{
key : 'expiration_date_to', label : 'STOCK.EXPIRATION_DATE', comparitor : '<', valueFilter : 'date',
},
{ key : 'project_id', label : 'FORM.LABELS.PROJECT' },
];

class ShipmentFilterer {
Expand Down
5 changes: 3 additions & 2 deletions client/src/modules/shipment/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ angular.module('bhima.controllers')
ShipmentRegistryController.$inject = [
'$state', 'ShipmentService', 'ShipmentFilter', 'ShipmentModalService', 'ModalService',
'uiGridConstants', 'GridStateService', 'GridColumnService',
'NotifyService', 'bhConstants',
'NotifyService', 'bhConstants', 'GridSortingService',
];

function ShipmentRegistryController(
$state, Shipments, ShipmentFilter, ShipmentModal, Modal,
GridConstants, GridState, Columns,
Notify, Constants,
Notify, Constants, Sorting,
) {
const vm = this;
const cacheKey = 'shipment-grid';
Expand Down Expand Up @@ -55,6 +55,7 @@ function ShipmentRegistryController(
headerTooltip : 'SHIPMENT.REFERENCE',
headerCellFilter : 'translate',
headerCellClass : 'wrappingColHeader',
sortingAlgorithm : Sorting.algorithms.sortByReference,
},
{
field : 'stock_reference',
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/stock/entry/modals/lots.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function StockDefineLotsModalController(

// Hide columns in the grid when it doesn't apply to this inventory item.
const isAsset = Data.stockLine.is_asset;
const showShowExpirationDate = !(Data.stockLine.tracking_expiration === false || Data.stockLine.is_asset);
const showShowExpirationDate = !(Data.stockLine.tracking_expiration === 0 || Data.stockLine.is_asset);

Data.stockLine.prev_unit_cost = Data.stockLine.unit_cost; // Save for later checks

Expand Down
5 changes: 5 additions & 0 deletions client/src/modules/stock/exit/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,14 @@ function StockExitController(

//
function onSelectExitType(exitType, entity) {
vm.stockForm.details.description = null;
vm.selectedExitType = exitType;
vm.stockForm.setExitType(exitType.label);

if (entity.shipment) {
vm.stockForm.details.description = entity.shipment.description;
}

switch (exitType.label) {
case 'patient':
vm.stockForm.setPatientDistribution(entity);
Expand Down
2 changes: 2 additions & 0 deletions server/controllers/asset_management/shipment/shipment.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ function getShipmentFilters(parameters) {
filters.equals('label', 'label', 'l');
filters.equals('reference', 'text', 'dm');
filters.equals('is_asset', 'is_asset', 'i');
filters.equals('project_id', 'project_id', 'sh');

// except current
filters.custom(
Expand Down Expand Up @@ -604,6 +605,7 @@ function find(params) {
LEFT JOIN document_map dm2 ON dm2.uuid = sh.document_uuid
`;

filters.setOrder('ORDER BY sh.reference DESC');
const query = filters.applyQuery(sql);
const queryParameters = filters.parameters();
return db.exec(query, queryParameters);
Expand Down
6 changes: 4 additions & 2 deletions test/integration/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ describe('(/groups) Group subscriptions API', () => {
.send(validSubscriptions)
.then((result) => {
helpers.api.errored(result, 400, 'ERROR.INVALID_REQUEST');
});
})
.catch(helpers.handler);
});

it('POST /groups/:key/:id rejects a requst with valid key and no subscriptions', () => {
return agent.post(`/groups/${validKey}/${validEntity}`)
.send({})
.then((result) => {
helpers.api.errored(result, 400, 'ERROR.ERR_MISSING_INFO');
});
})
.catch(helpers.handler);
});

it('POST /groups/:key/:id updates group subscriptions with valid request', () => {
Expand Down

0 comments on commit c7014bf

Please sign in to comment.