code: private function getPlainCalcId($period)
      {
          if ($period) {
              $dsMax = $this->hlpPeriod->getPeriodLastDate($period);
          } else {
              $dsMax = Cfg::DEF_MAX_DATESTAMP;
          }
          /* prepare query */
          $query = $this->qbCalcGetLast->build();
          $bind = [
              QBCalcGetLast::BND_CODE => Cfg::CODE_TYPE_CALC_FORECAST_PLAIN,
              QBCalcGetLast::BND_DATE => $dsMax,
              QBCalcGetLast::BND_STATE => Cfg::CALC_STATE_COMPLETE
          ];
  
          /* fetch & parse data */
          $conn = $query->getConnection();
          $rs = $conn->fetchRow($query, $bind);
          $result = $rs[QBCalcGetLast::A_CALC_ID];
          return $result;
      }
docs: Get ID for the last complete forecast plain calculation.
  
  @param string $period YYYYMM
  @return int