private function _setConfig()
 {
     $data = [[CfgParam::ATTR_RANK_ID => self::RANK_MAN, CfgParam::ATTR_SCHEME => self::SCHEMA, CfgParam::ATTR_LEG_MAX => 0, CfgParam::ATTR_LEG_MEDIUM => 0, CfgParam::ATTR_LEG_MIN => 0, CfgParam::ATTR_INFINITY => 0], [CfgParam::ATTR_RANK_ID => self::RANK_MAN_S, CfgParam::ATTR_SCHEME => self::SCHEMA, CfgParam::ATTR_LEG_MAX => 750, CfgParam::ATTR_LEG_MEDIUM => 0, CfgParam::ATTR_LEG_MIN => 0, CfgParam::ATTR_INFINITY => 0], [CfgParam::ATTR_RANK_ID => self::RANK_SUPER, CfgParam::ATTR_SCHEME => self::SCHEMA, CfgParam::ATTR_LEG_MAX => 1500, CfgParam::ATTR_LEG_MEDIUM => 750, CfgParam::ATTR_LEG_MIN => 0, CfgParam::ATTR_INFINITY => 0], [CfgParam::ATTR_RANK_ID => self::RANK_DIR, CfgParam::ATTR_SCHEME => self::SCHEMA, CfgParam::ATTR_LEG_MAX => 2250, CfgParam::ATTR_LEG_MEDIUM => 1500, CfgParam::ATTR_LEG_MIN => 1000, CfgParam::ATTR_INFINITY => 0.01], [CfgParam::ATTR_RANK_ID => self::RANK_DIR_S, CfgParam::ATTR_SCHEME => self::SCHEMA, CfgParam::ATTR_LEG_MAX => 4500, CfgParam::ATTR_LEG_MEDIUM => 3750, CfgParam::ATTR_LEG_MIN => 2250, CfgParam::ATTR_INFINITY => 0.02]];
     foreach ($data as $item) {
         /* replace rank code by rank ID */
         $rankId = $this->_repoRank->getIdByCode($item[CfgParam::ATTR_RANK_ID]);
         $item[CfgParam::ATTR_RANK_ID] = $rankId;
         $this->_repoBasic->addEntity(CfgParam::ENTITY_NAME, $item);
     }
     $this->_logger->debug("Ranks configuration is set.");
 }
 private function _setPercents()
 {
     $PERCENTS = [self::RANK_BY_PV => [0.05], self::RANK_BY_GV => [0.1], self::RANK_BY_PSAA => [0.15, 0.1]];
     foreach ($PERCENTS as $rank => $percents) {
         $calcTypeId = $this->_repoBonusTypeCalc->getIdByCode(Cfg::CODE_TYPE_CALC_BONUS);
         $rankId = $this->_repoBonusRank->getIdByCode($rank);
         $bind = [Generation::ATTR_RANK_ID => $rankId, Generation::ATTR_CALC_TYPE_ID => $calcTypeId];
         $gen = 1;
         foreach ($percents as $percent) {
             $bind[Generation::ATTR_PERCENT] = $percent;
             $bind[Generation::ATTR_GENERATION] = $gen++;
             $this->_repoCore->addEntity(Generation::ENTITY_NAME, $bind);
         }
     }
     $this->_logger->debug("Configuration parameters for Loyalty bonus are set.");
 }
 private function _validateQualification($calcId)
 {
     $EXP_COUNT = 11;
     /* [$custNdx => [$pv, $gv, $psaa], ... ] */
     $EXP_TREE = [1 => [1920, self::RANK_MAX], 2 => [0, 0], 3 => [1020, self::RANK_PRORATED], 4 => [0, 0], 5 => [0, 0], 6 => [0, 0], 8 => [0, 0], 9 => [0, 0], 11 => [0, 0], 12 => [0, 0], 13 => [0, 0]];
     $data = $this->_repoGetQualificationData($calcId);
     $this->assertEquals($EXP_COUNT, count($data));
     foreach ($data as $item) {
         $custId = $item[Compress::ATTR_CUSTOMER_ID];
         $gv = +$item[Qualification::ATTR_GV];
         $rankId = +$item[Qualification::ATTR_RANK_ID];
         $custNdx = $this->_mapCustomerIndexByMageId[$custId];
         $this->assertEquals($EXP_TREE[$custNdx][0], $gv);
         $rankIdExp = $EXP_TREE[$custNdx][1] ? $this->_repoBonusRank->getIdByCode($EXP_TREE[$custNdx][1]) : 0;
         $this->assertEquals($rankIdExp, $rankId);
     }
 }
 /**
  * Add one row to configuration parameters.
  *
  * @param $rankCode
  * @param $schemeCode
  * @param $qPv
  * @param $qTv
  * @param $legMin
  * @param $legMedium
  * @param $legMax
  * @param $infinity
  */
 private function _addConfigParameter($rankCode, $schemeCode, $qPv, $qTv, $legMin, $legMedium, $legMax, $infinity)
 {
     $rankId = $this->_repoRank->getIdByCode($rankCode);
     $bind = [CfgParam::ATTR_RANK_ID => $rankId, CfgParam::ATTR_SCHEME => $schemeCode, CfgParam::ATTR_QUALIFY_PV => $qPv, CfgParam::ATTR_QUALIFY_TV => $qTv, CfgParam::ATTR_LEG_MIN => $legMin, CfgParam::ATTR_LEG_MEDIUM => $legMedium, CfgParam::ATTR_LEG_MAX => $legMax, CfgParam::ATTR_INFINITY => $infinity];
     $this->_repoBasic->addEntity(CfgParam::ENTITY_NAME, $bind);
 }