diff --git a/src/main/java/org/openlmis/requisition/web/BaseRequisitionController.java b/src/main/java/org/openlmis/requisition/web/BaseRequisitionController.java index 93fdb95e6..a551ae33a 100644 --- a/src/main/java/org/openlmis/requisition/web/BaseRequisitionController.java +++ b/src/main/java/org/openlmis/requisition/web/BaseRequisitionController.java @@ -321,6 +321,11 @@ ETagResource doUpdate(Requisition requisitionToUpdate, Requisiti Map approvedProducts = findApprovedProducts( requisitionToUpdate::getAllApprovedProductIdentities, profiler); + if (Boolean.FALSE.equals(requisitionToUpdate.getEmergency())) { + requisition.setProcessingPeriodId(requisitionToUpdate.getProcessingPeriodId()); + requisition.setFacilityId(requisitionToUpdate.getFacilityId()); + } + UpdateParams params = new UpdateParams(requisitionToUpdate, requisition, orderables, facility, program, null, approvedProducts); @@ -703,7 +708,8 @@ class UpdateParams { void updateAndSave(Profiler profiler) { profiler.start("UPDATE"); toUpdate.updateFrom(requisition, orderables, approvedProducts, - datePhysicalStockCountCompletedEnabledPredicate.exec(program), null, null); + datePhysicalStockCountCompletedEnabledPredicate.exec(program), + requisitionService, periodService); profiler.start("SAVE"); toUpdate = requisitionRepository.save(toUpdate); diff --git a/src/test/java/org/openlmis/requisition/web/RequisitionControllerTest.java b/src/test/java/org/openlmis/requisition/web/RequisitionControllerTest.java index 841f2d5b1..b3358cb2e 100644 --- a/src/test/java/org/openlmis/requisition/web/RequisitionControllerTest.java +++ b/src/test/java/org/openlmis/requisition/web/RequisitionControllerTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.isNotNull; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyBoolean; @@ -605,7 +606,7 @@ public void shouldUpdateRequisition() { assertEquals(template, initiatedRequsition.getTemplate()); verify(initiatedRequsition).updateFrom( - any(Requisition.class), anyMap(), anyMap(), eq(true), isNull(), isNull()); + any(Requisition.class), anyMap(), anyMap(), eq(true), isNotNull(), isNotNull()); verify(requisitionRepository).save(initiatedRequsition); verify(requisitionVersionValidator).validateEtagVersionIfPresent( any(HttpServletRequest.class), eq(initiatedRequsition)); @@ -651,7 +652,7 @@ public void shouldUpdateStockBasedRequisition() { assertEquals(template, initiatedRequsition.getTemplate()); verify(initiatedRequsition).updateFrom( - any(Requisition.class), anyMap(), anyMap(), eq(true), isNull(), isNull()); + any(Requisition.class), anyMap(), anyMap(), eq(true), isNotNull(), isNotNull()); verify(requisitionRepository).save(initiatedRequsition); verify(requisitionVersionValidator).validateEtagVersionIfPresent( any(HttpServletRequest.class), eq(initiatedRequsition));