/** * Sub-functionality to get period and calculation data for depended calculation. * * @param \Praxigento\BonusBase\Service\Period\Response\GetForDependentCalc $result * @param int $basePeriodId * @param string $baseCalcTypeCode * @param string $baseDsBegin * @param string $baseDsEnd * @param string $dependentCalcTypeCode * @param int $dependentCalcTypeId * @return \Praxigento\BonusBase\Service\Period\Response\GetForDependentCalc */ public function getDependedCalc(\Praxigento\BonusBase\Service\Period\Response\GetForDependentCalc $result, $basePeriodId, $baseCalcTypeCode, $baseDsBegin, $baseDsEnd, $dependentCalcTypeCode, $dependentCalcTypeId) { $baseCalcData = $this->_repoService->getLastCalcForPeriodById($basePeriodId); $result->setBaseCalcData($baseCalcData); /* get depended data for complete base calculation */ if ($baseCalcData && $baseCalcData->getState() == Cfg::CALC_STATE_COMPLETE) { /* there is complete base calculation, get period for depended calc */ $this->_getForCompleteBase($result, $baseCalcTypeCode, $baseDsBegin, $baseDsEnd, $dependentCalcTypeCode, $dependentCalcTypeId); } else { /* there is no complete Base Calculation */ $msg = "There is no complete base '{$baseCalcTypeCode}' calculation for dependent " . "'{$dependentCalcTypeCode}' calculation. New period could not be created."; $this->_logger->warning($msg); } return $result; }
public function getLatest(Request\GetLatest $request) { $result = new Response\GetLatest(); $calcTypeId = $request->getCalcTypeId(); $calcTypeCode = $request->getCalcTypeCode(); $msgParams = is_null($calcTypeId) ? "type code '{$calcTypeCode}'" : "type ID #{$calcTypeId}"; $this->_logger->info("'Get latest calculation period' operation is started with {$msgParams} in bonus base module."); if (is_null($calcTypeId)) { /* get calculation type ID by type code */ $calcTypeId = $this->_repoTypeCalc->getIdByCode($calcTypeCode); $this->_logger->info("There is only calculation type code ({$calcTypeCode}) in request, calculation type id = {$calcTypeId}."); } $periodLatest = $this->_repoService->getLastPeriodByCalcType($calcTypeId); if ($periodLatest) { $result->setPeriodData($periodLatest); /* add period calculations to result set */ $periodId = $periodLatest->getId(); $calcLatest = $this->_repoService->getLastCalcForPeriodById($periodId); $result->setCalcData($calcLatest); } $result->markSucceed(); $this->_logger->info("'Get latest calculation period' operation is completed in bonus base module."); return $result; }