Skip to content

Commit

Permalink
Merge pull request #119 from OpenLMIS-Angola/OAM-187
Browse files Browse the repository at this point in the history
OAM-187: Handle receive for wards
  • Loading branch information
olewandowski1 authored Jun 17, 2024
2 parents 04bb573 + 330886d commit 3af32f7
Show file tree
Hide file tree
Showing 13 changed files with 898 additions and 127 deletions.
303 changes: 197 additions & 106 deletions src/stock-adjustment-creation/adjustment-creation.controller.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('StockAdjustmentCreationController', function() {
LotDataBuilder = $injector.get('LotDataBuilder');
UNPACK_REASONS = $injector.get('UNPACK_REASONS');
LotResource = $injector.get('LotResource');

this.OrderableDataBuilder = $injector.get('OrderableDataBuilder');
this.OrderableChildrenDataBuilder = $injector.get('OrderableChildrenDataBuilder');
this.offlineService = $injector.get('offlineService');
Expand All @@ -73,6 +74,7 @@ describe('StockAdjustmentCreationController', function() {
orderableGroups = [
new OrderableGroupDataBuilder().build()
];

reasons = [new ReasonDataBuilder().build()];

this.kitConstituents = [
Expand Down Expand Up @@ -564,7 +566,8 @@ describe('StockAdjustmentCreationController', function() {
orderableGroups: orderableGroups,
displayItems: [],
hasPermissionToAddNewLot: true,
editLotModalService: this.editLotModalService
editLotModalService: this.editLotModalService,
orderableGroupsByWard: undefined
});
}

Expand Down
40 changes: 23 additions & 17 deletions src/stock-adjustment-creation/adjustment-creation.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,40 @@ <h2>
</form>
<section class="is-primary">
<form class="form-inline" ng-submit="vm.addProduct()" name="productForm">
<div ng-if="vm.displayWardSelect">
<label for="receivingWard">
{{:: 'adjustmentCreation.receivingWardSelect' | message}}
</label>
<select id="receivingWard" class="form-control" ng-model="vm.itemDestination"
ng-change="vm.itemDestinationChanged()"
ng-options="ward as ward.name for ward in vm.homeFacilityWards track by ward.id">
</select>
</div>
<div>
<label for="productSelect">{{vm.key('product') | message}}</label>
<select id="productSelect" ng-model="vm.selectedOrderableGroup"
ng-options="orderableGroup[0].orderable.fullProductName for orderableGroup in vm.orderableGroups"
ng-change="vm.orderableSelectionChanged()"
required>
ng-options="orderableGroup[0].orderable.fullProductName for orderableGroup in vm.orderableGroups"
ng-change="vm.orderableSelectionChanged()" required>
</select>
</div>
<div ng-if="vm.selectedOrderableHasLots">
<label for="lotSelect">{{'stockAddProductsModal.lotCode' | message}}</label>
<!-- OAM-5: Lot code filter UI improvements. -->
<select id="lotSelect" ng-model="vm.selectedLot"
ng-options="lot as (vm.isExpired(lot) ? '[EXP] ' : '')
<select id="lotSelect" ng-model="vm.selectedLot" ng-options="lot as (vm.isExpired(lot) ? '[EXP] ' : '')
+ lot.lotCode
+ ((lot.lotCode !== 'Add lot' && lot.expirationDate != undefined) ? ' | ' + (lot.expirationDate | date:'dd.MM.yyyy') : '')
for lot in vm.lots"
ng-change="vm.lotChanged()"
required>
for lot in vm.lots" ng-change="vm.lotChanged()" required>
</select>
<!-- OAM-5: ends here -->
</div>
<div ng-if="vm.hasPermissionToAddNewLot && vm.canAddNewLot">
<label for="lotCode">{{'stockAddProductsModal.newLotCode' | message}}</label>
<input id="lotCode" type="text" ng-model="vm.newLot.lotCode"
ng-change="vm.newLotCodeChanged()"
openlmis-invalid="{{vm.newLot.lotCodeInvalid | message}}"
required>
<input id="lotCode" type="text" ng-model="vm.newLot.lotCode" ng-change="vm.newLotCodeChanged()"
openlmis-invalid="{{vm.newLot.lotCodeInvalid | message}}" required>
<label for="expirationDate">{{'stockAddProductsModal.newLotExpirationDate' | message}}</label>
<input id="expirationDate" type="date" ng-model="vm.newLot.expirationDate"
ng-change="vm.expirationDateChanged()"
openlmis-invalid="{{vm.newLot.expirationDateInvalid | message}}"/>
ng-change="vm.expirationDateChanged()"
openlmis-invalid="{{vm.newLot.expirationDateInvalid | message}}" />
</div>
<div ng-if="vm.selectedLot && vm.unitsOfOrderable">
<label for="newItemUnit">
Expand All @@ -71,13 +74,14 @@ <h2>
<th ng-show="vm.hasLot">{{vm.key('lotCode') | message}}</th>
<th ng-show="vm.hasLot">{{vm.key('expiryDate') | message}}</th>
<th>{{vm.key('soh') | message}}</th>
<th ng-if="vm.displayWardSelect">{{:: 'adjustmentCreation.itemDestination' | message}}</th>
<th ng-show="vm.srcDstAssignments">{{vm.key('srcDstLabel') | message}}</th>
<th ng-show="vm.srcDstAssignments">{{vm.key('srcDstComments') | message}}</th>
<th ng-if="vm.showReasonDropdown">{{vm.key('reason') | message}}</th>
<th ng-if="vm.showReasonDropdown">{{vm.key('reasonComments') | message}}</th>
<th>{{:: 'adjustmentCreation.unit' | message}}</th>
<th>{{:: 'adjustmentCreation.itemQuantity' | message}}</th>
<th>{{:: 'adjustmentCreation.totalQuantity' | message}}</th>
<th>{{:: 'adjustmentCreation.itemQuantity' | message}}</th>
<th>{{:: 'adjustmentCreation.totalQuantity' | message}}</th>
<!-- AO-804: Display product prices on Stock Issues, Adjustments and Receives Page-->
<th>{{:: 'adjustmentCreation.price' | message}}</th>
<th>{{:: 'adjustmentCreation.totalPrice' | message}}</th>
Expand All @@ -101,6 +105,7 @@ <h2>
</td>
<td ng-show="vm.hasLot">{{lineItem.lot.expirationDate | openlmisDate}}</td>
<td align="right">{{lineItem.$previewSOH}}</td>
<td>{{ lineItem.destination.name }}</td>
<td ng-show="vm.srcDstAssignments"
openlmis-invalid="{{lineItem.$errors.assignmentInvalid ? 'openlmisForm.required' : '' | message}}">
<select ng-model="lineItem.assignment"
Expand Down Expand Up @@ -145,7 +150,8 @@ <h2>
<!-- AO-805: Allow users with proper rights to edit product prices-->
<td openlmis-invalid="{{lineItem.$errors.priceInvalid}}" class="digit-cell"
ng-if="vm.canEditProductPrice(lineItem)">
<input class="form-control" ng-model="lineItem.price" ng-class="{'openlmis-modal': true,
<input class="form-control" ng-model="lineItem.price" ng-class="{
'openlmis-modal': true,
'openlmis-templates': true,
'openlmis-state-tracker': true,
'openlmis-modal-state-error': lineItem.$errors.priceInvalid}"
Expand Down
3 changes: 2 additions & 1 deletion src/stock-adjustment-creation/adjustment-creation.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'stock-unpack-kit',
'stock-reasons-modal',
'stock-edit-lot-modal',
'openlmis-unit-add'
'openlmis-unit-add',
'admin-facility-view'
]);
})();
96 changes: 96 additions & 0 deletions src/stock-adjustment-creation/adjustment-creation.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {
'use strict';

angular
.module('stock-adjustment-creation')
.config(routes);

routes.$inject = ['$stateProvider', 'STOCKMANAGEMENT_RIGHTS', 'SEARCH_OPTIONS', 'ADJUSTMENT_TYPE',
'WARDS_CONSTANTS'];

function routes($stateProvider, STOCKMANAGEMENT_RIGHTS, SEARCH_OPTIONS, ADJUSTMENT_TYPE,
WARDS_CONSTANTS) {
$stateProvider.state('openlmis.stockmanagement.adjustment.creation', {
isOffline: true,
url: '/:programId/create?page&size&keyword',
views: {
'@openlmis': {
controller: 'StockAdjustmentCreationController',
templateUrl: 'stock-adjustment-creation/adjustment-creation.html',
controllerAs: 'vm'
}
},
accessRights: [STOCKMANAGEMENT_RIGHTS.STOCK_ADJUST],
params: {
program: undefined,
facility: undefined,
stockCardSummaries: undefined,
reasons: undefined,
displayItems: undefined,
addedLineItems: undefined,
orderableGroups: undefined
},
resolve: {
program: function($stateParams, programService) {
if (_.isUndefined($stateParams.program)) {
return programService.get($stateParams.programId);
}
return $stateParams.program;
},
facility: function($stateParams, facilityFactory) {
if (_.isUndefined($stateParams.facility)) {
return facilityFactory.getUserHomeFacility();
}
return $stateParams.facility;
},
user: function(authorizationService) {
return authorizationService.getUser();
},
orderableGroups: function($stateParams, program, facility, existingStockOrderableGroupsFactory) {
if (!$stateParams.orderableGroups) {
$stateParams.orderableGroups = existingStockOrderableGroupsFactory
.getGroups($stateParams, program, facility);
}

return $stateParams.orderableGroups;
},
orderableGroupsByWard: function() {
return undefined;
},
displayItems: function($stateParams, registerDisplayItemsService) {
return registerDisplayItemsService($stateParams);
},
reasons: function($stateParams, stockReasonsFactory, facility) {
if (_.isUndefined($stateParams.reasons)) {
return stockReasonsFactory.getAdjustmentReasons($stateParams.programId, facility.type.id);
}
return $stateParams.reasons;
},
adjustmentType: function() {
return ADJUSTMENT_TYPE.ADJUSTMENT;
},
srcDstAssignments: function() {
return undefined;
},
hasPermissionToAddNewLot: function() {
return false;
}
}
});
}
})();
5 changes: 4 additions & 1 deletion src/stock-adjustment-creation/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"adjustmentCreation.addProduct": "Add product",
"adjustmentCreation.unit": "Unit",
"adjustmentCreation.itemQuantity": "Item quantity",
"adjustmentCreation.totalQuantity": "Total quantity"
"adjustmentCreation.totalQuantity": "Total quantity",
"adjustmentCreation.itemDestination": "Item destination",
"adjustmentCreation.receivingWardSelect": "Receiving ward"

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.stock-adjustment-creation {
.is-primary {
@include flex-layout(row, $gap: 0.5rem);
.form-inline{
.form-inline {
flex-wrap: wrap;
}
}
Expand Down
69 changes: 69 additions & 0 deletions src/stock-card-summary/stock-card-summary-repository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* This program is part of the OpenLMIS logistics management information system platform software.
* Copyright © 2017 VillageReach
*
* This program is free software: you can redistribute it and/or modify it under the terms
* of the GNU Affero General Public License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
*  
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
* See the GNU Affero General Public License for more details. You should have received a copy of
* the GNU Affero General Public License along with this program. If not, see
* http://www.gnu.org/licenses.  For additional information contact [email protected]
*/

(function() {

'use strict';

/**
* @ngdoc service
* @name stock-card-summary.StockCardSummaryRepository
*
* @description
* Repository of Stock Card Summaries. It's an abstraction layer over internals communicating with the OpenLMIS
* server.
*/
angular
.module('stock-card-summary')
.factory('StockCardSummaryRepository', StockCardSummaryRepository);

StockCardSummaryRepository.$inject = ['StockCardSummary'];

function StockCardSummaryRepository(StockCardSummary) {

StockCardSummaryRepository.prototype.query = query;

return StockCardSummaryRepository;

function StockCardSummaryRepository(impl) {
this.impl = impl;
}

/**
* @ngdoc method
* @methodOf stock-card-summary.StockCardSummaryRepository
* @name query
*
* @description
* Searches for Stock Card Summaries.
*
* @param {Object} params search and pagination parameters
* @return {Promise} the promise resolving to instance of the StockCardSummary class
*/
function query(params) {
return this.impl.query(params)
.then(function(page) {
if (!page.content) {
return page;
}

page.content = page.content.map(function(stockCardSummaryJson) {
return new StockCardSummary(stockCardSummaryJson);
});
return page;
});
}
}
})();
4 changes: 4 additions & 0 deletions src/stock-orderable-group/orderable-group.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@
programId: programId,
facilityId: facilityId
}).then(function(summaries) {
if (!summaries.content) {
return [];
}

return groupByOrderableId(summaries.content.reduce(function(items, summary) {
summary.canFulfillForMe.forEach(function(fulfill) {
items.push(fulfill);
Expand Down
Loading

0 comments on commit 3af32f7

Please sign in to comment.