private void processInventory() {
    LocalDate crc = SystemDao.getCrc();
    if (isStockedOut) {
      Demand d = getDemand(SystemDao.getCrc());
      if (crc.getDayOfWeek() == DateTimeConstants.SUNDAY) {
        d = getDemand(SystemDao.getReviewCycleStartDate());
      }
      int targetInv = (int) d.getRcAvgDemand() - inventory;

      setInventory(targetInv > 0 ? targetInv : (int) d.getRcAvgDemand());
      isStockedOut = false;
    }

    if (crc.getDayOfWeek() == DateTimeConstants.SUNDAY) {
      rcBopInv = inventory;
    }
    // daily inventory updates
    updateEpEopInv();
    epEopInv = inventory;
    rcInvOut += epInvOut;
    rcInvIn += epInvIn;
    ProductInventory p = getInventory(SystemDao.getReviewCycleStartDate());
    double beginOfPeriodEpAvgInv = 0;
    if (p != null) {
      beginOfPeriodEpAvgInv = p.getEpAvgInv();
    }
    double weight_5 = SystemDao.getWeight_5();
    epAvgInv =
        weight_5 * ((epEopInv >= 0) ? epEopInv : 0) + (((1 - weight_5) * beginOfPeriodEpAvgInv));
    epAvgInv = Math.max(0, epAvgInv);
  }
  private String inventoryToString() {
    StringBuffer epAvgInvBf = new StringBuffer();
    epAvgInvBf.append("epAvgInv|");

    StringBuffer epEopInvBf = new StringBuffer();
    epEopInvBf.append("epEopInv|");

    StringBuffer epInvOutBf = new StringBuffer();
    epInvOutBf.append("epInvOut|");

    StringBuffer epInvInBf = new StringBuffer();
    epInvInBf.append("epInvIn|");

    StringBuffer rcBopInvBf = new StringBuffer();
    rcBopInvBf.append("rcBopInv|");

    StringBuffer rcInvInBf = new StringBuffer();
    rcInvInBf.append("rcInvIn|");

    StringBuffer rcInvOutBf = new StringBuffer();
    rcInvOutBf.append("rcInvOut|");

    StringBuffer actualInvBf = new StringBuffer();
    actualInvBf.append("actualInv|");

    Iterator<Years> yrItr = inventoryMap.keySet().iterator();
    Map<LocalDate, ProductInventory> currInvMap;
    LocalDate currDate;
    Years currYr;
    ProductInventory currInv;
    // Populate Sale buffers
    while (yrItr.hasNext()) {
      currYr = yrItr.next();
      currInvMap = inventoryMap.get(currYr);
      Iterator<LocalDate> itr = currInvMap.keySet().iterator();
      while (itr.hasNext()) {
        currDate = itr.next();
        currInv = currInvMap.get(currDate);
        // epAvgInv
        epAvgInvBf.append(currDate);
        epAvgInvBf.append(":");
        epAvgInvBf.append(currInv.getEpAvgInv());
        epAvgInvBf.append("|");
        // epEopInv
        epEopInvBf.append(currDate);
        epEopInvBf.append(":");
        epEopInvBf.append(currInv.getEpEopInv());
        epEopInvBf.append("|");
        // epInvOut
        epInvOutBf.append(currDate);
        epInvOutBf.append(":");
        epInvOutBf.append(currInv.getEpInvOut());
        epInvOutBf.append("|");
        // epInvIn
        epInvInBf.append(currDate);
        epInvInBf.append(":");
        epInvInBf.append(currInv.getEpInvIn());
        epInvInBf.append("|");

        // rcBopInv
        rcBopInvBf.append(currDate);
        rcBopInvBf.append(":");
        rcBopInvBf.append(currInv.getRcBopInv());
        rcBopInvBf.append("|");
        // rcInvInBf
        rcInvInBf.append(currDate);
        rcInvInBf.append(":");
        rcInvInBf.append(currInv.getRcInvIn());
        rcInvInBf.append("|");
        // rcInvOut
        rcInvOutBf.append(currDate);
        rcInvOutBf.append(":");
        rcInvOutBf.append(currInv.getRcInvOut());
        rcInvOutBf.append("|");
        // ActualInv
        actualInvBf.append(currDate);
        actualInvBf.append(":");
        actualInvBf.append(currInv.getInventory());
        actualInvBf.append("|");
      }
    }
    epAvgInvBf.append(";\n");
    epEopInvBf.append(";\n");
    epInvOutBf.append(";\n");
    epInvInBf.append(";\n");
    actualInvBf.append(";\n");

    rcBopInvBf.append(";\n");
    rcInvInBf.append(";\n");
    rcInvOutBf.append(";\n");

    StringBuffer retBf = new StringBuffer();
    retBf.append(epAvgInvBf.toString());
    retBf.append(epEopInvBf.toString());
    retBf.append(epInvOutBf.toString());
    retBf.append(epInvInBf.toString());
    retBf.append(actualInvBf.toString());
    retBf.append(rcBopInvBf.toString());
    retBf.append(rcInvInBf.toString());
    retBf.append(rcInvOutBf.toString());
    retBf.append("\n");

    return retBf.toString();
  }