Exemplo n.º 1
0
  private void fillPreviousNCsInLineItems(
      Rnr requisition, Integer numberOfMonths, Date trackingDate) {
    if (numberOfMonths >= 3 && !(requisition.isEmergency() || requisition.isForVirtualFacility())) {
      return;
    }

    for (RnrLineItem lineItem : requisition.getFullSupplyLineItems()) {
      List<RnrLineItem> previousLineItems =
          requisitionRepository.getAuthorizedRegularUnSkippedLineItems(
              lineItem.getProductCode(),
              requisition,
              getNumberOfPreviousNCToTrack(numberOfMonths),
              trackingDate);
      List<Integer> nNormalizedConsumptions =
          (List<Integer>)
              collect(
                  previousLineItems,
                  new Transformer() {
                    @Override
                    public Object transform(Object o) {
                      return ((RnrLineItem) o).getNormalizedConsumption();
                    }
                  });
      lineItem.setPreviousNormalizedConsumptions(nNormalizedConsumptions);
    }
  }
Exemplo n.º 2
0
  private void calculateForNonFullSupply(Rnr requisition) {
    for (RnrLineItem lineItem : requisition.getNonFullSupplyLineItems()) {
      lineItem.validateNonFullSupply();

      lineItem.calculatePacksToShip();

      requisition.addToNonFullSupplyCost(lineItem.calculateCost());
    }
  }
Exemplo n.º 3
0
  private void calculateForFullSupply(Rnr requisition, ProgramRnrTemplate template) {
    List<LossesAndAdjustmentsType> lossesAndAdjustmentsTypes =
        requisitionRepository.getLossesAndAdjustmentsTypes();

    for (RnrLineItem lineItem : requisition.getNonSkippedLineItems()) {

      lineItem.validateMandatoryFields(template);
      lineItem.calculateForFullSupply(template, requisition.getStatus(), lossesAndAdjustmentsTypes);
      lineItem.validateCalculatedFields(template);

      requisition.addToFullSupplyCost(lineItem.calculateCost());
    }
  }
Exemplo n.º 4
0
  public void fillReportingDays(Rnr requisition) {
    Date startDate = requisition.getPeriod().getStartDate();
    Integer numberOfMonths = requisition.getPeriod().getNumberOfMonths();

    List<ProcessingPeriod> twoPreviousPeriods =
        processingScheduleService.getNPreviousPeriodsInDescOrder(requisition.getPeriod(), 2);

    if (twoPreviousPeriods.size() != 0) {
      numberOfMonths = twoPreviousPeriods.get(0).getNumberOfMonths();
      startDate =
          (numberOfMonths < 3 && twoPreviousPeriods.size() != 1)
              ? twoPreviousPeriods.get(1).getStartDate()
              : twoPreviousPeriods.get(0).getStartDate();
    }

    for (RnrLineItem lineItem : requisition.getNonSkippedLineItems()) {
      Integer reportingDays =
          getReportingDaysBasedOnRequisition(
              requisition, lineItem.getProductCode(), startDate, numberOfMonths);
      lineItem.setReportingDays(reportingDays);
    }
  }