@Test public void shouldSkipPeriodValidationForVirtualFacility() throws Exception { Facility facility = new Facility(); facility.setVirtualFacility(true); restRequisitionCalculator.validatePeriod(facility, new Program()); }
public void validatePeriod(Facility reportingFacility, Program reportingProgram) { if (!reportingFacility.getVirtualFacility()) { RequisitionSearchCriteria searchCriteria = new RequisitionSearchCriteria(); searchCriteria.setProgramId(reportingProgram.getId()); searchCriteria.setFacilityId(reportingFacility.getId()); if (requisitionService.getCurrentPeriod(searchCriteria) != null && !requisitionService.getCurrentPeriod(searchCriteria).getId().equals (requisitionService.getPeriodForInitiating(reportingFacility, reportingProgram).getId())) { throw new DataException("error.rnr.previous.not.filled"); } } }
RestRequisitionCalculator { public void validatePeriod(Facility reportingFacility, Program reportingProgram) { if (!reportingFacility.getVirtualFacility()) { RequisitionSearchCriteria searchCriteria = new RequisitionSearchCriteria(); searchCriteria.setProgramId(reportingProgram.getId()); searchCriteria.setFacilityId(reportingFacility.getId()); if (requisitionService.getCurrentPeriod(searchCriteria) != null && !requisitionService.getCurrentPeriod(searchCriteria).getId().equals (requisitionService.getPeriodForInitiating(reportingFacility, reportingProgram).getId())) { throw new DataException("error.rnr.previous.not.filled"); } } } }
RestRequisitionCalculator { public void validatePeriod(Facility reportingFacility, Program reportingProgram) { if (!reportingFacility.getVirtualFacility()) { RequisitionSearchCriteria searchCriteria = new RequisitionSearchCriteria(); searchCriteria.setProgramId(reportingProgram.getId()); searchCriteria.setFacilityId(reportingFacility.getId()); if (requisitionService.getCurrentPeriod(searchCriteria) != null && !requisitionService.getCurrentPeriod(searchCriteria).getId().equals (requisitionService.getPeriodForInitiating(reportingFacility, reportingProgram).getId())) { throw new DataException("error.rnr.previous.not.filled"); } } }  }
RestRequisitionCalculator { public void validatePeriod(Facility reportingFacility, Program reportingProgram) { if (!reportingFacility.getVirtualFacility()) { RequisitionSearchCriteria searchCriteria = new RequisitionSearchCriteria(); searchCriteria.setProgramId(reportingProgram.getId()); searchCriteria.setFacilityId(reportingFacility.getId()); if (requisitionService.getCurrentPeriod(searchCriteria) != null && !requisitionService.getCurrentPeriod(searchCriteria).getId().equals (requisitionService.getPeriodForInitiating(reportingFacility, reportingProgram).getId())) { throw new DataException("error.rnr.previous.not.filled"); } } }  void validatePeriod(Facility reportingFacility, Program reportingProgram); void validateCustomPeriod(Facility reportingFacility, Program reportingProgram, ProcessingPeriod period, Long userId); void validateProducts(List<RnrLineItem> products, Rnr savedRequisition); Rnr setDefaultValues(Rnr requisition); }
RestRequisitionCalculator { public void validatePeriod(Facility reportingFacility, Program reportingProgram) { if (!reportingFacility.getVirtualFacility()) { RequisitionSearchCriteria searchCriteria = new RequisitionSearchCriteria(); searchCriteria.setProgramId(reportingProgram.getId()); searchCriteria.setFacilityId(reportingFacility.getId()); if (requisitionService.getCurrentPeriod(searchCriteria) != null && !requisitionService.getCurrentPeriod(searchCriteria).getId().equals (requisitionService.getPeriodForInitiating(reportingFacility, reportingProgram).getId())) { throw new DataException("error.rnr.previous.not.filled"); } } }  void validatePeriod(Facility reportingFacility, Program reportingProgram); void validateCustomPeriod(Facility reportingFacility, Program reportingProgram, ProcessingPeriod period, Long userId); void validateProducts(List<RnrLineItem> products, Rnr savedRequisition); Rnr setDefaultValues(Rnr requisition);  }