Skip to content

Commit

Permalink
Merge pull request #67 from OpenLMIS/OLMIS-7748
Browse files Browse the repository at this point in the history
OLMIS-7748: Fix filtering 'includeInactive' on the Physical Inventory page
  • Loading branch information
mdulko-soldevelo authored Sep 17, 2024
2 parents 0606480 + 1ffecac commit 8953ec8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Improvements:
* [OLMIS-7954](https://openlmis.atlassian.net/browse/OLMIS-7954): Added fixes to improve performance on login page
* [OLMIS-7991](https://openlmis.atlassian.net/browse/OLMIS-7991): Filtered out lots that not expired on Issue screeen

Bug fixes:
* [OLMIS-7748](https://openlmis.atlassian.net/browse/OLMIS-7748): Fix filtering 'includeInactive' on the Physical Inventory page

2.1.5 / 2023-06-26
==================
Bug fixes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@

_.chain(displayLineItemsGroup).flatten()
.each(function(item) {
if (!item.active) {
if (!item.active && item.stockOnHand === 0) {
activeError = 'stockPhysicalInventoryDraft.submitInvalidActive';
} else if (vm.validateQuantity(item) || vm.validateUnaccountedQuantity(item)) {
qtyError = 'stockPhysicalInventoryDraft.submitInvalid';
Expand Down
2 changes: 1 addition & 1 deletion src/stock-physical-inventory/physical-inventory.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@

if (!includeInactive) {
result = _.filter(result, function(item) {
return item.active;
return item.active || item.stockOnHand !== 0;
});
}

Expand Down
29 changes: 21 additions & 8 deletions src/stock-physical-inventory/physical-inventory.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('physicalInventoryService', function() {
var orderable1 = new this.OrderableDataBuilder().withFullProductName('Streptococcus Pneumoniae Vaccine II')
.build(),
orderable2 = new this.OrderableDataBuilder().build(),
orderable3 = new this.OrderableDataBuilder().build(),
lot = new this.LotDataBuilder().build(),
stockAdjustments = [new this.PhysicalInventoryLineItemAdjustmentDataBuilder().build()];

Expand All @@ -48,13 +49,17 @@ describe('physicalInventoryService', function() {
.withStockAdjustments(stockAdjustments)
.buildAsAdded(),
new this.PhysicalInventoryLineItemDataBuilder().withOrderable(orderable2)
.withStockOnHand(null)
.withStockOnHand(0)
.withQuantity(4)
.buildAsAdded(),
new this.PhysicalInventoryLineItemDataBuilder().withOrderable(orderable2)
.withLot(lot)
.withStockOnHand(null)
.withStockOnHand(0)
.withQuantity(null)
.buildAsAdded(),
new this.PhysicalInventoryLineItemDataBuilder().withOrderable(orderable3)
.withStockOnHand(null)
.withQuantity(40)
.buildAsAdded()
];

Expand Down Expand Up @@ -206,7 +211,7 @@ describe('physicalInventoryService', function() {

it('should search by quantity', function() {
expect(this.physicalInventoryService.search('4', this.physicalInventoryLineItems, null))
.toEqual([this.physicalInventoryLineItems[1]]);
.toEqual([this.physicalInventoryLineItems[1], this.physicalInventoryLineItems[3]]);
});

it('should search by lotCode', function() {
Expand All @@ -219,7 +224,8 @@ describe('physicalInventoryService', function() {
this.messageService.get.andReturn('No lot defined');

expect(this.physicalInventoryService.search('No lot defined', this.physicalInventoryLineItems, null))
.toEqual([this.physicalInventoryLineItems[0], this.physicalInventoryLineItems[1]]);
.toEqual([this.physicalInventoryLineItems[0], this.physicalInventoryLineItems[1],
this.physicalInventoryLineItems[3]]);
});

it('should search by expirationDate', function() {
Expand All @@ -230,15 +236,21 @@ describe('physicalInventoryService', function() {
it('should search by only active', function() {
var lineItems = [
{
active: true
active: true,
stockOnHand: 20
},
{
active: false
active: false,
stockOnHand: 0
},
{
active: false,
stockOnHand: null
}
];

expect(this.physicalInventoryService.search('', lineItems, false))
.toEqual([lineItems[0]]);
.toEqual([lineItems[0], lineItems[2]]);
});

it('should find include inactive', function() {
Expand Down Expand Up @@ -272,10 +284,11 @@ describe('physicalInventoryService', function() {
this.$httpBackend.flush();
this.$rootScope.$apply();

expect(result.lineItems.length).toBe(3);
expect(result.lineItems.length).toBe(4);
expect(result.lineItems[0].quantity).toBe(3);
expect(result.lineItems[1].quantity).toBe(4);
expect(result.lineItems[2].quantity).toBe(null);
expect(result.lineItems[3].quantity).toBe(40);
});

//eslint-disable-next-line jasmine/missing-expect
Expand Down

0 comments on commit 8953ec8

Please sign in to comment.