_inputData = $inputData; $this->_applicantCount = $this->_inputData[1]['applicantsCount']; } protected function _getApplicantAge($DOB = null) { if (!is_null($DOB)) { return App_Wizard_View::getApplicantAge($DOB); } if (!isset($this->_applicantAge)) { $this->_applicantAge = App_Wizard_View::getApplicantAge($this->_currentData[2]['birth']); } return $this->_applicantAge; } protected function _getMinAge() { if (!isset($this->_MinAge)) { $this->_MinAge = App_Settings_Obj::get('maxAgeMA'); } return $this->_MinAge; } protected function _getESIConst() { if (!isset($this->_ESIConst)) { $this->_ESIConst = App_Settings_Obj::get('ESIConst'); } return $this->_ESIConst; } protected function _getApplicantName($applicantIndex) { return $this->_inputData['applicants'][$applicantIndex]; } protected function _unsetCurrentData() { $this->_debugData[] = array_merge( $this->_currentCalculating, array( 'FPL' => $this->_FPL, 'MPC' => $this->_MPC, ) ); unset($this->_applicantAge); unset($this->_FPL); unset($this->_currentCalculating); unset($this->_currentResult); unset($this->_MPC); $this->_resultBlock = false; return $this; } protected function _setCurrentData($applicantIndex) { $this->_currentData = array(); for ($step = 2; $step <= 5; $step++) { if (isset($this->_inputData[$step][$applicantIndex])) { $this->_currentData[$step] = $this->_inputData[$step][$applicantIndex]; } } if (!isset($this->_currentData[2]['pregnancyStatus'])) { $this->_currentData[2]['pregnancyStatus'] = 'not'; } // костиль, який треба буде поправити на формі, бо приходить 1 а не 0 if ('not' == $this->_currentData[2]['pregnancyStatus']) { $this->_currentData[2]['pregnancyChildren'] = 0; } return $this; } protected function _getPercentFPL($percent, $type) { if (!isset($this->_FPL[$type])) { if ($type == 'MA') { /* *FPLMA for January-June = FPL for the previous year *FPLMA for July-December = FPL for the current year */ $month = date('n'); $year = ($month > 6) ? date("Y") : date("Y") - 1; $exception = Qs_Translate::translate(self::NO_DATA_FPLMA, 'Wizard'); } elseif (('y' == App_Settings_Obj::get('useRatesNextYear')) && ($type == "APTC")) { $year = date("Y"); $exception = Qs_Translate::translate(self::NO_DATA_FPLAPTC, 'Wizard'); } else { $year = date("Y") - 1; $exception = Qs_Translate::translate(self::NO_DATA_FPL, 'Wizard'); } $size = $this->_currentCalculating['HHSize' . $type]; if (!($data = (new App_FPL_Obj())->getFPL($year, $size))) { throw new Exception ($exception); } $this->_FPL[$type] = $data['FPL']; } return $this->_FPL[$type] * ($percent / 100); } protected function _addResult() { $appIndex = $this->_currentData[2]['applicantIndex']; $this->_fullResult[$appIndex] = array_merge( $this->_currentResult, array( 'name' => $this->_inputData['applicants'][$appIndex], 'resultBlock' => $this->_resultBlock ) ); return $this; } protected function _setCurrentResult($resultTextId = null, $result = array(), $block = null) { if ($this->_resultBlock) { return $this; } if ($block) { $this->_resultBlock = true; unset($this->_currentResult['resultTextId']); } if (!is_null($resultTextId)) { $this->_currentResult['resultTextId'][$resultTextId] = $resultTextId; } if (isset($result['eligibilityType'])) { $this->_currentResult['eligibilityType'] = $result['eligibilityType']; } if (isset($result['note'])) { $this->_currentResult['note'] = $result['note']; } if (isset($result['ma'])) { $this->_currentResult['ma'] = (int)$result['ma']; } if (isset($result['mcre'])) { $this->_currentResult['mcre'] = (int)$result['mcre']; } if (isset($result['aptc'])) { $this->_currentResult['aptc'] = (int)$result['aptc']; } if (isset($result['csr'])) { $this->_currentResult['csr'] = (int)$result['csr']; } if (isset($result['premiumAmount'])) { $this->_currentResult['premiumAmount'] = (int)$result['premiumAmount']; } return $this; } public function getResult() { for ($i = 0; $i < $this->_applicantCount; $i++) { try { $this->_setCurrentData($i); if ('y' == $this->_currentData[2]['isEligibleMedicare']) { if ($this->_getApplicantAge() > 64) { $this->_setCurrentResult( 3, array( 'eligibilityType' => 'No', 'note' => 'Senior', 'aptc' => false, 'csr' => false, 'mcre' => false, 'ma' => false ) ); } else { $this->_setCurrentResult( 2, array( 'eligibilityType' => 'No', 'note' => 'Disability', 'aptc' => false, 'csr' => false, 'mcre' => false, 'ma' => false ) ); } } elseif ('n' == $this->_currentData[2]['isMnResident']) { $this->_setCurrentResult( 1, array( 'eligibilityType' => 'No', 'aptc' => false, 'csr' => false, 'mcre' => false, 'ma' => false ) ); } elseif ('y' == $this->_currentData[2]['isMnResident']) { $this->_setDefaultIncome(); $this->_processHHSize(); /* * At the end of HHSize Process, System determines * MINCOMEMA[i], AINCOMEMCRE[i] and AINCOMEAPTC (only for i=1) * as the total income for HH for different eligibilities * * настправді підраховується під час процесу */ if ('n' == $this->_currentData[2]['isUSCitizen']) { $this->_processIMM(); } else { $this->_processESI(); } $this->_processMCREP1(); if (!isset($this->_AIncomeAPTC)) { $this->_AIncomeAPTC = $this->_currentCalculating['IncomeAPTC']; } $this->_calculateMPC(); $this->_processAPTC(); $this->_processAmericanIndianResults(); } $this->_addResult(); $this->_unsetCurrentData(); } catch (Exception $e) { return $e->getMessage(); } } $this->_calculateEAPTC(); return $this->_fullResult; } public function getDebugData() { return array('result' => $this->getResult(), 'calculating' => $this->_debugData); } public function getIncomeAPTC($applicantIndex) { $this->_setCurrentData($applicantIndex); $this->_setDefaultIncome(); $this->_processHHSize(); return $this->_currentCalculating['IncomeAPTC']; } protected function _processAmericanIndianResults() { $isAmericanIndian = $this->_currentData[2]['isAmericanIndian']; if ('y' == $isAmericanIndian && array_key_exists(6, $this->_currentResult['resultTextId'])) { if ( $this->_currentCalculating['EAPTC'] > 0 && $this->_currentCalculating['IncomeAPTC'] <= $this->_getPercentFPL('300', 'APTC') && $this->_currentCalculating['IncomeAPTC'] > $this->_getPercentFPL('200', 'APTC') ) { /* If income is over 200% FPL but not more than 300% FPL, and APTC amount is > $0, note AI and apply Results Text #26. */ unset($this->_currentResult['resultTextId'][6]); $this->_setCurrentResult( 26, array( 'eligibilityType' => 'CSR+APTC', 'note' => 'AI', 'aptc' => true ) ); } elseif ( $this->_currentCalculating['EAPTC'] > 0 && $this->_currentCalculating['IncomeAPTC'] <= $this->_getPercentFPL('400', 'APTC') && $this->_currentCalculating['IncomeAPTC'] > $this->_getPercentFPL('300', 'APTC') ) { /* If income is over 300% FPL but not more than 400% FPL, and APTC amount is > $0, note AI and apply Results Text #28. */ unset($this->_currentResult['resultTextId'][6]); $this->_setCurrentResult( 28, array( 'eligibilityType' => 'CSR+APTC', 'note' => 'AI', 'aptc' => true, ) ); } } if ('y' == $isAmericanIndian && array_key_exists(7, $this->_currentResult['resultTextId'])) { if ( $this->_currentCalculating['EAPTC'] = 0 && $this->_currentCalculating['IncomeAPTC'] <= $this->_getPercentFPL('300', 'APTC') && $this->_currentCalculating['IncomeAPTC'] > $this->_getPercentFPL('200', 'APTC') ) { /* If income is over 200% FPL but not more than 300% FPL, and APTC amount is $0, note AI and apply Results Text #27. */ unset($this->_currentResult['resultTextId'][7]); $this->_setCurrentResult( 27, array( 'eligibilityType' => 'CSR', 'note' => 'AI', ) ); } elseif ( $this->_currentCalculating['EAPTC'] = 0 && $this->_currentCalculating['IncomeAPTC'] <= $this->_getPercentFPL('400', 'APTC') && $this->_currentCalculating['IncomeAPTC'] > $this->_getPercentFPL('300', 'APTC') ) { /* If income is over 300% FPL but not more than 400% FPL, and APTC amount is $0, note AI and apply Results Text #29. */ unset($this->_currentResult['resultTextId'][7]); $this->_setCurrentResult( 29, array( 'eligibilityType' => 'CSR', 'note' => 'AI', ) ); } } } protected function _getFILHH() { return isset($this->_FILHH) ? $this->_FILHH : false; } protected function _setFILHH($value) { $this->_FILHH = $value; } protected function _getBenchmarkPlan() { if (!isset($this->_benchmarkPlan)) { $this->_benchmarkPlan = 0; for ($i = 0; $i < $this->_applicantCount; $i++) { if (!(isset($this->_fullResult[$i]['aptc'])) || $this->_fullResult[$i]['aptc'] != false) { $this->_benchmarkPlan += (new App_BenchmarkPlans_Obj())->getBenchmarkPlanRate( $this->_getApplicantAge($this->_inputData[2][$i]['birth']), $this->_inputData[2][$i]['zip'] ); } } } return $this->_benchmarkPlan; } protected function _changeResult($i, $resultTextId = null, $EL = null, $APTC = null, $CSR = null) { if ($this->_fullResult[$i]['resultBlock']) { return $this; } if (!is_null($EL)) { $this->_fullResult[$i]['eligibilityType'] = $EL; } if (!is_null($APTC)) { $this->_fullResult[$i]['aptc'] = (int)$APTC; } if (!is_null($CSR)) { $this->_fullResult[$i]['csr'] = (int)$CSR; } if (!is_null($resultTextId)) { $this->_fullResult[$i]['resultTextId'][$resultTextId] = $resultTextId; } return $this; } protected function _calculateEAPTC() { /* * System finds the appropriate Benchmark Plan Premium * for Applicant based on AGE and ZIP */ for ($i = 0; $i < $this->_applicantCount; $i++) { if (!isset($this->_fullResult[$i]['aptc']) || $this->_currentResult[$i]['aptc'] == true) { $this->_MPC = $this->_debugData[$i]['MPC']; $this->_AIncomeAPTC = $this->_debugData[$i]['IncomeAPTC']; $this->_currentCalculating['EAPTC'] = $this->_getBenchmarkPlan() - round($this->_MPC, 2); if ($this->_currentCalculating['EAPTC'] < 0) { $this->_changeResult($i, null, null, false); } else { $this->_changeResult($i, null, 'APTC', true); } if (!isset($this->_debugData[$i]['FPL']['APTC'])) { $this->_debugData[$i]['FPL']['APTC'] = $this->_debugData[$i]['FPL']['MCRE']; } if ($this->_AIncomeAPTC <= ($this->_debugData[$i]['FPL']['APTC'] * 2.5) && $this->_AIncomeAPTC > ($this->_debugData[$i]['FPL']['APTC'] * 2) ) { $this->_changeResult($i, null, null, null, true); if (!isset($this->_fullResult[$i]['aptc']) || $this->_fullResult[$i]['aptc'] == false) { $this->_changeResult($i, 7, 'CSR', null); } else { $this->_changeResult($i, 6, 'CSR+APTC', true); } } else { $this->_changeResult($i, null, null, null, false); if (!isset($this->_fullResult[$i]['aptc']) || $this->_fullResult[$i]['aptc'] == false) { $this->_changeResult($i, 9); } else { $this->_changeResult($i, 8); } } if ($this->_fullResult[$i]['aptc'] && $this->_currentCalculating['EAPTC'] > 0) { $this->_fullResult[$i] = array_merge( $this->_fullResult[$i], array('aptcAmount' => round($this->_currentCalculating['EAPTC'], 2)) ); } $this->_debugData[$i]['BenchmarkPlan'] = $this->_getBenchmarkPlan(); } } } protected function _processAPTC() { //це додасть FPL[APTC] до резкльтатів дебагу. // відповідно це зможе юзатись в обрахунку EAPTC не залежно від того чи э APTC $this->_getPercentFPL(100,'APTC'); if ('y' == $this->_currentData[4]['isMarried'] && 'filer' == $this->_currentData[4]['taxFilingStatus'] && 'separately' == $this->_currentData[4]['spouseFilingStatus'] ) { $this->_setCurrentResult( 9, array( 'aptc' => false, ) ); } else { if (!$this->_getFILHH()) { $this->_setCurrentResult( 9, array( 'aptc' => false, ) ); } else { if (isset($this->_currentResult['aptc']) && $this->_currentResult['aptc'] == false) { $this->_setCurrentResult( 9, array( 'csr' => false, ) ); } } } return $this; } protected function _calculateMPC() { /* * System determines MPC (expected contribution) by using * appropriate Income and FPL (only for 1st applicant): * * Тепер Рахується для всіх окремо. * * MPC = (MPC2(FPLX-FPL1) + MPC1(FPL2-FPLX))/(FPL2-FPL1) * AINCOMEAPTC / 12 */ if (!isset($this->_MPC)) { $FPL = $this->_getPercentFPL(100, 'APTC'); $FPLX = round(($this->_currentCalculating['IncomeAPTC'] * 100) / $FPL, 2); if (!($data = (new App_MPC_Obj())->getMPC($FPLX))) { throw new Exception(Qs_Translate::translate(self::NO_DATA_MPC, 'Wizard')); } $FPL1 = $data['FPLStart']; $FPL2 = $data['FPLEnd']; $MPC1 = $data['MPCStart']; $MPC2 = $data['MPCEnd']; $IncomeAPTC = $this->_currentCalculating['IncomeAPTC']; $this->_MPC = ((($MPC2 * ($FPLX - $FPL1) + $MPC1 * ($FPL2 - $FPLX)) / 100) / ($FPL2 - $FPL1)) * ($IncomeAPTC / 12); } return $this; } protected function _setDefaultIncome() { $this->_currentCalculating['IncomeMA'] = App_Wizard_View::currencyToFloat( $this->_currentData[2]['monthlyIncome'] ); $this->_currentCalculating['IncomeMCRE'] = App_Wizard_View::currencyToFloat( $this->_currentData[2]['annualIncome'] ); if (!isset($this->_currentCalculating['IncomeAPTC'])) { $this->_currentCalculating['IncomeAPTC'] = App_Wizard_View::currencyToFloat( $this->_currentData[2]['annualIncome'] ); } return $this; } protected function _setIncome($type, $income, $minus) { $this->_currentCalculating[$type] += $minus * App_Wizard_View::currencyToFloat($income); return $this; } protected function _getIncomeType($type) { if ($type == 'MA') { $incomeType = 'monthlyIncome'; } else { $incomeType = 'annualIncome'; } return $incomeType; } protected function _addSpouseIncome($type, $minus = false) { $spouseId = $this->_currentData[4]['spouseId']; $minus = ($minus) ? -1 : 1; if ($spouseId == 'new') { $newApplicantName = $this->_currentData[4]["newSpouse"]; if (!in_array($newApplicantName, $this->_currentCalculating['Applicants' . $type])) { $this->_currentCalculating['HHSize' . $type]++; array_push($this->_currentCalculating['Applicants' . $type], $newApplicantName); $this->_setIncome( 'Income' . $type, $this->_currentData[4]['spouse' . ucfirst($this->_getIncomeType($type))], $minus ); } } elseif (!in_array($this->_getApplicantName($spouseId), $this->_currentCalculating['Applicants' . $type])) { $this->_currentCalculating['HHSize' . $type]++; array_push($this->_currentCalculating['Applicants' . $type], $this->_getApplicantName($spouseId)); $this->_setIncome( 'Income' . $type, $this->_inputData[2][$spouseId][$this->_getIncomeType($type)], $minus ); } return $this; } protected function _addSizeAndIncome($type, $incomer, $minus = false, $ending = 's') { $count = (isset($this->_currentData[4][$incomer . $ending . 'Count'])) ? $this->_currentData[4][$incomer . $ending . 'Count'] : 0; $minus = ($minus) ? -1 : 1; for ($i = 0; $i < $count; $i++) { $id = $this->_currentData[4][$incomer . 'Id_' . $i]; if (0 === strpos($id, 'new')) { if ($id == 'new') { $newApplicantName = $this->_currentData[4]["new" . ucfirst($incomer) . '_' . $i]; $income = $this->_currentData[4][$incomer . ucfirst($this->_getIncomeType($type)) . '_' . $i]; }else{ $newApplicantName = substr($id, 4); $income = $this->_inputData['additionalPersons'][$newApplicantName][$this->_getIncomeType($type)]; }; if (!in_array($newApplicantName, $this->_currentCalculating['Applicants' . $type])) { $this->_currentCalculating['HHSize' . $type]++; array_push($this->_currentCalculating['Applicants' . $type], $newApplicantName); $this->_setIncome( 'Income' . $type, $income, $minus ); } } elseif (!in_array($this->_getApplicantName($id), $this->_currentCalculating['Applicants' . $type])) { $this->_currentCalculating['HHSize' . $type]++; array_push($this->_currentCalculating['Applicants' . $type], $this->_getApplicantName($id)); $this->_setIncome( 'Income' . $type, $this->_inputData[2][$id][$this->_getIncomeType($type)], $minus ); } } return $this; } protected function _processMCREP1() { if ($this->_currentCalculating['IncomeMA'] <= $this->_getPercentFPL(280, 'MA')) { if ($this->_getApplicantAge() < $this->_getMinAge() || 'currently' == $this->_currentData[2]['pregnancyStatus'] || 'recently' == $this->_currentData[2]['pregnancyStatus'] ) { $this->_setCurrentResult( 4, array( 'eligibilityType' => 'MA', 'ma' => true, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } elseif ( $this->_currentCalculating['IncomeMA'] <= $this->_getPercentFPL(138, 'MA') ) { if (!isset($this->_currentResult['ma']) || $this->_currentResult['ma'] != false) { $this->_setCurrentResult( 4, array( 'eligibilityType' => 'MA', 'ma' => true, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } else { /*checkMCRE and process Result #5 or #25*/ $this->_checkMCRE(); } } else { $this->_processMCREP2(); } } else { $this->_processMCREP2(); } return $this; } protected function _checkMCRE() { if (!isset($this->_currentResult['mcre']) || false != $this->_currentResult['mcre']) { if ('y' == $this->_currentData[2]['isAmericanIndian']) { /* If eligible for MCRE, note AI and apply Results Text #25 instead of #5 */ $this->_setCurrentResult( 25, array( 'eligibilityType' => 'MCRE', 'note' => 'AI', 'ma' => false, 'mcre' => true, 'aptc' => false, 'csr' => false, ), true ); } else { $premium = $this->_calculateMonthlyPremium($this->_currentCalculating['IncomeMCRE'], 'MCRE'); if( $this->_getApplicantAge() < 21 || $this->_currentCalculating['IncomeMCRE'] < $this->_getPercentFPL(35, 'MCRE') ){ $premium = 0; } $this->_setCurrentResult( 5, array( 'eligibilityType' => 'MCRE', 'note' => '2', 'ma' => false, 'mcre' => true, 'aptc' => false, 'csr' => false, 'premiumAmount' => $premium ), true ); } } return $this; } protected function _processMCREP2() { if (($this->_currentCalculating['IncomeMCRE'] <= $this->_getPercentFPL(200, 'MCRE') && $this->_currentCalculating['IncomeMCRE'] > $this->_getPercentFPL(138, 'MCRE')) ) { /*checkMCRE and process Result #5 or #25*/ $this->_checkMCRE(); } elseif ($this->_currentCalculating['IncomeMCRE'] <= $this->_getPercentFPL(138, 'MCRE') && $this->_currentCalculating['IncomeMA'] > $this->_getPercentFPL(138, 'MA') ) { $this->_setCurrentResult( 4, array( 'eligibilityType' => 'MA', 'ma' => true, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } else { $this->_setCurrentResult( null, array( 'ma' => false, 'mcre' => false, ) ); } return $this; } protected function _calculateMonthlyPremium($incomeAmount, $type) { $fpl100 = $this->_getPercentFPL(100, $type); $realFplPercent = $incomeAmount * 100 / $fpl100; if (!($premium = (new App_MinnesotaCare_Obj())->getPremium(date("Y"), $realFplPercent))) { throw new Exception (Qs_Translate::translate(self::NO_DATA_PREMIUM, 'Wizard')); } return $premium; } protected function _processIMM() { if ('y' == $this->_currentData[3]['isLawfully']) { if ('other' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 12, array( 'note' => 'OtherImmStatus', ) ); } else { if ('currently' == $this->_currentData[2]['pregnancyStatus'] || 'recently' == $this->_currentData[2]['pregnancyStatus'] ) { if ('studentOrWorker' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 10, array( 'note' => 'Student/Worker', 'ma' => false, ) ); } elseif ('daca' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 14, array( 'eligibilityType' => 'MA', 'note' => 'CHIP', 'ma' => true, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } } else { if ($this->_getApplicantAge() < 21) { if ('daca' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 15, array( 'eligibilityType' => 'No', 'note' => 'EMA', 'ma' => false, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } } else { if ('lawful' == $this->_currentData[3]['immigrationStatus'] || 'vawa' == $this->_currentData[3]['immigrationStatus'] ) { if ('n' == $this->_currentData[3]['isStatusLongerFiveYear'] && 'n' == $this->_currentData[3]['isEnterAsRefugeeOrAsylee'] ) { $this->_setCurrentResult( 16, array( 'ma' => false, ) ); } } else { if ('daca' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 19, array( 'eligibilityType' => 'No', 'note' => 'EMA', 'ma' => false, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } else { if ('studentOrWorker' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 17, array( 'note' => 'Student/Worker', 'ma' => false, ) ); } elseif ('u-visa' == $this->_currentData[3]['immigrationStatus']) { $this->_setCurrentResult( 18, array( 'note' => 'U-Visa', 'ma' => false, ) ); } } } } } } } else { if ('currently' == $this->_currentData[2]['pregnancyStatus'] || 'recently' == $this->_currentData[2]['pregnancyStatus'] ) { $this->_setCurrentResult( 10, array( 'eligibilityType' => 'MA', 'note' => 'CHIP', 'ma' => true, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } else { $this->_setCurrentResult( 11, array( 'eligibilityType' => 'EMA', 'note' => 'CHIP', 'ma' => false, 'mcre' => false, 'aptc' => false, 'csr' => false, ), true ); } } return $this; } protected function _processESI() { if ('haveUse' == $this->_currentData[5]['insuranceSituation']) { $this->_setCurrentResult( 20, array( 'mcre' => false, 'aptc' => false, 'csr' => false, ) ); $this->_currentResult['ResultTextId'] = 20; } elseif ('haveNotUse' == $this->_currentData[5]['insuranceSituation']) { if ($this->_currentData[5]['monthlyPremium'] * 12 <= $this->_getESIConst() * $this->_currentCalculating['IncomeAPTC'] ) { if ('y' == $this->_currentData[5]['isInsuranceOfferMin']) { $this->_setCurrentResult( 21, array( 'mcre' => false, 'aptc' => false, 'csr' => false, ) ); } } } return $this; } protected function _processHHSize() { $applicantIndex = $this->_currentData[2]['applicantIndex']; $this->_currentCalculating['HHSizeMA'] = 1 + $this->_currentData[2]['pregnancyChildren']; $this->_currentCalculating['ApplicantsMA'] = array($this->_getApplicantName($applicantIndex)); $this->_currentCalculating['HHSizeMCRE'] = 1; $this->_currentCalculating['ApplicantsMCRE'] = array($this->_getApplicantName($applicantIndex)); $this->_currentCalculating['HHSizeAPTC'] = 1; $this->_currentCalculating['ApplicantsAPTC'] = array($this->_getApplicantName($applicantIndex)); if ('filer' == $this->_currentData[4]['taxFilingStatus']) { $this->_countHHSizeBySpouseP1(); } elseif ('dependent' == $this->_currentData[4]['taxFilingStatus'] && 'y' == $this->_currentData[4]['isChildOrSpouseTaxFiler'] && $this->_getApplicantAge() < $this->_getMinAge() && 'n' == $this->_currentData[4]['isChildLivesUnmarriedParents'] && 'n' == $this->_currentData[4]['isChildNoncustodialParent'] ) { $this->_countHHSizeBySpouseP1(); } else { if ($this->_getApplicantAge() < $this->_getMinAge()) { $this->_countHHSizeLessMinAge(); } else { $this->_countHHSizeMoreMinAge(); } } $this->_currentCalculating['IncomeMA'] = $this->_currentCalculating['IncomeMA'] * 12; return $this; } protected function _countHHSizeLessMinAge() { $this->_addSizeAndIncome('MA', 'sibling'); $this->_addSizeAndIncome('MA', 'parent'); if ('noTaxNoDependent' == $this->_currentData[4]['taxFilingStatus']) { if ('y' == $this->_currentData[4]['isMarried'] && 'y' == $this->_currentData[4]['isLivingTogether'] ) { $this->_addSpouseIncome('MA'); } $this->_addSizeAndIncome('MCRE', 'sibling'); $this->_addSizeAndIncome('MCRE', 'parent'); $this->_addSizeAndIncome('MCRE', 'child', null, 'ren'); } else { if ('y' == $this->_currentData[4]['isMarried'] && 'y' == $this->_currentData[4]['isLivingTogether'] ) { $this->_addSpouseIncome('MA'); } $this->_countHHSizeBySpouseP2(); } return $this; } protected function _countHHSizeMoreMinAge() { if ('y' == $this->_currentData[4]['isMarried'] && 'y' == $this->_currentData[4]['isLivingTogether']) { $this->_addSpouseIncome('MA'); } $this->_addSizeAndIncome('MA', 'child', null, 'ren'); if ('noTaxNoDependent' == $this->_currentData[4]['taxFilingStatus']) { $this->_addSizeAndIncome('MCRE', 'child', null, 'ren'); } else { $this->_countHHSizeBySpouseP2(); } return $this; } protected function _countHHSizeBySpouseP1() { $this->_setFILHH(true); if ('y' == $this->_currentData[4]['isMarried']) { if ('y' == $this->_currentData[4]['isLivingTogether']) { $this->_addSpouseIncome('MA'); $this->_addSpouseIncome('APTC'); } if ('filer' != $this->_currentData[4]['taxFilingStatus'] && 'jointly' != $this->_currentData[4]['spouseFilingStatus'] ) { $this->_addSpouseIncome('MCRE'); } $this->_addSpouseIncome('MCRE'); } $this->_countHHSizeBySpouseP2(); return $this; } protected function _countHHSizeBySpouseP2() { if ('filer' == $this->_currentData[4]['taxFilingStatus']) { $this->_addSizeAndIncome('MCRE', 'dependent'); $this->_addSizeAndIncome('MA', 'dependent'); $this->_addSizeAndIncome('APTC', 'dependent'); } else { $this->_addSizeAndIncome('MCRE', 'filer'); $this->_addSizeAndIncome('MCRE', 'filersDependent'); $this->_addSizeAndIncome('MA', 'filer'); $this->_addSizeAndIncome('MA', 'filersDependent'); $this->_addSizeAndIncome('APTC', 'filer'); $this->_addSizeAndIncome('APTC', 'filersDependent'); } return $this; } }