Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 81 |
ExamRegistrationFeeCommonService | |
0.00% |
0 / 1 |
|
0.00% |
0 / 6 |
420.00 | |
0.00% |
0 / 81 |
__construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
getCurrentFeeTemplateForStudent | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 15 |
|||
checkIfRulesMatches | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 9 |
|||
checkIfIndividualRuleMatches | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 12 |
|||
getAllOperations | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 26 |
|||
getCurrentSubjectFeeTemplateForStudent | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 17 |
<?php | |
namespace com\linways\ec\core\service; | |
use com\linways\base\util\MakeSingletonTrait; | |
use com\linways\ec\core\exception\ExamControllerException; | |
use com\linways\ec\core\service\ExamRegistrationSubjectService; | |
use com\linways\core\ams\professional\service\CommonService; | |
use com\linways\core\ams\professional\constant\SettingsConstants; | |
use com\linways\ec\core\constant\ExamFeeOperators; | |
use com\linways\ec\core\mapper\ExamAttendanceServiceMapper; | |
use com\linways\core\ams\professional\constant\examcontroller\ExamRegistrationFeePaymentConstants; | |
class ExamRegistrationFeeCommonService extends BaseService | |
{ | |
use MakeSingletonTrait; | |
private function __construct() { | |
$this->mapper = ExamAttendanceServiceMapper::getInstance()->getMapper(); | |
} | |
/** | |
* Insert ExamRegistration | |
* @param ExamRegistration $examRegistration | |
* @return $id | |
*/ | |
public function getCurrentFeeTemplateForStudent($studentDetails){ | |
$commonBatchFee = new \stdClass; | |
foreach($studentDetails->batchFeeFine as $batchFeeFine){ | |
$batchOperationPropertiesArr = (array)$batchFeeFine->batchOperationProperties; | |
if($batchOperationPropertiesArr){ | |
$batchOperationPropertiesRules = (array)$batchFeeFine->batchOperationProperties->operations; | |
if ($this->checkIfRulesMatches($batchOperationPropertiesRules, $studentDetails)){ | |
return($batchFeeFine); | |
} | |
} | |
else{ | |
$commonBatchFee = $batchFeeFine; | |
} | |
} | |
return($commonBatchFee); | |
} | |
public function checkIfRulesMatches($rules, $studentDetails){ | |
$operations = $this->getAllOperations(); | |
foreach($rules as $innerRule){ | |
$currentOperation = $operations[$innerRule->id]; | |
if(!$this->checkIfIndividualRuleMatches($innerRule,$currentOperation,$studentDetails)){ | |
return false; | |
} | |
} | |
return true; | |
} | |
public function checkIfIndividualRuleMatches($innerRule,$currentOperation,$student){ | |
$operandName = $currentOperation->properties->baseTablecolumnId; | |
$studentValue = $student->{$operandName}; | |
$operand = $innerRule->operand; | |
switch ($operand) { | |
case ExamFeeOperators::EQ: | |
if (!empty($studentValue) && $studentValue == $innerRule->value) { | |
return true; | |
} | |
break; | |
} | |
return false; | |
} | |
/** | |
* getAllOperations | |
* @return operations | |
* @throws ExamControllerException | |
*/ | |
public function getAllOperations(){ | |
$sql = ""; | |
$operationArray = []; | |
$sql = "SELECT | |
id, | |
code, | |
display_name, | |
operation, | |
remark, | |
properties | |
FROM | |
ec_fee_operations"; | |
try { | |
$operations = $this->executeQueryForList($sql); | |
} catch (\Exception $e) { | |
throw new ExamControllerException($e->getCode(), $e->getMessage()); | |
} | |
foreach($operations as $operation){ | |
$operationArray[$operation->id]->id = $operation->id; | |
$operationArray[$operation->id]->code = $operation->code; | |
$operationArray[$operation->id]->display_name = $operation->display_name; | |
$operationArray[$operation->id]->remark = $operation->remark; | |
$operationArray[$operation->id]->operation = json_decode($operation->operation); | |
$operationArray[$operation->id]->properties = json_decode($operation->properties); | |
} | |
return $operationArray; | |
} | |
/** | |
* Insert ExamRegistration | |
* @param ExamRegistration $examRegistration | |
* @return $id | |
*/ | |
public function getCurrentSubjectFeeTemplateForStudent($subject,$studentDetails){ | |
$commonSubjectFeeTemplateId = ""; | |
foreach($studentDetails->batchFeeFine as $batchFeeFine){ | |
if(in_array ( $batchFeeFine->id, $subject->subjectFeeTemplateIdsArray)){ | |
$batchOperationPropertiesArr = (array)$batchFeeFine->batchOperationProperties; | |
if($batchOperationPropertiesArr){ | |
$batchOperationPropertiesRules = (array)$batchFeeFine->batchOperationProperties->operations; | |
if ($this->checkIfRulesMatches($batchOperationPropertiesRules, $studentDetails)){ | |
return($batchFeeFine->id); | |
} | |
} | |
else{ | |
$commonSubjectFeeTemplateId = $batchFeeFine->id; | |
} | |
} | |
} | |
return($commonSubjectFeeTemplateId); | |
} | |
} |