setEnableQuickPunch( false ); //Helps prevent duplicate punch IDs and validation failures. $dd->setUserNamePostFix( '_' . uniqid( null, true ) ); //Needs to be super random to prevent conflicts and random failing tests. $this->company_id = $dd->createCompany(); $this->legal_entity_id = $dd->createLegalEntity( $this->company_id, 10 ); Debug::text( 'Company ID: ' . $this->company_id, __FILE__, __LINE__, __METHOD__, 10 ); //$dd->createPermissionGroups( $this->company_id, 40 ); //Administrator only. $dd->createCurrency( $this->company_id, 10 ); $dd->createPayStubAccount( $this->company_id ); $this->createPayStubAccounts(); //$this->createPayStubAccrualAccount(); $dd->createPayStubAccountLink( $this->company_id ); $this->getPayStubAccountLinkArray(); $dd->createUserWageGroups( $this->company_id ); $this->user_wage_groups = $dd->user_wage_groups; $this->user_id = $dd->createUser( $this->company_id, $this->legal_entity_id, 100 ); $this->createPayPeriodSchedule(); $this->createPayPeriods(); $this->getAllPayPeriods(); $this->policy_ids['accrual_policy_account'][10] = $dd->createAccrualPolicyAccount( $this->company_id, 10 ); //Bank $this->policy_ids['accrual_policy_account'][20] = $dd->createAccrualPolicyAccount( $this->company_id, 20 ); //Vacation $this->policy_ids['accrual_policy_account'][30] = $dd->createAccrualPolicyAccount( $this->company_id, 30 ); //Sick $this->policy_ids['pay_formula_policy'][100] = $dd->createPayFormulaPolicy( $this->company_id, 100 ); //Reg 1.0x $this->policy_ids['pay_formula_policy'][910] = $this->createPayFormulaPolicy( $this->company_id, 910, $this->policy_ids['accrual_policy_account'][10] ); //Bank $this->policy_ids['pay_formula_policy'][1101] = $this->createPayFormulaPolicy( $this->company_id, 1101 ); //Reg Alt Wage #1 $this->policy_ids['pay_formula_policy'][1102] = $this->createPayFormulaPolicy( $this->company_id, 1102 ); //Reg Alt Wage #2 $this->policy_ids['pay_code'][100] = $dd->createPayCode( $this->company_id, 100, $this->policy_ids['pay_formula_policy'][100] ); //Regular $this->policy_ids['pay_code'][101] = $dd->createPayCode( $this->company_id, 101, $this->policy_ids['pay_formula_policy'][1101] ); //Regular B1 Alt Wage #1 $this->policy_ids['pay_code'][102] = $dd->createPayCode( $this->company_id, 102, $this->policy_ids['pay_formula_policy'][1102] ); //Regular B2 Alt Wage #2 $this->policy_ids['pay_code'][190] = $dd->createPayCode( $this->company_id, 190, $this->policy_ids['pay_formula_policy'][100] ); //Lunch $this->policy_ids['pay_code'][192] = $dd->createPayCode( $this->company_id, 192, $this->policy_ids['pay_formula_policy'][100] ); //Break $this->policy_ids['pay_code'][300] = $dd->createPayCode( $this->company_id, 300, $this->policy_ids['pay_formula_policy'][100] ); //Prem1 $this->policy_ids['pay_code'][310] = $dd->createPayCode( $this->company_id, 310, $this->policy_ids['pay_formula_policy'][100] ); //Prem2 $this->policy_ids['pay_code'][900] = $dd->createPayCode( $this->company_id, 900, $this->policy_ids['pay_formula_policy'][910] ); //Vacation $this->policy_ids['pay_code'][910] = $dd->createPayCode( $this->company_id, 910, $this->policy_ids['pay_formula_policy'][100] ); //Bank $this->policy_ids['pay_code'][920] = $dd->createPayCode( $this->company_id, 920, $this->policy_ids['pay_formula_policy'][100] ); //Sick $this->policy_ids['contributing_pay_code_policy'][10] = $dd->createContributingPayCodePolicy( $this->company_id, 10, [ $this->policy_ids['pay_code'][100], $this->policy_ids['pay_code'][101], $this->policy_ids['pay_code'][102] ] ); //Regular $this->policy_ids['contributing_pay_code_policy'][12] = $dd->createContributingPayCodePolicy( $this->company_id, 12, [ $this->policy_ids['pay_code'][100], $this->policy_ids['pay_code'][101], $this->policy_ids['pay_code'][102], $this->policy_ids['pay_code'][190], $this->policy_ids['pay_code'][192] ] ); //Regular+Meal/Break $this->policy_ids['contributing_pay_code_policy'][14] = $dd->createContributingPayCodePolicy( $this->company_id, 14, [ $this->policy_ids['pay_code'][100], $this->policy_ids['pay_code'][101], $this->policy_ids['pay_code'][102], $this->policy_ids['pay_code'][190], $this->policy_ids['pay_code'][192], $this->policy_ids['pay_code'][900] ] ); //Regular+Meal/Break+Absence $this->policy_ids['contributing_pay_code_policy'][90] = $dd->createContributingPayCodePolicy( $this->company_id, 90, [ $this->policy_ids['pay_code'][900] ] ); //Absence $this->policy_ids['contributing_pay_code_policy'][99] = $dd->createContributingPayCodePolicy( $this->company_id, 99, $this->policy_ids['pay_code'] ); //All Time $this->policy_ids['contributing_shift_policy'][10] = $dd->createContributingShiftPolicy( $this->company_id, 10, $this->policy_ids['contributing_pay_code_policy'][10] ); //Regular $this->policy_ids['contributing_shift_policy'][12] = $dd->createContributingShiftPolicy( $this->company_id, 20, $this->policy_ids['contributing_pay_code_policy'][12] ); //Regular+Meal/Break $this->policy_ids['contributing_shift_policy'][14] = $dd->createContributingShiftPolicy( $this->company_id, 40, $this->policy_ids['contributing_pay_code_policy'][14] ); //Regular+Meal/Break+Absence $this->policy_ids['contributing_shift_policy'][90] = $dd->createContributingShiftPolicy( $this->company_id, 90, $this->policy_ids['contributing_pay_code_policy'][90] ); //Absence $this->policy_ids['regular'][10] = $dd->createRegularTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['pay_code'][100] ); $this->policy_ids['regular'][12] = $dd->createRegularTimePolicy( $this->company_id, 20, $this->policy_ids['contributing_shift_policy'][12], $this->policy_ids['pay_code'][100] ); $this->policy_ids['absence'][10] = $dd->createAbsencePolicy( $this->company_id, 10, $this->policy_ids['pay_code'][900] ); //Vacation $this->policy_ids['absence'][11] = $dd->createAbsencePolicy( $this->company_id, 11, $this->policy_ids['pay_code'][900] ); //Vacation (B) $this->branch_ids[] = $dd->createBranch( $this->company_id, 10 ); $this->branch_ids[] = $dd->createBranch( $this->company_id, 20 ); $this->assertTrue( TTUUID::isUUID( $this->company_id ) ); $this->assertTrue( TTUUID::isUUID( $this->user_id ) ); } public function tearDown(): void { Debug::text( 'Running tearDown(): ', __FILE__, __LINE__, __METHOD__, 10 ); } function getPayStubAccountLinkArray() { $this->pay_stub_account_link_arr = [ 'total_gross' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 40, 'Total Gross' ), 'total_deductions' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 40, 'Total Deductions' ), 'employer_contribution' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 40, 'Employer Total Contributions' ), 'net_pay' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 40, 'Net Pay' ), 'regular_time' => CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 10, 'Regular Time' ), ]; return true; } function createPayStubAccounts() { Debug::text( 'Saving.... Employee Deduction - Other', __FILE__, __LINE__, __METHOD__, 10 ); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany( $this->company_id ); $pseaf->setStatus( 10 ); $pseaf->setType( 20 ); $pseaf->setName( 'Other' ); $pseaf->setOrder( 290 ); if ( $pseaf->isValid() ) { $pseaf->Save(); } Debug::text( 'Saving.... Employee Deduction - Other2', __FILE__, __LINE__, __METHOD__, 10 ); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany( $this->company_id ); $pseaf->setStatus( 10 ); $pseaf->setType( 20 ); $pseaf->setName( 'Other2' ); $pseaf->setOrder( 291 ); if ( $pseaf->isValid() ) { $pseaf->Save(); } Debug::text( 'Saving.... Employee Deduction - EI', __FILE__, __LINE__, __METHOD__, 10 ); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany( $this->company_id ); $pseaf->setStatus( 10 ); $pseaf->setType( 20 ); $pseaf->setName( 'EI' ); $pseaf->setOrder( 292 ); if ( $pseaf->isValid() ) { $pseaf->Save(); } Debug::text( 'Saving.... Employee Deduction - CPP', __FILE__, __LINE__, __METHOD__, 10 ); $pseaf = new PayStubEntryAccountFactory(); $pseaf->setCompany( $this->company_id ); $pseaf->setStatus( 10 ); $pseaf->setType( 20 ); $pseaf->setName( 'CPP' ); $pseaf->setOrder( 293 ); if ( $pseaf->isValid() ) { $pseaf->Save(); } //Link Account EI and CPP accounts $pseallf = new PayStubEntryAccountLinkListFactory(); $pseallf->getByCompanyId( $this->company_id ); if ( $pseallf->getRecordCount() > 0 ) { $pseal_obj = $pseallf->getCurrent(); $pseal_obj->setEmployeeEI( CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 20, 'EI' ) ); $pseal_obj->setEmployeeCPP( CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $this->company_id, 20, 'CPP' ) ); $pseal_obj->Save(); } return true; } function createPayPeriodSchedule() { $ppsf = new PayPeriodScheduleFactory(); $ppsf->setCompany( $this->company_id ); //$ppsf->setName( 'Bi-Weekly'.rand(1000,9999) ); $ppsf->setName( 'Bi-Weekly' ); $ppsf->setDescription( 'Pay every two weeks' ); $ppsf->setType( 20 ); $ppsf->setStartWeekDay( 0 ); $anchor_date = TTDate::getBeginWeekEpoch( TTDate::incrementDate( time(), -42, 'day' ) ); //Start 6 weeks ago $ppsf->setAnchorDate( $anchor_date ); $ppsf->setStartDayOfWeek( TTDate::getDayOfWeek( $anchor_date ) ); $ppsf->setTransactionDate( 7 ); $ppsf->setTransactionDateBusinessDay( true ); $ppsf->setTimeZone( 'America/Vancouver' ); $ppsf->setDayStartTime( 0 ); $ppsf->setNewDayTriggerTime( ( 4 * 3600 ) ); $ppsf->setMaximumShiftTime( ( 16 * 3600 ) ); $ppsf->setShiftAssignedDay( 10 ); $ppsf->setEnableInitialPayPeriods( false ); if ( $ppsf->isValid() ) { $insert_id = $ppsf->Save( false ); Debug::Text( 'Pay Period Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); $ppsf->setUser( [ $this->user_id ] ); $ppsf->Save(); $this->pay_period_schedule_id = $insert_id; return $insert_id; } Debug::Text( 'Failed Creating Pay Period Schedule!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createPayPeriods() { $max_pay_periods = 35; $ppslf = new PayPeriodScheduleListFactory(); $ppslf->getById( $this->pay_period_schedule_id ); if ( $ppslf->getRecordCount() > 0 ) { $pps_obj = $ppslf->getCurrent(); $end_date = null; for ( $i = 0; $i < $max_pay_periods; $i++ ) { if ( $i == 0 ) { $end_date = TTDate::getBeginWeekEpoch( ( TTDate::getBeginWeekEpoch( time() ) - ( 86400 * ( 7 * 52 ) ) ) ); //Go back 52 weeks. } else { $end_date = TTDate::incrementDate( $end_date, 14, 'day' ); } Debug::Text( 'I: ' . $i . ' End Date: ' . TTDate::getDate( 'DATE+TIME', $end_date ), __FILE__, __LINE__, __METHOD__, 10 ); $pps_obj->createNextPayPeriod( $end_date, ( 86400 + 3600 ), false ); //Don't import punches, as that causes deadlocks when running tests in parallel. } } return true; } function getAllPayPeriods() { $pplf = new PayPeriodListFactory(); //$pplf->getByCompanyId( $this->company_id ); $pplf->getByPayPeriodScheduleId( $this->pay_period_schedule_id ); if ( $pplf->getRecordCount() > 0 ) { foreach ( $pplf as $pp_obj ) { Debug::text( 'Pay Period... Start: ' . TTDate::getDate( 'DATE+TIME', $pp_obj->getStartDate() ) . ' End: ' . TTDate::getDate( 'DATE+TIME', $pp_obj->getEndDate() ), __FILE__, __LINE__, __METHOD__, 10 ); $this->pay_period_objs[] = $pp_obj; } } $this->pay_period_objs = array_reverse( $this->pay_period_objs ); return true; } function getCurrentPayPeriod( $epoch = null ) { if ( $epoch == '' ) { $epoch = time(); } $this->getAllPayPeriods(); //This doesn't return the pay periods, just populates an array and returns TRUE. $pay_periods = $this->pay_period_objs; if ( is_array( $pay_periods ) ) { foreach ( $pay_periods as $pp_obj ) { if ( $pp_obj->getStartDate() <= $epoch && $pp_obj->getEndDate() >= $epoch ) { Debug::text( 'Current Pay Period... Start: ' . TTDate::getDate( 'DATE+TIME', $pp_obj->getStartDate() ) . ' End: ' . TTDate::getDate( 'DATE+TIME', $pp_obj->getEndDate() ), __FILE__, __LINE__, __METHOD__, 10 ); return $pp_obj; } } } Debug::text( 'Current Pay Period not found! Epoch: ' . TTDate::getDate( 'DATE+TIME', $epoch ), __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createSchedulePolicy( $type, $meal_policy_id ) { $spf = TTnew( 'SchedulePolicyFactory' ); /** @var SchedulePolicyFactory $spf */ $spf->setCompany( $this->company_id ); switch ( $type ) { case 10: //Normal $spf->setName( 'Schedule Policy' ); //$spf->setAbsencePolicyID( 0 ); $spf->setStartStopWindow( ( 3600 * 2 ) ); break; case 20: //No Lunch $spf->setName( 'No Lunch' ); //$spf->setAbsencePolicyID( 0 ); $spf->setStartStopWindow( ( 3600 * 2 ) ); break; } if ( $spf->isValid() ) { $insert_id = $spf->Save( false ); $spf->setMealPolicy( $meal_policy_id ); Debug::Text( 'Schedule Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Schedule Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createSchedule( $user_id, $date_stamp, $data = null ) { $sf = TTnew( 'ScheduleFactory' ); /** @var ScheduleFactory $sf */ $sf->setCompany( $this->company_id ); $sf->setUser( $user_id ); //$sf->setUserDateId( UserDateFactory::findOrInsertUserDate( $user_id, $date_stamp) ); if ( isset( $data['status_id'] ) ) { $sf->setStatus( $data['status_id'] ); } else { $sf->setStatus( 10 ); } if ( isset( $data['schedule_policy_id'] ) ) { $sf->setSchedulePolicyID( $data['schedule_policy_id'] ); } if ( isset( $data['absence_policy_id'] ) ) { $sf->setAbsencePolicyID( $data['absence_policy_id'] ); } if ( isset( $data['branch_id'] ) ) { $sf->setBranch( $data['branch_id'] ); } if ( isset( $data['department_id'] ) ) { $sf->setDepartment( $data['department_id'] ); } if ( isset( $data['job_id'] ) ) { $sf->setJob( $data['job_id'] ); } if ( isset( $data['job_item_id'] ) ) { $sf->setJobItem( $data['job_item_id'] ); } if ( isset( $data['punch_tag_id'] ) ) { $sf->setPunchTag( $data['punch_tag_id'] ); } if ( $data['start_time'] != '' ) { $start_time = strtotime( $data['start_time'], $date_stamp ); } if ( $data['end_time'] != '' ) { Debug::Text( 'End Time: ' . $data['end_time'] . ' Date Stamp: ' . $date_stamp, __FILE__, __LINE__, __METHOD__, 10 ); $end_time = strtotime( $data['end_time'], $date_stamp ); Debug::Text( 'bEnd Time: ' . $data['end_time'] . ' - ' . TTDate::getDate( 'DATE+TIME', $data['end_time'] ), __FILE__, __LINE__, __METHOD__, 10 ); } $sf->setStartTime( $start_time ); $sf->setEndTime( $end_time ); if ( $sf->isValid() ) { $sf->setEnableReCalculateDay( true ); //This is needed to calculate accrual balances. $insert_id = $sf->Save(); Debug::Text( 'Schedule ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Schedule!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createMealPolicy( $company_id, $type ) { $mpf = new MealPolicyFactory(); $mpf->setCompany( $company_id ); switch ( $type ) { case 100: //Normal 1hr lunch $mpf->setName( 'Normal' ); $mpf->setType( 20 ); $mpf->setTriggerTime( ( 3600 * 6 ) ); $mpf->setAmount( 3600 ); $mpf->setIncludeLunchPunchTime( false ); $mpf->setPayCode( $this->policy_ids['pay_code'][190] ); break; case 110: //AutoAdd 1hr $mpf->setName( 'AutoAdd 1hr' ); $mpf->setType( 15 ); $mpf->setTriggerTime( ( 3600 * 6 ) ); $mpf->setAmount( 3600 ); $mpf->setIncludeLunchPunchTime( false ); $mpf->setPayCode( $this->policy_ids['pay_code'][190] ); break; case 115: //AutoAdd 1hr $mpf->setName( 'AutoAdd 1hr' ); $mpf->setType( 15 ); $mpf->setTriggerTime( ( 3600 * 6 ) ); $mpf->setAmount( 3600 ); $mpf->setIncludeLunchPunchTime( true ); $mpf->setPayCode( $this->policy_ids['pay_code'][190] ); break; case 120: //AutoDeduct 1hr $mpf->setName( 'AutoDeduct 1hr' ); $mpf->setType( 10 ); $mpf->setTriggerTime( ( 3600 * 6 ) ); $mpf->setAmount( 3600 ); $mpf->setIncludeLunchPunchTime( false ); $mpf->setPayCode( $this->policy_ids['pay_code'][190] ); break; case 130: //AutoDeduct 1hr at Active After Time $mpf->setName( 'AutoDeduct 1hr' ); $mpf->setType( 10 ); $mpf->setAllocationType( 100 ); //At Active After Time. $mpf->setTriggerTime( ( 3600 * 6 ) ); $mpf->setAmount( 3600 ); $mpf->setIncludeLunchPunchTime( false ); $mpf->setPayCode( $this->policy_ids['pay_code'][190] ); break; } if ( $mpf->isValid() ) { $insert_id = $mpf->Save(); Debug::Text( 'Meal Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Meal Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createBreakPolicy( $company_id, $type ) { $bpf = new BreakPolicyFactory(); $bpf->setCompany( $company_id ); switch ( $type ) { // case 100: //Normal 15min break // $bpf->setName( 'Normal' ); // $bpf->setType( 20 ); // $bpf->setTriggerTime( (3600 * 6) ); // $bpf->setAmount( 60 * 15 ); // $bpf->setIncludeBreakPunchTime( FALSE ); // $bpf->setIncludeMultipleBreaks( FALSE ); // $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); // break; // case 110: //AutoAdd 15min // $bpf->setName( 'AutoAdd 15min' ); // $bpf->setType( 15 ); // $bpf->setTriggerTime( (3600 * 1) ); // $bpf->setAmount( 60 * 15 ); // $bpf->setIncludeBreakPunchTime( FALSE ); // $bpf->setIncludeMultipleBreaks( FALSE ); // $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); // break; // case 115: //AutoAdd 15min // $bpf->setName( 'AutoAdd 15min (Include Punch Time)' ); // $bpf->setType( 15 ); // $bpf->setTriggerTime( (3600 * 1) ); // $bpf->setAmount( 60 * 15 ); // $bpf->setIncludeBreakPunchTime( TRUE ); // $bpf->setIncludeMultipleBreaks( FALSE ); // $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); // break; case 120: //AutoDeduct 15min $bpf->setName( 'AutoDeduct 15min' ); $bpf->setType( 10 ); $bpf->setTriggerTime( ( 3600 * 6 ) ); $bpf->setAmount( 15 * 60 ); $bpf->setIncludeBreakPunchTime( false ); $bpf->setIncludeMultipleBreaks( false ); $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); break; // case 121: //AutoDeduct 15min // $bpf->setName( 'AutoDeduct 15min (b)' ); // $bpf->setType( 10 ); // $bpf->setTriggerTime( (3600 * 6) ); // $bpf->setAmount( 15 * 60 ); // $bpf->setIncludeBreakPunchTime( FALSE ); // $bpf->setIncludeMultipleBreaks( FALSE ); // $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); // break; case 130: //AutoDeduct 30min $bpf->setName( 'AutoDeduct 30min' ); $bpf->setType( 10 ); $bpf->setTriggerTime( ( 3600 * 6 ) ); $bpf->setAmount( 30 * 60 ); $bpf->setIncludeBreakPunchTime( false ); $bpf->setIncludeMultipleBreaks( false ); $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); break; case 150: //AutoAdd 15min $bpf->setName( 'AutoAdd 15min (Include Both)' ); $bpf->setType( 15 ); $bpf->setTriggerTime( ( 3600 * 1 ) ); $bpf->setAmount( 60 * 15 ); $bpf->setIncludeBreakPunchTime( true ); $bpf->setIncludeMultipleBreaks( true ); $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); break; case 152: //AutoAdd 30min $bpf->setName( 'AutoAdd 15min (Include Both) [2]' ); $bpf->setType( 15 ); $bpf->setTriggerTime( ( 3600 * 3 ) ); $bpf->setAmount( 60 * 30 ); $bpf->setIncludeBreakPunchTime( true ); $bpf->setIncludeMultipleBreaks( true ); $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); break; // case 154: //AutoAdd 15min // $bpf->setName( 'AutoAdd 15min (Include Both) [3]' ); // $bpf->setType( 15 ); // $bpf->setTriggerTime( (3600 * 5) ); // $bpf->setAmount( 60 * 15 ); // $bpf->setIncludeBreakPunchTime( TRUE ); // $bpf->setIncludeMultipleBreaks( TRUE ); // $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); // break; // case 156: //AutoAdd 15min // $bpf->setName( 'AutoAdd 15min (Include Both) [4]' ); // $bpf->setType( 15 ); // $bpf->setTriggerTime( (3600 * 10) ); // $bpf->setAmount( 60 * 15 ); // $bpf->setIncludeBreakPunchTime( TRUE ); // $bpf->setIncludeMultipleBreaks( TRUE ); // $bpf->setPayCode( $this->policy_ids['pay_code'][192] ); // break; } if ( $bpf->isValid() ) { $insert_id = $bpf->Save(); Debug::Text( 'Break Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Break Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function getCurrentAccrualBalance( $user_id, $accrual_policy_account_id = null ) { if ( $user_id == '' ) { return false; } if ( $accrual_policy_account_id == '' ) { $accrual_policy_account_id = $this->getId(); } //Check min/max times of accrual policy. $ablf = TTnew( 'AccrualBalanceListFactory' ); /** @var AccrualBalanceListFactory $ablf */ $ablf->getByUserIdAndAccrualPolicyAccount( $user_id, $accrual_policy_account_id ); if ( $ablf->getRecordCount() > 0 ) { $accrual_balance = $ablf->getCurrent()->getBalance(); } else { $accrual_balance = 0; } Debug::Text( '   Current Accrual Balance: ' . $accrual_balance, __FILE__, __LINE__, __METHOD__, 10 ); return $accrual_balance; } function getUserDateTotalArray( $start_date, $end_date ) { $udtlf = new UserDateTotalListFactory(); $date_totals = []; //Get only system totals. $udtlf->getByCompanyIDAndUserIdAndObjectTypeAndStartDateAndEndDate( $this->company_id, $this->user_id, [ 5, 20, 25, 30, 40, 100, 110 ], $start_date, $end_date ); if ( $udtlf->getRecordCount() > 0 ) { foreach ( $udtlf as $udt_obj ) { Debug::Text( 'Date: ' . TTDate::getDate( 'DATE+TIME', $udt_obj->getDateStamp() ) . ' Total Records: ' . $udtlf->getRecordCount(), __FILE__, __LINE__, __METHOD__, 10 ); $date_totals[$udt_obj->getDateStamp()][] = [ //'date_stamp' => $udt_obj->getColumn('user_date_stamp'), 'date_stamp' => $udt_obj->getDateStamp(), 'id' => $udt_obj->getId(), //Keep legacy status_id/type_id for now, so we don't have to change as many unit tests. 'status_id' => $udt_obj->getStatus(), 'type_id' => $udt_obj->getType(), 'src_object_id' => $udt_obj->getSourceObject(), 'object_type_id' => $udt_obj->getObjectType(), 'pay_code_id' => $udt_obj->getPayCode(), 'branch_id' => TTUUID::castUUID( $udt_obj->getBranch() ), 'department_id' => $udt_obj->getDepartment(), 'punch_tag_id' => $udt_obj->getPunchTag(), 'total_time' => $udt_obj->getTotalTime(), 'name' => $udt_obj->getName(), 'start_time_stamp' => $udt_obj->getStartTimeStamp(), 'end_time_stamp' => $udt_obj->getEndTimeStamp(), //'start_time_stamp_display' => date('r', $udt_obj->getStartTimeStamp() ), //'end_time_stamp_display' => date('r', $udt_obj->getEndTimeStamp() ), 'quantity' => $udt_obj->getQuantity(), 'bad_quantity' => $udt_obj->getBadQuantity(), 'hourly_rate' => $udt_obj->getHourlyRate(), 'hourly_rate_with_burden' => $udt_obj->getHourlyRateWithBurden(), //Override only shows for SYSTEM override columns... //Need to check Worked overrides too. 'tmp_override' => $udt_obj->getOverride(), ]; } } return $date_totals; } function createPayCode( $company_id, $type, $pay_formula_policy_id = 0 ) { $pcf = TTnew( 'PayCodeFactory' ); /** @var PayCodeFactory $pcf */ $pcf->setCompany( $company_id ); switch ( $type ) { case 100: $pcf->setName( 'Daily (>8hrs)' ); //$pcf->setRate( '1.5' ); break; case 110: $pcf->setName( 'Daily (>9hrs)' ); //$pcf->setRate( '2.0' ); break; case 120: $pcf->setName( 'Daily (>10hrs)' ); //$pcf->setRate( '2.5' ); break; case 190: $pcf->setName( 'Lunch' ); //$pcf->setRate( '2.5' ); break; case 200: $pcf->setName( 'Weekly (>47hrs)' ); //$pcf->setRate( '1.5' ); break; case 210: $pcf->setName( 'Weekly (>59hrs)' ); //$pcf->setRate( '2.0' ); break; case 220: $pcf->setName( 'Weekly (>71hrs)' ); //$pcf->setRate( '2.5' ); break; case 230: $pcf->setName( 'Weekly (>31hrs)' ); //$pcf->setRate( '1.5' ); break; case 240: $pcf->setName( 'Weekly (>39hrs)' ); //$pcf->setRate( '2.0' ); break; case 250: $pcf->setName( 'Weekly (>47hrs)' ); //$pcf->setRate( '2.5' ); break; case 300: $pcf->setName( 'BiWeekly (>80hrs)' ); //$pcf->setRate( '1.5' ); break; case 310: $pcf->setName( 'BiWeekly (>84hrs)' ); //$pcf->setRate( '2.0' ); break; case 320: $pcf->setName( 'BiWeekly (>86hrs)' ); //$pcf->setRate( '2.5' ); break; case 350: $pcf->setName( 'Every 4 Weeks' ); //$pcf->setRate( '2.5' ); break; case 500: $pcf->setName( 'Holiday' ); //$pcf->setRate( '1.5' ); break; case 510: $pcf->setName( 'Holiday' ); //$pcf->setRate( '4.0' ); //This should have the highest rate as it always takes precedance. break; } $pcf->setCode( md5( $pcf->getName() ) ); $pcf->setType( 10 ); //Paid //$pcf->setAccrualPolicyID( $accrual_policy_id ); $pcf->setPayFormulaPolicy( $pay_formula_policy_id ); $pcf->setPayStubEntryAccountID( CompanyDeductionFactory::getPayStubEntryAccountByCompanyIDAndTypeAndFuzzyName( $company_id, 10, 'Over Time 1' ) ); //$pcf->setAccrualRate( 1.0 ); if ( $pcf->isValid() ) { $insert_id = $pcf->Save(); Debug::Text( 'Pay Code ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Pay Code!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createRegularTimePolicy( $company_id, $type, $contributing_shift_policy_id = 0, $pay_code_id = 0 ) { $rtpf = TTnew( 'RegularTimePolicyFactory' ); /** @var RegularTimePolicyFactory $rtpf */ $rtpf->setId( $rtpf->getNextInsertId() ); //Make sure we can define the differential criteria before calling isValid() $rtpf->setCompany( $company_id ); switch ( $type ) { case 10: $rtpf->setName( 'Regular Time' ); $rtpf->setContributingShiftPolicy( $contributing_shift_policy_id ); $rtpf->setPayCode( $pay_code_id ); $rtpf->setCalculationOrder( 9999 ); break; case 20: $rtpf->setName( 'Regular Time (2)' ); $rtpf->setContributingShiftPolicy( $contributing_shift_policy_id ); $rtpf->setPayCode( $pay_code_id ); $rtpf->setCalculationOrder( 9999 ); break; case 1010: $rtpf->setName( 'Regular Time (B1)' ); $rtpf->setContributingShiftPolicy( $contributing_shift_policy_id ); $rtpf->setPayCode( $pay_code_id ); $rtpf->setCalculationOrder( 1000 ); $rtpf->setBranchSelectionType( 20 ); $rtpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1020: $rtpf->setName( 'Regular Time (B2)' ); $rtpf->setContributingShiftPolicy( $contributing_shift_policy_id ); $rtpf->setPayCode( $pay_code_id ); $rtpf->setCalculationOrder( 1001 ); $rtpf->setBranchSelectionType( 20 ); $rtpf->setBranch( [ $this->branch_ids[1] ] ); break; } if ( $rtpf->isValid() ) { $insert_id = $rtpf->Save( true, true ); Debug::Text( 'Regular Time Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Regular Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function updatePayFormulaPolicy( $id, $accrual_policy_account_id = 0, $wage_source_contributing_shift_policy_id = 0, $time_source_contributing_shift_policy_id = 0 ) { $pfplf = TTnew( 'PayFormulaPolicyListFactory' ); /** @var PayFormulaPolicyListFactory $pfplf */ $pfplf->getById( $id ); if ( $pfplf->getRecordCount() == 1 ) { $pfpf = $pfplf->getCurrent(); $pfpf->setWageSourceContributingShiftPolicy( $wage_source_contributing_shift_policy_id ); $pfpf->setTimeSourceContributingShiftPolicy( $time_source_contributing_shift_policy_id ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); if ( $pfpf->isValid() ) { $pfpf->Save(); Debug::Text( 'Updating Pay Formula Policy! ID: ' . $id, __FILE__, __LINE__, __METHOD__, 10 ); return true; } } Debug::Text( 'Failed Updating Pay Formula Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createPayFormulaPolicy( $company_id, $type, $accrual_policy_account_id = 0, $wage_source_contributing_shift_policy_id = 0, $time_source_contributing_shift_policy_id = 0 ) { $pfpf = TTnew( 'PayFormulaPolicyFactory' ); /** @var PayFormulaPolicyFactory $pfpf */ $pfpf->setCompany( $company_id ); switch ( $type ) { case 10: $pfpf->setName( 'None ($0)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 0 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 0 ); $pfpf->setAccrualBalanceThreshold( 0 ); //Don't use default lower threshold of 0. break; case 100: $pfpf->setName( 'Regular' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 1.0 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 200: $pfpf->setName( 'OverTime (1.5x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 1.5 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 210: $pfpf->setName( 'OverTime (2.0x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 2.0 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 220: $pfpf->setName( 'OverTime (2.5x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 2.5 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 510: $pfpf->setName( 'OverTime (4.0x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 4.0 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 910: $pfpf->setName( 'Bank' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 1.0 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( -1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * -999) ); //Don't use default lower threshold of 0. break; case 1101: $pfpf->setName( 'Regular (Alt Wage #1)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 1.0 ); $pfpf->setWageGroup( $this->user_wage_groups[0] ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 1102: $pfpf->setName( 'Regular (Alt Wage #2)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setRate( 1.0 ); $pfpf->setWageGroup( $this->user_wage_groups[1] ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 1200: //Overtime averaging. $pfpf->setName( 'OverTime Avg (1.5x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setWageSourceType( 30 ); //Average of contributing pay codes. $pfpf->setWageSourceContributingShiftPolicy( $wage_source_contributing_shift_policy_id ); $pfpf->setTimeSourceContributingShiftPolicy( $time_source_contributing_shift_policy_id ); $pfpf->setRate( 1.5 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 1210: //Overtime averaging. $pfpf->setName( 'OverTime Avg (2.0x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setWageSourceType( 30 ); //Average of contributing pay codes. $pfpf->setWageSourceContributingShiftPolicy( $wage_source_contributing_shift_policy_id ); $pfpf->setTimeSourceContributingShiftPolicy( $time_source_contributing_shift_policy_id ); $pfpf->setRate( 2.0 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 1220: //Overtime averaging. $pfpf->setName( 'OverTime Avg (2.5x)' ); $pfpf->setPayType( 10 ); //Pay Multiplied By Factor $pfpf->setWageSourceType( 30 ); //Average of contributing pay codes. $pfpf->setWageSourceContributingShiftPolicy( $wage_source_contributing_shift_policy_id ); $pfpf->setTimeSourceContributingShiftPolicy( $time_source_contributing_shift_policy_id ); $pfpf->setRate( 2.5 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; case 1300: //Daily Average Rate $pfpf->setName( 'Daily Avg' ); $pfpf->setPayType( 70 ); //Daily Average $pfpf->setWageSourceContributingShiftPolicy( $wage_source_contributing_shift_policy_id ); $pfpf->setTimeSourceContributingShiftPolicy( $time_source_contributing_shift_policy_id ); //$pfpf->setRate( 0 ); $pfpf->setAverageDays( 5 ); $pfpf->setAccrualPolicyAccount( $accrual_policy_account_id ); $pfpf->setAccrualRate( 1.0 ); $pfpf->setAccrualBalanceThreshold( (86400 * 999) ); //Don't use default lower threshold of 0. break; } if ( $pfpf->isValid() ) { $insert_id = $pfpf->Save(); Debug::Text( 'Pay Formula Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Pay Formula Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createOverTimePolicy( $company_id, $type, $contributing_shift_policy_id = 0, $pay_code_id = 0, $trigger_time_adjust_contributing_shift_policy_id = 0 ) { $otpf = new OverTimePolicyFactory(); $otpf->setId( $otpf->getNextInsertId() ); //Make sure we can define the differential criteria before calling isValid() $otpf->setCompany( $company_id ); switch ( $type ) { // //Changing the OT rates will make a big difference is how these tests are calculated. // case 10: $otpf->setName( 'Daily (>0hrs)' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 0 ) ); break; case 90: $otpf->setName( 'Daily (>7hrs)' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 7 ) ); break; case 100: $otpf->setName( 'Daily (>8hrs)' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 8 ) ); break; case 110: $otpf->setName( 'Daily (>9hrs)' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 9 ) ); break; case 120: $otpf->setName( 'Daily (>10hrs)' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 10 ) ); break; case 200: $otpf->setName( 'Weekly (>47hrs)' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 47 ) ); break; case 210: $otpf->setName( 'Weekly (>59hrs)' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 59 ) ); break; case 220: $otpf->setName( 'Weekly (>71hrs)' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 71 ) ); break; case 230: $otpf->setName( 'Weekly (>31hrs)' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 31 ) ); break; case 240: $otpf->setName( 'Weekly (>39hrs)' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 39 ) ); break; case 242: $otpf->setName( 'Weekly (>40hrs) [B]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 40 ) ); break; case 250: $otpf->setName( 'Weekly (>47hrs) [B]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 47 ) ); break; case 300: $otpf->setName( 'BiWeekly (>80hrs)' ); $otpf->setType( 30 ); $otpf->setTriggerTime( ( 3600 * 80 ) ); break; case 310: $otpf->setName( 'BiWeekly (>84hrs)' ); $otpf->setType( 30 ); $otpf->setTriggerTime( ( 3600 * 84 ) ); break; case 320: $otpf->setName( 'BiWeekly (>86hrs)' ); $otpf->setType( 30 ); $otpf->setTriggerTime( ( 3600 * 86 ) ); break; case 500: $otpf->setName( 'Holiday' ); $otpf->setType( 180 ); $otpf->setTriggerTime( 0 ); break; case 510: $otpf->setName( 'Holiday' ); $otpf->setType( 180 ); $otpf->setTriggerTime( 0 ); //$otpf->setPayCode( $pay_code_id ); //Rate should be 4.0... This should have the highest rate as it always takes precedance. break; case 1000: //Differential $otpf->setName( 'Daily (>8hrs) [B1]' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 8 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1001: //Differential $otpf->setName( 'Daily (>8hrs) [B2]' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 8 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[1] ] ); break; case 1230: //Differential $otpf->setName( 'Weekly (>31hrs) [B1]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 31 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[1] ] ); break; case 1231: //Differential $otpf->setName( 'Weekly (>31hrs) [B2]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 31 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1240: //Differential $otpf->setName( 'Weekly (>39hrs) [B1]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 39 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[1] ] ); break; case 1241: //Differential $otpf->setName( 'Weekly (>39hrs) [B2]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 39 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1250: //Differential $otpf->setName( 'Weekly (>40hrs) [B1]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 40 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1251: //Differential $otpf->setName( 'Weekly (>40hrs) [B2]' ); $otpf->setType( 20 ); $otpf->setTriggerTime( ( 3600 * 40 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[1] ] ); break; case 1300: //Differential $otpf->setName( 'BiWeekly (>80hrs) [B2]' ); $otpf->setType( 30 ); $otpf->setTriggerTime( ( 3600 * 80 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1310: //Differential $otpf->setName( 'BiWeekly (>84hrs) [B2]' ); $otpf->setType( 30 ); $otpf->setTriggerTime( ( 3600 * 84 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1320: //Differential $otpf->setName( 'BiWeekly (>86hrs) [B2]' ); $otpf->setType( 30 ); $otpf->setTriggerTime( ( 3600 * 86 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 1900: //Differential - Used to test mid-shift differential at a higher rate (ie: 2.0x) that just applies to an hour or so. The lower rate should then apply thereafter still. $otpf->setName( 'OT Differential [B1]' ); $otpf->setType( 10 ); $otpf->setTriggerTime( ( 3600 * 0 ) ); $otpf->setBranchSelectionType( 20 ); $otpf->setBranch( [ $this->branch_ids[0] ] ); break; case 2150: $otpf->setName( '2 Or More Days/Week Consecutively Worked' ); $otpf->setType( 150 ); $otpf->setTriggerTime( 0 ); break; case 2155: $otpf->setName( '7 Or More Days/Week Consecutively Worked' ); $otpf->setType( 155 ); $otpf->setTriggerTime( 0 ); break; case 2300: $otpf->setName( '2 Or More Days Consecutively Worked' ); $otpf->setType( 300 ); $otpf->setTriggerTime( 0 ); break; case 2305: $otpf->setName( '7 Or More Days Consecutively Worked' ); $otpf->setType( 305 ); $otpf->setTriggerTime( 0 ); break; case 2400: $otpf->setName( '2 Or More Days/Week Worked' ); $otpf->setType( 400 ); $otpf->setTriggerTime( 0 ); break; case 2404: $otpf->setName( '6 Or More Days/Week Worked' ); //7 or more doesn't really make much sense, since they are all consecutive anwyays. $otpf->setType( 404 ); $otpf->setTriggerTime( 0 ); break; case 5504: $otpf->setName( 'Every 4 Weeks' ); $otpf->setType( 504 ); $otpf->setTriggerTime( ( 234 * 3600 ) ); //5days/week at 12hr days. break; } $otpf->setPayCode( $pay_code_id ); $otpf->setContributingShiftPolicy( $contributing_shift_policy_id ); $otpf->setTriggerTimeAdjustContributingShiftPolicy( $trigger_time_adjust_contributing_shift_policy_id ); if ( $otpf->isValid() ) { $insert_id = $otpf->Save( true, true ); Debug::Text( 'Overtime Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Overtime Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createHolidayPolicy( $company_id, $type ) { $hpf = new HolidayPolicyFactory(); $hpf->setCompany( $company_id ); switch ( $type ) { case 10: $hpf->setName( 'Default' ); $hpf->setType( 10 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 10 ); $hpf->setAverageTimeWorkedDays( true ); $hpf->setIncludeOverTime( true ); $hpf->setIncludePaidAbsenceTime( true ); $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( 0 ); $hpf->setMaximumTime( 0 ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); //$hpf->setRoundIntervalPolicyID( $data['round_interval_policy_id'] ); break; case 20: $hpf->setName( 'Standard (8Hrs)' ); $hpf->setType( 10 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 10 ); $hpf->setAverageTimeWorkedDays( true ); $hpf->setIncludeOverTime( true ); $hpf->setIncludePaidAbsenceTime( true ); $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); //$hpf->setRoundIntervalPolicyID( $data['round_interval_policy_id'] ); break; case 100: $hpf->setName( 'Calendar Day Before/After' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 1 ); //Before $hpf->setMinimumWorkedPeriodDays( 1 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 1 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 1 ); //After $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 200: $hpf->setName( 'Scheduled Day Before/After' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 1 ); //1=Scheduled Day $hpf->setMinimumWorkedDays( 1 ); //Before $hpf->setMinimumWorkedPeriodDays( 1 ); //Before $hpf->setWorkedAfterScheduledDays( 1 ); //1=Scheduled Day $hpf->setMinimumWorkedAfterDays( 1 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 1 ); //After $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 300: $hpf->setName( 'Holiday Weekday Day Before/After' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 2 ); //2=Holiday Weekday $hpf->setMinimumWorkedDays( 1 ); //Before $hpf->setMinimumWorkedPeriodDays( 1 ); //Before $hpf->setWorkedAfterScheduledDays( 2 ); //2=Holiday Weekday $hpf->setMinimumWorkedAfterDays( 1 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 1 ); //After $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 400: $hpf->setName( 'Must Work On Holiday' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 0 ); //Before $hpf->setMinimumWorkedPeriodDays( 0 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 0 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 0 ); //After $hpf->setShiftOnHolidayType( 10 ); //10=Must Always Work $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 420: $hpf->setName( 'Must Never Work' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 0 ); //Before $hpf->setMinimumWorkedPeriodDays( 0 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 0 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 0 ); //After $hpf->setShiftOnHolidayType( 20 ); //30=Must Never Work $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 430: $hpf->setName( 'Must Work Only If Schedule' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 0 ); //Before $hpf->setMinimumWorkedPeriodDays( 0 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 0 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 0 ); //After $hpf->setShiftOnHolidayType( 30 ); //30=Must Work Only If Scheduled $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 440: $hpf->setName( 'Must Not Work Only If Scheduled Absent' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 0 ); //Before $hpf->setMinimumWorkedPeriodDays( 0 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 0 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 0 ); //After $hpf->setShiftOnHolidayType( 40 ); //40=Must Not Work (Only if Scheduled Absent) $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 472: $hpf->setName( 'Must Not Work (Must be Scheduled Absent)' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 0 ); //Before $hpf->setMinimumWorkedPeriodDays( 0 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 0 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 0 ); //After $hpf->setShiftOnHolidayType( 72 ); //72=Must Not Work (Must be Scheduled Absent) $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; case 475: $hpf->setName( 'Must Not Work (Must not be Scheduled)' ); $hpf->setType( 20 ); $hpf->setDefaultScheduleStatus( 10 ); $hpf->setMinimumEmployedDays( 0 ); $hpf->setMinimumWorkedPeriodDays( 0 ); $hpf->setMinimumWorkedDays( 0 ); $hpf->setAverageTimeDays( 0 ); $hpf->setAverageTimeWorkedDays( false ); $hpf->setWorkedScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedDays( 0 ); //Before $hpf->setMinimumWorkedPeriodDays( 0 ); //Before $hpf->setWorkedAfterScheduledDays( 0 ); //0=Calendar Day $hpf->setMinimumWorkedAfterDays( 0 ); //After $hpf->setMinimumWorkedAfterPeriodDays( 0 ); //After $hpf->setShiftOnHolidayType( 75 ); //75=Must Not Work (Must not be Scheduled) $hpf->setForceOverTimePolicy( true ); $hpf->setMinimumTime( ( 3600 * 8 ) ); $hpf->setMaximumTime( ( 3600 * 8 ) ); $hpf->setAbsencePolicyID( $this->policy_ids['absence'][10] ); $hpf->setEligibleContributingShiftPolicy( $this->policy_ids['contributing_shift_policy'][10] ); break; } $hpf->setHolidayDisplayDays( 371 ); if ( $hpf->isValid() ) { $insert_id = $hpf->Save(); Debug::Text( 'Holiday Policy ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Holiday Policy!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } function createHoliday( $company_id, $type, $date, $holiday_policy_id ) { $hf = new HolidayFactory(); switch ( $type ) { case 10: $hf->setHolidayPolicyId( $holiday_policy_id ); $hf->setDateStamp( $date ); $hf->setName( 'Test1' ); break; case 20: $hf->setHolidayPolicyId( $holiday_policy_id ); $hf->setDateStamp( $date ); $hf->setName( 'Test2' ); break; } if ( $hf->isValid() ) { $insert_id = $hf->Save(); Debug::Text( 'Holiday ID: ' . $insert_id, __FILE__, __LINE__, __METHOD__, 10 ); return $insert_id; } Debug::Text( 'Failed Creating Holiday!', __FILE__, __LINE__, __METHOD__, 10 ); return false; } /* Tests: No Overtime Daily OverTime (3 levels) Weekly OverTime (3 Levels) BiWeekly OverTime (3 Levels) Combination Daily+Weekly (3 Levels) Combination Daily+Weekly+Holiday (3 Levels) */ /** * @group OvertimePolicy_testNoOverTimePolicyA */ function testNoOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 3:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 7 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); $this->assertEquals( 21.50, $udt_arr[$date_epoch][1]['hourly_rate'] ); $this->assertEquals( 24.4025, $udt_arr[$date_epoch][1]['hourly_rate_with_burden'] ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimePolicyA */ function testDailyOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][4]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 1.5 * 21.50 * 1.135 ) ) ); //13.5% //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.0 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate_with_burden'], ( 2.0 * 21.50 * 1.135 ) ); //13.5% //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 2.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 2.5 * 21.50 * 1.135 ) ) ); //13.5% //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimePolicyB */ function testDailyOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:30PM' ), strtotime( $date_stamp . ' 5:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:30PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 4:30PM' ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 4:30PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimePolicyC */ function testDailyOverTimePolicyC() { global $dd; //Test multiple breaks and a lunch that are fairly close to one another. //This should cause UDT records to have to adjust their end_time_stamp in reverse to test a specific bug. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); //Don't include Meal/Break as thats already in Regular Time. //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['break'][] = $this->createBreakPolicy( $this->company_id, 152 ); //AutoAdd 30min //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users $policy_ids['break'], //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 10:15AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 30, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:30PM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 20, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 2:15PM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 30, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 299, $udt_arr[$date_epoch][1]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 1:57:33PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 2:02:32PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 349, $udt_arr[$date_epoch][2]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 2:02:32PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 2:08:21PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 399, $udt_arr[$date_epoch][3]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 2:08:21PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 2:15:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][4]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 753, $udt_arr[$date_epoch][4]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 1:45:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 1:57:33PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 1800, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 1:45:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 2:15:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 5400, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:30:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 2:00:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 6300, $udt_arr[$date_epoch][3]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 10:15:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 12:00:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][4]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 7200, $udt_arr[$date_epoch][4]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 8:00:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 10:00:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 8100, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][5]['start_time_stamp'], strtotime( $date_stamp . ' 2:15:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['end_time_stamp'], strtotime( $date_stamp . ' 4:30:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][6]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $policy_ids['pay_code'][0] ); //Overtime $this->assertEquals( 5400, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][6]['start_time_stamp'], strtotime( $date_stamp . ' 4:30:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][6]['end_time_stamp'], strtotime( $date_stamp . ' 6:00:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][6]['hourly_rate'], ( 1.5 * 21.50 ) ); $this->assertEquals( 36.6038, $udt_arr[$date_epoch][6]['hourly_rate_with_burden'] ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][10]['object_type_id'] ); //Break Time //$this->assertEquals( $udt_arr[$date_epoch][10]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 299, $udt_arr[$date_epoch][10]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][10]['start_time_stamp'], strtotime( $date_stamp . ' 1:57:33PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][10]['end_time_stamp'], strtotime( $date_stamp . ' 2:02:32PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][10]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][10]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][11]['object_type_id'] ); //Break Time //$this->assertEquals( $udt_arr[$date_epoch][11]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 349, $udt_arr[$date_epoch][11]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][11]['start_time_stamp'], strtotime( $date_stamp . ' 2:02:32PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][11]['end_time_stamp'], strtotime( $date_stamp . ' 2:08:21PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][11]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][11]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][12]['object_type_id'] ); //Break Time //$this->assertEquals( $udt_arr[$date_epoch][12]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 399, $udt_arr[$date_epoch][12]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][12]['start_time_stamp'], strtotime( $date_stamp . ' 2:08:21PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][12]['end_time_stamp'], strtotime( $date_stamp . ' 2:15:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][12]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][12]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][13]['object_type_id'] ); //Break Time //$this->assertEquals( $udt_arr[$date_epoch][13]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 753, $udt_arr[$date_epoch][13]['total_time'] ); //$this->assertEquals( $udt_arr[$date_epoch][13]['start_time_stamp'], strtotime( $date_stamp . ' 1:45:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][13]['end_time_stamp'], strtotime( $date_stamp . ' 1:57:33PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][13]['hourly_rate'], ( 1 * 21.50 ) ); //$this->assertEquals( $udt_arr[$date_epoch][13]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time $this->assertEquals( 110, $udt_arr[$date_epoch][7]['object_type_id'] ); //Break Time $this->assertEquals( $udt_arr[$date_epoch][7]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time $this->assertEquals( 1800, $udt_arr[$date_epoch][7]['total_time'] ); $this->assertEquals( $udt_arr[$date_epoch][7]['start_time_stamp'], strtotime( $date_stamp . ' 1:45:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][7]['end_time_stamp'], strtotime( $date_stamp . ' 2:15:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][7]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][7]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Make sure no other hours $this->assertCount( 8, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimePolicyD1 */ function testDailyOverTimePolicyD1() { global $dd; //Test a single overtime policy active after 0hrs in the day, and a pay rate of $0/hr. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 10 ); //$0/hr $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 0 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 0 * 21.50 * 1.135 ) ) ); //13.5% //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimePolicyD2 */ function testDailyOverTimePolicyD2() { global $dd; //Test a single overtime policy active after 0hrs in the day, and a pay rate of 1.5x $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //1.5x $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 1.5 * 21.50 * 1.135 ) ) ); //13.5% //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimePolicyA */ function testWeeklyOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDuplicateWeeklyOverTimePolicyA */ function testDuplicateWeeklyOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); //Duplicate Weekly OT policies, they should BOTH be attempted to calculate due to differential criteria. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 250, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 7 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithTimeBank */ function testDailyOverTimeWithTimeBank() { //Test handling daily OT with absences and the Start/End timestamps for each UDT record. global $dd; //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 910 ); //OT1.5 BANK //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $this->policy_ids['pay_formula_policy'][910] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 5:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 5:00PM' ), strtotime( $date_stamp . ' 6:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -2.5 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 6:30PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); ////Overtime 1(a) -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1.0 * 21.50 ) ); ////Overtime 1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1.5 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 6:30PM' ) ); //$this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 1.0 * 21.50 ) ); //Overtime 1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 6:30PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1.0 * 21.50 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -2.5 * 3600 ) ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyA */ function testDailyOverTimeWithAbsencePolicyA() { //Test handling daily OT with absences and the Start/End timestamps for each UDT record. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 4 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -4 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 4:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 4:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['start_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['end_time_stamp'], strtotime( $date_stamp . ' 1:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['hourly_rate'], ( 1.5 * 21.50 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 1:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 2:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 2.0 * 21.50 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 6 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 2:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.5 * 21.50 ) ); //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -4 * 3600 ) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyA2 */ function testDailyOverTimeWithAbsencePolicyA2() { //Test handling daily OT with absences from a schedule where the punches and absence times overlap. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $schedule_id = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '2:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 2:00AM' ) ); //Since absence and punches overlap, the absence time gets moved to before the punches. $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 2:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 6 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 2:00AM' ) ); //Since absence and punches overlap, the absence time gets moved to before the punches. $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 2:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 1.5 * 21.50 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyB */ function testDailyOverTimeWithAbsencePolicyB() { //Test handling OT that goes to a Time Bank along with Absences. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$this->policy_ids['pay_code'][900] //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $this->policy_ids['pay_formula_policy'][910] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -1 * 3600 ) ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 4 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -5 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 4:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 4:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['start_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['end_time_stamp'], strtotime( $date_stamp . ' 1:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['hourly_rate'], ( 1.0 * 21.50 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 1:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 2:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 2.0 * 21.50 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 6 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 2:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.5 * 21.50 ) ); //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -5 * 3600 ) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -1 * 3600 ) ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyC */ function testDailyOverTimeWithAbsencePolicyC() { //Test handling daily OT with absences and the Start/End timestamps for each UDT record. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime($date_stamp.' 8:00AM') ); //$this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime($date_stamp.' 8:00PM') ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1.5 * 21.50 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.0 * 21.50 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 2.5 * 21.50 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyC2 */ function testDailyOverTimeWithAbsencePolicyC2() { //Test handling daily OT with absences and the Start/End timestamps for each UDT record. // **This is special in that the OT policies DEPOSIT to accrual accounts as well to minic // the case where 12hr vacation is used, which triggers OT policy that is banked rather than paid. // Essenially in this case the Vacation time is withdrawn part of it (regular time) is paid, and the rest is deposited (transferred) into the OT bank global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200, $this->policy_ids['accrual_policy_account'][30] ); //OT1.5 -- Deposit to Accrual $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210, $this->policy_ids['accrual_policy_account'][30] ); //OT2.0 -- Deposit to Accrual $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220, $this->policy_ids['accrual_policy_account'][30] ); //OT2.5 -- Deposit to Accrual $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][30] ), ( 0 * 3600 ) ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][30] ), ( 4 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime($date_stamp.' 8:00AM') ); //$this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime($date_stamp.' 8:00PM') ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1.5 * 21.50 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.0 * 21.50 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 2.5 * 21.50 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][30] ), ( 4 * 3600 ) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][30] ), ( 0 * 3600 ) ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyD */ function testDailyOverTimeWithAbsencePolicyD() { //Test handling daily OT with absences and the Start/End timestamps for each UDT record. //Only have the absence record entered directly on the timesheet, so there are no start/end timestamps though. //and make sure the Absence policy uses Regular Time pay code so its included in OT. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); $policy_ids['absence'][] = $dd->createAbsencePolicy( $this->company_id, 30, $this->policy_ids['pay_code'][100] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense $policy_ids['absence'], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 7 * 3600 ), $policy_ids['absence'][0] ); //$this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), (-12 * 3600) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 7 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime($date_stamp.' 8:00AM') ); //$this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime($date_stamp.' 8:00PM') ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Absence Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 7:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); //$this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), (-12 * 3600) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); return true; } /** * @group OvertimePolicy_testDailyOverTimeWithAbsencePolicyE */ function testDailyOverTimeWithAbsencePolicyE() { //Test handling daily OT with absences and the Start/End timestamps for each UDT record. //Only have the absence record entered directly on the timesheet, so there are no start/end timestamps though. //and make sure the Absence policy uses Regular Time pay code so its included in OT. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); $policy_ids['absence'][] = $dd->createAbsencePolicy( $this->company_id, 30, $this->policy_ids['pay_code'][100] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense $policy_ids['absence'], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $policy_ids['absence'][0] ); //$this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), (-12 * 3600) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime($date_stamp.' 8:00AM') ); //$this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime($date_stamp.' 8:00PM') ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Absence Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1.5 * 21.50 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.0 * 21.50 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 2.5 * 21.50 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); //$this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), (-12 * 3600) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); return true; } /** * @group OvertimePolicy_testNoOverTimePolicyWithAbsence */ function testNoOverTimePolicyWithAbsence() { //This is mainly to test for a bug that occurs when no UDT records are returned to calculateOverTimePolicy global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $dd->createAbsence( $this->user_id, $date_epoch, ( 4 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -4 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //PTO/Vacation $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( 21.50, $udt_arr[$date_epoch][1]['hourly_rate'] ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimeWithAbsencePolicyA */ function testWeeklyOverTimeWithAbsencePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimeWithAbsencePolicyB */ function testWeeklyOverTimeWithAbsencePolicyB() { //Test with absence at the beginning of the week. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); // //Day of Week: 1 (Absence to be included in Weekly OT) // $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimeWithAbsencePolicyC */ function testWeeklyOverTimeWithAbsencePolicyC() { //Test with absence at the end of the week, where it switched into OT. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); // //Day of Week: 1 // $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -24 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -36 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -36 * 3600 ) ); //Delete absence in the middle of the week and confirm balance is still correct. $dd->deleteAbsence( $absence_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -24 * 3600 ) ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimeWithAbsencePolicyD */ function testWeeklyOverTimeWithAbsencePolicyD() { //Test with schedule absence and auto-deduct lunch at the end of the week, where it switched into OT. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); // //Day of Week: 1 // $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); //$dd->createAbsence( $this->user_id, $date_epoch, (12 * 3600), $this->policy_ids['absence'][10] ); $schedule_id = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '9:00PM', ] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); //$dd->createAbsence( $this->user_id, $date_epoch, (12 * 3600), $this->policy_ids['absence'][10] ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '9:00PM', ] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -24 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '9:00PM', ] ); //$dd->createAbsence( $this->user_id, $date_epoch, (12 * 3600), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -36 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Over Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -36 * 3600 ) ); //Delete scheduled absence in the middle of the week and confirm balance is still correct. $dd->deleteSchedule( $schedule_id ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -24 * 3600 ) ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimeWithAdjustTriggerAndAbsencePolicyA */ function testWeeklyOverTimeWithAdjustTriggerAndAbsencePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0], $this->policy_ids['contributing_shift_policy'][90] ); //Include adjusting contrib policy using just absences. //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1], $this->policy_ids['contributing_shift_policy'][90] ); //Include adjusting contrib policy using just absences. //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2], $this->policy_ids['contributing_shift_policy'][90] ); //Include adjusting contrib policy using just absences. //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime 2 $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); return true; } /** * @group OvertimePolicy_testWeeklyOverTimeWithAdjustTriggerAndAbsencePolicyB */ function testWeeklyOverTimeWithAdjustTriggerAndAbsencePolicyB() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][0], $this->policy_ids['contributing_shift_policy'][90] ); //Include adjusting contrib policy using just absences. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][1], $this->policy_ids['contributing_shift_policy'][90] ); //Include adjusting contrib policy using just absences. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][14], $policy_ids['pay_code'][2], $this->policy_ids['contributing_shift_policy'][90] ); //Include adjusting contrib policy using just absences. //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 (Absence to be included in Weekly OT) // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( 0 * 3600 ) ); $dd->createAbsence( $this->user_id, $date_epoch, ( 12 * 3600 ), $this->policy_ids['absence'][10] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); $this->assertEquals( $this->getCurrentAccrualBalance( $this->user_id, $this->policy_ids['accrual_policy_account'][10] ), ( -12 * 3600 ) ); return true; } /** * @group OvertimePolicy_testBiWeeklyOverTimeDates */ function testBiWeeklyOverTimeDates() { $cp = TTnew( 'CalculatePolicy' ); /** @var CalculatePolicy $cp */ $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '22-Dec-2013' ), strtotime( '22-Dec-2013' ), 0 ) ); //Sun $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '29-Dec-2013' ), strtotime( '22-Dec-2013' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '29-Dec-2013' ), strtotime( '29-Dec-2013' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '30-Dec-2013' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '31-Dec-2013' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '01-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '02-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '03-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '04-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '05-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '06-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '07-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '08-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '09-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '10-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '11-Jan-2014' ), strtotime( '29-Dec-2013' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '29-Dec-2013' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '30-Dec-2013' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '31-Dec-2013' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '01-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '02-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '03-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '04-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '05-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '06-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '07-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '08-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '09-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '10-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '11-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //These were originally incorrect by the looks of it, and once we added daydiff rounding it fixed them. //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-May-2016'), strtotime('28-Dec-2013'), 0 ), FALSE ); //Sat //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-May-2016'), strtotime('29-Dec-2013'), 0 ), TRUE ); //Sun //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-May-2016'), strtotime('01-Jan-2014'), 0 ), TRUE ); //Wed $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '01-May-2016' ), strtotime( '28-Dec-2013' ), 0 ) ); //Sat $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '01-May-2016' ), strtotime( '29-Dec-2013' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '01-May-2016' ), strtotime( '01-Jan-2014' ), 0 ) ); //Wed //Test 53 week year. $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '29-Dec-2014' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun: Week 1 $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '05-Jan-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '12-Jan-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '26-Jan-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '09-Feb-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '23-Feb-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '09-Mar-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '23-Mar-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '14-Dec-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun: Week 51 $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '21-Dec-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun: Week 52 $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '28-Dec-2015' ), strtotime( '29-Dec-2014' ), 0 ) ); //Sun: Week 53 $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '01-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '06-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $this->assertEquals( false, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '12-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '20-Jan-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '03-Feb-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $this->assertEquals( true, $cp->isSecondBiWeeklyOverTimeWeek( strtotime( '17-Feb-2014' ), strtotime( '01-Jan-2014' ), 0 ) ); //Sun $retval = false; $anchor_date = TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2014' ) ); $x = 0; for ( $i = $anchor_date; $i <= TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2015' ) ); $i += ( 86400 * 7 ) ) { $x++; //Run at beginning so the counter essentially starts at 1. $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( $i, $anchor_date, 0 ), $retval ); $retval = !$retval; //Swap } $this->assertEquals( 53, $x ); $retval = false; $anchor_date = TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2014' ) ); $x = 0; for ( $i = $anchor_date; $i <= TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2025' ) ); $i += ( 86400 * 7 ) ) { $x++; //Run at beginning so the counter essentially starts at 1. $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( $i, $anchor_date, 0 ), $retval ); $retval = !$retval; //Swap } $this->assertEquals( 575, $x ); } /** * @group OvertimePolicy_testBiWeeklyOverTimePeriodDates */ function testBiWeeklyOverTimePeriodDates() { $cp = TTnew( 'CalculatePolicy' ); /** @var CalculatePolicy $cp */ $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '22-Dec-2013' ), 2, strtotime( '22-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '22-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '04-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('29-Dec-2013'), strtotime('22-Dec-2013'), 0 ), TRUE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '29-Dec-2013' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('29-Dec-2013'), strtotime('29-Dec-2013'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '30-Dec-2013' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('30-Dec-2013'), strtotime('29-Dec-2013'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '31-Dec-2013' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('31-Dec-2013'), strtotime('29-Dec-2013'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '01-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-Jan-2014'), strtotime('29-Dec-2013'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '02-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('02-Jan-2014'), strtotime('29-Dec-2013'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '03-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('03-Jan-2014'), strtotime('29-Dec-2013'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '04-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('04-Jan-2014'), strtotime('29-Dec-2013'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '05-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('05-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '06-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('06-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '07-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('07-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '08-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('08-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '09-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('09-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '10-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('10-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '11-Jan-2014' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('11-Jan-2014'), strtotime('29-Dec-2013'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '29-Dec-2013' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('29-Dec-2013'), strtotime('01-Jan-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '30-Dec-2013' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('30-Dec-2013'), strtotime('01-Jan-2014'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '31-Dec-2013' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('31-Dec-2013'), strtotime('01-Jan-2014'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '01-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-Jan-2014'), strtotime('01-Jan-2014'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '02-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('02-Jan-2014'), strtotime('01-Jan-2014'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '03-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('03-Jan-2014'), strtotime('01-Jan-2014'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '04-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('04-Jan-2014'), strtotime('01-Jan-2014'), 0 ), FALSE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '05-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('05-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '06-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('06-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '07-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('07-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '08-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('08-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '09-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('09-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '10-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('10-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '11-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); //Mon $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('11-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '01-May-2016' ), 2, strtotime( '28-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '24-Apr-2016' ) ) ); //Sat $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '07-May-2016' ) ) ); //Fri $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-May-2016'), strtotime('28-Dec-2013'), 0 ), TRUE ); //Sat $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '01-May-2016' ), 2, strtotime( '29-Dec-2013' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '01-May-2016' ) ) ); //Sun $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '14-May-2016' ) ) ); //Sat $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-May-2016'), strtotime('29-Dec-2013'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '01-May-2016' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '01-May-2016' ) ) ); //Wed $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '14-May-2016' ) ) ); //Tue $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-May-2016'), strtotime('01-Jan-2014'), 0 ), FALSE ); //Wed // //Test 53 week year. $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '29-Dec-2014' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '28-Dec-14' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '10-Jan-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('29-Dec-2014'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun: Week 1 $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '05-Jan-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '28-Dec-14' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '10-Jan-15' ) ) ); $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('05-Jan-2015'), strtotime('29-Dec-2014'), 0 ), TRUE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '12-Jan-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '11-Jan-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '24-Jan-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('12-Jan-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '26-Jan-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '25-Jan-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '07-Feb-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('26-Jan-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '09-Feb-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '08-Feb-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '21-Feb-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('09-Feb-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '23-Feb-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '22-Feb-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '07-Mar-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('23-Feb-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '09-Mar-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '08-Mar-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '21-Mar-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('09-Mar-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '23-Mar-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '22-Mar-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '04-Apr-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('23-Mar-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '14-Dec-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '13-Dec-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '26-Dec-15' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('14-Dec-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun: Week 51 $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '21-Dec-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '13-Dec-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '26-Dec-15' ) ) ); $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('21-Dec-2015'), strtotime('29-Dec-2014'), 0 ), TRUE ); //Sun: Week 52 $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '28-Dec-2015' ), 2, strtotime( '29-Dec-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '27-Dec-15' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '09-Jan-16' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('28-Dec-2015'), strtotime('29-Dec-2014'), 0 ), FALSE ); //Sun: Week 53 $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '01-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('01-Jan-2014'), strtotime('01-Jan-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '06-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '29-Dec-2013' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '11-Jan-2014' ) ) ); $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('06-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '12-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '12-Jan-2014' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '25-Jan-2014' ) ) ); $this->assertEquals( true, $ot_period_dates['is_first_week'] ); $this->assertEquals( false, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('12-Jan-2014'), strtotime('01-Jan-2014'), 0 ), FALSE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '20-Jan-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '12-Jan-2014' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '25-Jan-2014' ) ) ); $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('20-Jan-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '03-Feb-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '26-Jan-2014' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '08-Feb-2014' ) ) ); $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('03-Feb-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); //Sun $ot_period_dates = $cp->getOverTimePeriodDates( strtotime( '17-Feb-2014' ), 2, strtotime( '01-Jan-2014' ), 0 ); $this->assertEquals( $ot_period_dates['start_date'], TTDate::getBeginDayEpoch( strtotime( '09-Feb-2014' ) ) ); $this->assertEquals( $ot_period_dates['end_date'], TTDate::getEndDayEpoch( strtotime( '22-Feb-2014' ) ) ); $this->assertEquals( false, $ot_period_dates['is_first_week'] ); $this->assertEquals( true, $ot_period_dates['is_last_week'] ); // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( strtotime('17-Feb-2014'), strtotime('01-Jan-2014'), 0 ), TRUE ); //Sun $retval = false; $anchor_date = TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2014' ) ); $x = 0; for ( $i = $anchor_date; $i <= TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2015' ) ); $i += ( 86400 * 7 ) ) { $x++; //Run at beginning so the counter essentially starts at 1. // $this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( $i, $anchor_date, 0 ), $retval ); // $retval = !$retval; //Swap $ot_period_dates = $cp->getOverTimePeriodDates( $i, 2, $anchor_date, 0 ); $this->assertEquals( $ot_period_dates['is_last_week'], $retval ); $retval = !$retval; //Swap } $this->assertEquals( 53, $x ); $retval = false; $anchor_date = TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2014' ) ); $x = 0; for ( $i = $anchor_date; $i <= TTDate::getMiddleDayEpoch( strtotime( '29-Dec-2025' ) ); $i += ( 86400 * 7 ) ) { $x++; //Run at beginning so the counter essentially starts at 1. //$this->assertEquals( $cp->isSecondBiWeeklyOverTimeWeek( $i, $anchor_date, 0 ), $retval ); //$retval = !$retval; //Swap $ot_period_dates = $cp->getOverTimePeriodDates( $i, 2, $anchor_date, 0 ); $this->assertEquals( $ot_period_dates['is_last_week'], $retval ); $retval = !$retval; //Swap } $this->assertEquals( 575, $x ); } /** * @group OvertimePolicy_testBiWeeklyOverTimePolicyA */ function testBiWeeklyOverTimePolicyA() { global $dd; //Test reaching the biweekly overtime in the first week, and part of it going into the second. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 300, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 310, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 320, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 300, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 310, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 320, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Start two weeks ago... $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $current_pay_period_obj = $this->getCurrentPayPeriod( $date_epoch ); if ( is_object( $current_pay_period_obj ) ) { $date_stamp = TTDate::getDate( 'DATE', $current_pay_period_obj->getStartDate() ); $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( $current_pay_period_obj->getStartDate() ); } else { $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); } Debug::text( 'Using date stamp: ' . TTDate::getDate( 'DATE+TIME', $date_stamp ), __FILE__, __LINE__, __METHOD__, 10 ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 1 - Beginning of next week... // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime policies are sorted by id desc, so the we have to reverse the order. //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 10 * 3600 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 8, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime policies are sorted by id desc, so the we have to reverse the order. //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testBiWeeklyOverTimePolicyB */ function testBiWeeklyOverTimePolicyB() { global $dd; //Test reaching the biweekly overtime in the first week, and part of it going into the second. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 300, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 310, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 320, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 300, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 310, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 320, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Start two weeks ago... $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $current_pay_period_obj = $this->getCurrentPayPeriod( $date_epoch ); if ( is_object( $current_pay_period_obj ) ) { $date_stamp = TTDate::getDate( 'DATE', $current_pay_period_obj->getStartDate() ); $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( $current_pay_period_obj->getStartDate() ); } else { $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); } Debug::text( 'Using date stamp: ' . TTDate::getDate( 'DATE+TIME', $date_stamp ), __FILE__, __LINE__, __METHOD__, 10 ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 10 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 1 - Beginning of next week... // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 8, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 9, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 14 * 3600 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 14 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testBiWeeklyOverTimePolicyC */ function testBiWeeklyOverTimePolicyC() { global $dd; //Test reaching the biweekly overtime just in the 2nd week. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 300, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 310, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 320, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 300, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 310, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 320, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Start two weeks ago... $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $current_pay_period_obj = $this->getCurrentPayPeriod( $date_epoch ); if ( is_object( $current_pay_period_obj ) ) { $date_stamp = TTDate::getDate( 'DATE', ( $current_pay_period_obj->getStartDate() + ( 7 * 86400 + 3601 ) ) ); $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( $current_pay_period_obj->getStartDate() + ( 7 * 86400 + 3601 ) ); } else { $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); } Debug::text( 'Using date stamp: ' . TTDate::getDate( 'DATE+TIME', $date_stamp ), __FILE__, __LINE__, __METHOD__, 10 ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 16 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 16 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 16 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 16 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 16 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 10 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 10:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 16 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testEvery4WeeksOverTimePolicyA */ function testEvery4WeeksOverTimePolicyA() { global $dd; //Test reaching the biweekly overtime in the first week, and part of it going into the second. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 300, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 310, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 350, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 5504, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Start four weeks ago... $start_epoch = $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -24, 'day' ); $current_pay_period_obj = $this->getCurrentPayPeriod( $date_epoch ); if ( is_object( $current_pay_period_obj ) ) { $date_stamp = TTDate::getDate( 'DATE', $current_pay_period_obj->getStartDate() ); $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( $current_pay_period_obj->getStartDate() ); } else { $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); } Debug::text( 'Using date stamp: ' . TTDate::getDate( 'DATE+TIME', $date_stamp ), __FILE__, __LINE__, __METHOD__, 10 ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 - Beginning of next week... // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:05AM' ), strtotime( $date_stamp . ' 8:05PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 8, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:05AM' ), strtotime( $date_stamp . ' 8:05PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 9, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:05AM' ), strtotime( $date_stamp . ' 8:05PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 10, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:05AM' ), strtotime( $date_stamp . ' 8:05PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 11, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:05AM' ), strtotime( $date_stamp . ' 8:05PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 - Beginning of next week... // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 14, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 15, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 16, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 17, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 18, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 - Beginning of next week... // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 21, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 22, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 23, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 24, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $start_epoch ), 25, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:10AM' ), strtotime( $date_stamp . ' 8:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 6 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 6 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyA */ function testDailyAndWeeklyOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][4] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 250, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][5] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 >39 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][4] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); //Weekly Overtime2 >31 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 7 * 3600 ) ); //Overtime1 //$this->assertEquals( $udt_arr[$date_epoch][5]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], (1*3600) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 >47 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][5] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //Weekly Overtime2 >39 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][4] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 6 * 3600 ) ); //Overtime1 >8 //$this->assertEquals( $udt_arr[$date_epoch][5]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], (1*3600) ); //Overtime2 >9 //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Overtime3 >10 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyB */ function testDailyAndWeeklyOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][4] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 250, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][5] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyC */ function testDailyAndWeeklyOverTimePolicyC() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // // //Test split shift where the first part of the shift doesn't cross into overtime and only the 2nd half does. // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 9:35AM' ), strtotime( $date_stamp . ' 2:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 2:20PM' ), strtotime( $date_stamp . ' 6:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12300 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 16500 ) ); //Overtime2 //This could be Daily >8 or Weekly >39 as they both apply at the exact same time. //However even though Daily OT has a lower calculation order and is calculated first, Weekly > 39 has a higher rate. //Which one should be used? Go with Daily OT for now as its calculated first and always needs to apply even after Weekly OT (ie: >12hrs) $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //Daily >8 $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); //Weekly >39 $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyC2 */ function testDailyAndWeeklyOverTimePolicyC2() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Test with same rate as Daily >8 //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // // //Test split shift where the first part of the shift doesn't cross into overtime and only the 2nd half does. // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 9:35AM' ), strtotime( $date_stamp . ' 2:10PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 2:20PM' ), strtotime( $date_stamp . ' 6:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12300 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 16500 ) ); //Overtime2 //This could be Daily >8 or Weekly >39 as they both apply at the exact same time. //However both have the same rate, so Daily >8 should *definitely* be used over Weekly OT. $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //Daily >8 $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyD */ function testDailyAndWeeklyOverTimePolicyD() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // // //Test split shift where the first part of the shift doesn't cross into overtime and only the 2nd half does. // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 9:35AM' ), strtotime( $date_stamp . ' 11:10AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 11:20AM' ), strtotime( $date_stamp . ' 6:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 5700 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 23100 ) ); //Overtime2 //This could be Daily >8 or Weekly >39 as they both apply at the exact same time. //However even though Daily OT has a lower calculation order and is calculated first, Weekly > 39 has a higher rate. //Which one should be used? Go with Daily OT for now as its calculated first and always needs to apply even after Weekly OT (ie: >12hrs) $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //Daily >8 $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); //Weekly >39 $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyE */ function testDailyAndWeeklyOverTimePolicyE() { //Test Daily and Weekly OT policies using the same pay code, as this causes problems for calculating weekly OT properly. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 1:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 5 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 5 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // // //Test split shift where the first part of the shift doesn't cross into overtime and only the 2nd half does. // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 1:00PM' ), strtotime( $date_stamp . ' 7:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyE2 */ function testDailyAndWeeklyOverTimePolicyE2() { //Test Daily and Weekly OT policies using the same pay code, as this causes problems for calculating weekly OT properly. // Also have the Weekly OT trigger on the same day that Daily OT, but after 10hrs. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); //OT $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Daily $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Weekly //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 6 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 6 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyE3 */ function testDailyAndWeeklyOverTimePolicyE3() { //Test Daily and Weekly OT policies using the same pay code, as this causes problems for calculating weekly OT properly. // Also have the Weekly OT trigger on the same day that Daily OT, but after 10hrs. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 // $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT1.5 // $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); //Weekly //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Daily $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Daily - Differential $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Weekly $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1250, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Weekly - Differential //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 6 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 6 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 7:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 11 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 3 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAndWeeklyOverTimePolicyF */ function testDailyAndWeeklyOverTimePolicyF() { //Test cases where Weekly OT has a higher rate than Daily OT and therefore takes priority. //For example when there is Daily >8 @ 1.5x, Daily >12 @ 2.0x, and Weekly > 40 @ 1.5x and Weekly > 44 @ 2.0x global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 242, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // // //Test split shift where the first part of the shift doesn't cross into overtime and only the 2nd half does. // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 9:35AM' ), strtotime( $date_stamp . ' 11:10AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 11:20AM' ), strtotime( $date_stamp . ' 6:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 5700 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 23100 ) ); //Overtime2 //This could be Daily >8 or Weekly >39 as they both apply at the exact same time. //However even though Daily OT has a lower calculation order and is calculated first, Weekly > 39 has a higher rate. //Which one should be used? Go with Daily OT for now as its calculated first and always needs to apply even after Weekly OT (ie: >12hrs) $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //Daily >8 $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); //Weekly >39 $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 10 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndDailyAndWeeklyOverTimePolicyA */ function testHolidayAndDailyAndWeeklyOverTimePolicyA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][3] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][4] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 250, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][5] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 500, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][6] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Since the Holiday OT rate is 4.0x, its higher than any other OT rate, so the employee should stay on holiday OT for the entire day. //Holiday OT $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][6] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Holiday OT //$this->assertEquals( $udt_arr[$date_epoch][1]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][6] ); //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], (8*3600) ); //Overtime 1 //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Overtime 2 //$this->assertEquals( $udt_arr[$date_epoch][3]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], (1*3600) ); //Overtime 3 //$this->assertEquals( $udt_arr[$date_epoch][2]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], (2*3600) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 >39 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][4] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); //Weekly Overtime1 >31 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 7 * 3600 ) ); //Overtime1 //$this->assertEquals( $udt_arr[$date_epoch][5]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], (1*3600) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime 2 >47 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][5] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //Weekly Overtime 3 >39 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][4] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 6 * 3600 ) ); //Overtime1 //$this->assertEquals( $udt_arr[$date_epoch][5]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], (1*3600) ); //Overtime2 //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayOverTimePolicyA */ function testHolidayOverTimePolicyA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Holiday OT $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayOverTimePolicyB */ function testHolidayOverTimePolicyB() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 12:15PM' ), [ 'in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:45PM' ), strtotime( $date_stamp . ' 8:30PM' ), [ 'in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:30PM' ) ); //Holiday OT $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4.25 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:15PM' ) ); $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 7.75 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:45PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:30PM' ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayOverTimePolicyC */ function testHolidayOverTimePolicyC() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 12:15PM' ), [ 'in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:45PM' ), strtotime( $date_stamp . ' 4:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 5:00PM' ), strtotime( $date_stamp . ' 9:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 9:00PM' ) ); //Holiday OT $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 3.75 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:45PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 4:30PM' ) ); $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 9:00PM' ) ); $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4.25 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 12:15PM' ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndDailyOverTimePolicyA */ function testHolidayAndDailyOverTimePolicyA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Holiday OT: This is daily OT at 1.5x, so other OT at same or higher rates should still kick in after this. $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime 1 >8 (1.5x) $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Overtime 2 >9 (@2.0x) $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime 3 >10 (@2.5x) $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndDailyOverTimePolicyB */ function testHolidayAndDailyOverTimePolicyB() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Holiday OT $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime 1 >8 (1.5x) [All Daily OT have same pay code] $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime 1 >8 (1.5x) [All Daily OT have same pay code] -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime 1 >8 (1.5x) [All Daily OT have same pay code] $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testQuantityWithOverTimePolicy */ function testQuantityWithOverTimePolicy() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][4] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 250, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][5] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'quantity' => 13, 'bad_quantity' => 3, ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['quantity'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['bad_quantity'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 8.67, $udt_arr[$date_epoch][1]['quantity'] ); $this->assertEquals( 2, $udt_arr[$date_epoch][1]['bad_quantity'] ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( 1.08, $udt_arr[$date_epoch][4]['quantity'] ); $this->assertEquals( 0.25, $udt_arr[$date_epoch][4]['bad_quantity'] ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( 1.08, $udt_arr[$date_epoch][3]['quantity'] ); $this->assertEquals( 0.25, $udt_arr[$date_epoch][3]['bad_quantity'] ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( 2.17, $udt_arr[$date_epoch][2]['quantity'] ); $this->assertEquals( 0.5, $udt_arr[$date_epoch][2]['bad_quantity'] ); $quantity_total = ( $udt_arr[$date_epoch][0]['quantity'] + $udt_arr[$date_epoch][1]['quantity'] + $udt_arr[$date_epoch][2]['quantity'] + $udt_arr[$date_epoch][3]['quantity'] + $udt_arr[$date_epoch][4]['quantity'] ); $this->assertEquals( 13, $quantity_total ); $bad_quantity_total = ( $udt_arr[$date_epoch][0]['bad_quantity'] + $udt_arr[$date_epoch][1]['bad_quantity'] + $udt_arr[$date_epoch][2]['bad_quantity'] + $udt_arr[$date_epoch][3]['bad_quantity'] + $udt_arr[$date_epoch][4]['bad_quantity'] ); $this->assertEquals( 3, $bad_quantity_total ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:05PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [], 'quantity' => 13, 'bad_quantity' => 3, ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( 43500, $udt_arr[$date_epoch][0]['total_time'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['quantity'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['bad_quantity'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 8.61, $udt_arr[$date_epoch][1]['quantity'] ); $this->assertEquals( 1.99, $udt_arr[$date_epoch][1]['bad_quantity'] ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( 1.08, $udt_arr[$date_epoch][4]['quantity'] ); $this->assertEquals( 0.25, $udt_arr[$date_epoch][4]['bad_quantity'] ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( 1.07, $udt_arr[$date_epoch][3]['quantity'] ); $this->assertEquals( 0.25, $udt_arr[$date_epoch][3]['bad_quantity'] ); //Overtime3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( 7500, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( 2.24, $udt_arr[$date_epoch][2]['quantity'] ); $this->assertEquals( 0.51, $udt_arr[$date_epoch][2]['bad_quantity'] ); $quantity_total = ( $udt_arr[$date_epoch][0]['quantity'] + $udt_arr[$date_epoch][1]['quantity'] + $udt_arr[$date_epoch][2]['quantity'] + $udt_arr[$date_epoch][3]['quantity'] + $udt_arr[$date_epoch][4]['quantity'] ); $this->assertEquals( 13, $quantity_total ); $bad_quantity_total = ( $udt_arr[$date_epoch][0]['bad_quantity'] + $udt_arr[$date_epoch][1]['bad_quantity'] + $udt_arr[$date_epoch][2]['bad_quantity'] + $udt_arr[$date_epoch][3]['bad_quantity'] + $udt_arr[$date_epoch][4]['bad_quantity'] ); $this->assertEquals( 3, $bad_quantity_total ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndNoOverTimePolicyA */ function testAutoDeductMealAndNoOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 3:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 7 * 3600 ) ); //Unless meal/break time is deducted from Regular Time, the total should be the same as worked time. //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Lunch Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndNoOverTimePolicyB */ function testAutoDeductMealAndNoOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 5:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9 * 3600 ) ); //Unless meal/break time is deducted from Regular Time, the total should be the same as worked time. //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 9 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Lunch Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndNoOverTimePolicyC */ function testAutoDeductMealAndNoOverTimePolicyC() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 3:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 6 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 6 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][2]['object_type_id'] ); //Lunch $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Lunch Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndNoOverTimePolicyD */ function testAutoDeductMealAndNoOverTimePolicyD() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 5:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndOverTimePolicyA */ function testAutoDeductMealAndOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 5:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); //Unless meal/break time is deducted from Regular Time, the total should be the same as worked time. //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 9 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndOverTimePolicyB */ function testAutoDeductMealAndOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10.5 * 3600 ) ); //Unless meal/break time is deducted from Regular Time, the total should be the same as worked time. //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 9 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][4]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndOverTimePolicyC */ function testAutoDeductMealAndOverTimePolicyC() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 5:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8.5 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndOverTimePolicyD */ function testAutoDeductMealAndOverTimePolicyD() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][4]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( -1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndOverTimePolicyE */ function testAutoDeductMealAndOverTimePolicyE() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 1:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 1:30PM' ), strtotime( $date_stamp . ' 6:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][1]['total_time'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 17915, $udt_arr[$date_epoch][2]['total_time'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.5 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( -1885, $udt_arr[$date_epoch][5]['total_time'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( -1715, $udt_arr[$date_epoch][6]['total_time'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); return true; } /** * @group testUserDateTotalOverrideWithAutoDeductMealAndOverTimePolicyA */ function testUserDateTotalOverrideWithAutoDeductMealAndOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 1:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 1:30PM' ), strtotime( $date_stamp . ' 6:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][1]['total_time'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 17915, $udt_arr[$date_epoch][2]['total_time'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.5 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( -1885, $udt_arr[$date_epoch][5]['total_time'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( -1715, $udt_arr[$date_epoch][6]['total_time'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); // //Override the UserDateTotal record for the lunch and change it to TotalTime=0 // $udtlf = new UserDateTotalListFactory(); $udtlf->getById( $udt_arr[$date_epoch][6]['id'] ); $this->assertEquals( 1, $udtlf->getRecordCount() ); if ( $udtlf->getRecordCount() == 1 ) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setOverride( true ); $udt_obj->setTotalTime( 0 ); $udt_obj->setStartTimeStamp( '' ); $udt_obj->setEndTimeStamp( '' ); $this->assertEquals( true, $udt_obj->isValid() ); if ( $udt_obj->isValid() ) { $udt_obj->Save(); } } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][1]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 17915, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][2]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][3]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][4]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( -1885, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][5]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][6]['tmp_override'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); $udtlf = new UserDateTotalListFactory(); $udtlf->getById( $udt_arr[$date_epoch][5]['id'] ); $this->assertEquals( 1, $udtlf->getRecordCount() ); if ( $udtlf->getRecordCount() == 1 ) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setOverride( true ); $udt_obj->setTotalTime( 0 ); $udt_obj->setStartTimeStamp( '' ); $udt_obj->setEndTimeStamp( '' ); $this->assertEquals( true, $udt_obj->isValid() ); if ( $udt_obj->isValid() ) { $udt_obj->Save(); } } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][1]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 17915, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][2]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][3]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][4]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][5]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][6]['tmp_override'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); $udtlf = new UserDateTotalListFactory(); $udtlf->getById( $udt_arr[$date_epoch][4]['id'] ); $this->assertEquals( 1, $udtlf->getRecordCount() ); if ( $udtlf->getRecordCount() == 1 ) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setOverride( true ); $udt_obj->setTotalTime( 0 ); $udt_obj->setStartTimeStamp( '' ); $udt_obj->setEndTimeStamp( '' ); $this->assertEquals( true, $udt_obj->isValid() ); if ( $udt_obj->isValid() ) { $udt_obj->Save(); } } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][1]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 17915, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][2]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][3]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][4]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][4]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][5]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][6]['tmp_override'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); $udtlf = new UserDateTotalListFactory(); $udtlf->getById( $udt_arr[$date_epoch][3]['id'] ); $this->assertEquals( 1, $udtlf->getRecordCount() ); if ( $udtlf->getRecordCount() == 1 ) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setOverride( true ); $udt_obj->setTotalTime( 0 ); $udt_obj->setStartTimeStamp( '' ); $udt_obj->setEndTimeStamp( '' ); $this->assertEquals( true, $udt_obj->isValid() ); if ( $udt_obj->isValid() ) { $udt_obj->Save(); } } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][1]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 17915, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][2]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][3]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][3]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][4]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][4]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][5]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][6]['tmp_override'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); $udtlf = new UserDateTotalListFactory(); $udtlf->getById( $udt_arr[$date_epoch][2]['id'] ); $this->assertEquals( 1, $udtlf->getRecordCount() ); if ( $udtlf->getRecordCount() == 1 ) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setOverride( true ); $udt_obj->setTotalTime( 0 ); $udt_obj->setStartTimeStamp( '' ); $udt_obj->setEndTimeStamp( '' ); $this->assertEquals( true, $udt_obj->isValid() ); if ( $udt_obj->isValid() ) { $udt_obj->Save(); } } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['tmp_override'] ); //Regular Time (Returned record order got changed, so swapped with above) $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 10885, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( false, $udt_arr[$date_epoch][2]['tmp_override'] ); //Regular Time (Returned record order got changed, so swapped with above) $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][1]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][3]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][3]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][4]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][4]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][5]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][6]['tmp_override'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); $udtlf = new UserDateTotalListFactory(); $udtlf->getById( $udt_arr[$date_epoch][2]['id'] ); //(Returned record order got changed, so using record '2' instead of '1'. $this->assertEquals( 1, $udtlf->getRecordCount() ); if ( $udtlf->getRecordCount() == 1 ) { $udt_obj = $udtlf->getCurrent(); $udt_obj->setOverride( true ); $udt_obj->setTotalTime( 0 ); $udt_obj->setStartTimeStamp( '' ); $udt_obj->setEndTimeStamp( '' ); $this->assertEquals( true, $udt_obj->isValid() ); if ( $udt_obj->isValid() ) { $udt_obj->Save(); } } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 9.5 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][1]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][1]['tmp_override'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][2]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][2]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][3]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][3]['tmp_override'] ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( 0, $udt_arr[$date_epoch][4]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][4]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][5]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][5]['tmp_override'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 0, $udt_arr[$date_epoch][6]['total_time'] ); $this->assertEquals( true, $udt_arr[$date_epoch][6]['tmp_override'] ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoAddMealAndNoOverTimePolicyA */ function testAutoAddMealAndNoOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 110 ); //AutoAdd 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 9:00AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 1:00PM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 6 * 3600 ) ); //Unless meal/break time is added to Regular Time, the total should be the same as worked time. //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 3 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 3 * 3600 ) ); //Regular Time (AutoAdd Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Lunch Time $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); ////Regular Time (AutoAdd Lunch) -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 100, $udt_arr[$date_epoch][4]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Lunch Time //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 0.5 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoAddMealAndOverTimePolicyA */ function testAutoAddMealAndOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); //$policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 110 ); //AutoAdd 1hr //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 3:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 1637, $udt_arr[$date_epoch][1]['total_time'] ); ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 1963, $udt_arr[$date_epoch][1]['total_time'] ); ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( 3600, $udt_arr[$date_epoch][2]['total_time'] ); ////Regular Time -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( ( 6 * 3600 ) + 1637 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( ( 8 * 3600 ) ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); ////Regular Time (AutoDeduct Lunch) //$this->assertEquals( 100, $udt_arr[$date_epoch][7]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][7]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time //$this->assertEquals( 1637, $udt_arr[$date_epoch][7]['total_time'] ); ////Regular Time (AutoDeduct Lunch) //$this->assertEquals( 100, $udt_arr[$date_epoch][8]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][8]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time //$this->assertEquals( 1963, $udt_arr[$date_epoch][8]['total_time'] ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( 3600, $udt_arr[$date_epoch][5]['total_time'] ); //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoAddMealAndOverTimePolicyB */ function testAutoAddMealAndOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //*Don't* include meal/break in regular time, keep it separate for this test. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 90, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //Include Meal/Break. $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 100 ); //Normal 1hr $policy_ids['break'][] = $this->createBreakPolicy( $this->company_id, 150 ); //AutoAdd 15mins //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users $policy_ids['break'], //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][10] ] //Regular *not* incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 7:00AM' ), strtotime( $date_stamp . ' 10:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 30, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 10:15AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 30, 'out_type_id' => 20, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:30PM' ), strtotime( $date_stamp . ' 3:00PM' ), [ 'in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 3:00PM' ), strtotime( $date_stamp . ' 4:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8.75 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1.75 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2.0 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 3 * 3600 ) ); ////OverTime -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 0.5 * 3600 ) ); ////OverTime -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1.5 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 2 * 3600 ) ); //Regular Time (AutoAdd Break) -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][6]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 155, $udt_arr[$date_epoch][6]['total_time'] ); //Regular Time (AutoAdd Break) -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][7]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][7]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 180, $udt_arr[$date_epoch][7]['total_time'] ); //Regular Time (AutoAdd Break) -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][7]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][7]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 308, $udt_arr[$date_epoch][7]['total_time'] ); ////Regular Time (AutoAdd Break) -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 110, $udt_arr[$date_epoch][8]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][8]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time //$this->assertEquals( 437, $udt_arr[$date_epoch][8]['total_time'] ); //Regular Time (AutoAdd Break) $this->assertEquals( 110, $udt_arr[$date_epoch][5]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Break Time $this->assertEquals( 900, $udt_arr[$date_epoch][5]['total_time'] ); //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndBreakAndOverTimePolicyA */ function testAutoDeductMealAndBreakAndOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $policy_ids['break'][] = $this->createBreakPolicy( $this->company_id, 130 ); //AutoDeduct 30min //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users $policy_ids['break'], //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 5:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( -1 * 3600 ) ); //Regular Time (AutoDeduct Break) $this->assertEquals( 110, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( -0.5 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAutoDeductMealAndBreakAndOverTimePolicyB */ function testAutoDeductMealAndBreakAndOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 190, $policy_ids['pay_formula_policy'][0] ); //Don't include meal/break in overtime. Include it in Regular time instead. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $policy_ids['break'][] = $this->createBreakPolicy( $this->company_id, 130 ); //AutoDeduct 30min //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users $policy_ids['break'], //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular incl. meal/break ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8.5 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); //Regular Time (AutoDeduct Lunch) $this->assertEquals( 100, $udt_arr[$date_epoch][3]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][190] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( -1 * 3600 ) ); //Regular Time (AutoDeduct Break) $this->assertEquals( 110, $udt_arr[$date_epoch][4]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][192] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( -0.5 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } // // Test OverTime Policy Differential Criteria. // /** * @group OvertimePolicy_testNestedDifferentialDailyOverTimePolicyA */ function testNestedDifferentialDailyOverTimePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][12], $this->policy_ids['pay_code'][100] ); //Regular Time policy as OT policy. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testNestedDifferentialDailyOverTimePolicyB */ function testNestedDifferentialDailyOverTimePolicyB() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][12], $this->policy_ids['pay_code'][100] ); //Regular Time policy as OT policy. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testNestedDifferentialWeeklyOverTimePolicyA */ function testNestedDifferentialWeeklyOverTimePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][12], $this->policy_ids['pay_code'][100] ); //Regular Time policy as OT policy. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1241, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:30AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:30AM' ), strtotime( $date_stamp . ' 9:15AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 9:15AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:45PM' ), strtotime( $date_stamp . ' 4:45PM' ), [ 'in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => TTUUID::getZeroID(), 'job_id' => TTUUID::getZeroID(), 'job_item_id' => TTUUID::getZeroID(), 'punch_tag_id' => [], ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); ////OverTime as Regular Time //$this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); ////OverTime as Regular Time //$this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.75 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1.25 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2.75 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 3 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testNestedDifferentialWeeklyOverTimePolicyB */ function testNestedDifferentialWeeklyOverTimePolicyB() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 10, $this->policy_ids['contributing_shift_policy'][12], $this->policy_ids['pay_code'][100] ); //Regular Time policy as OT policy. $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1241, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 7:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 11 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:30AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:30AM' ), strtotime( $date_stamp . ' 10:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 10:00AM' ), strtotime( $date_stamp . ' 12:15PM' ), [ 'in_type_id' => 10, 'out_type_id' => 20, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:45PM' ), strtotime( $date_stamp . ' 4:30PM' ), [ 'in_type_id' => 20, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], //Branch that is not included in OT differential. 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //OverTime $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 0.25 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 3.75 * 3600 ) ); ////OverTime as Regular Time //$this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.50 * 3600 ) ); ////OverTime as Regular Time //$this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1.50 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2.00 * 3600 ) ); //OverTime as Regular Time $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyOverTimePolicyA */ function testDifferentialDailyOverTimePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 90, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 5 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyOverTimePolicyB */ function testDifferentialDailyOverTimePolicyB() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 90, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyOverTimePolicyC */ function testDifferentialDailyOverTimePolicyC() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 90, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 3:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 3:30PM' ), strtotime( $date_stamp . ' 4:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:45PM' ), strtotime( $date_stamp . ' 5:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 5:30PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); ////Overtime1 //$this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.5 * 3600 ) ); ////Overtime1 //$this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.75 * 3600 ) ); ////Overtime1 //$this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1.25 * 3600 ) ); ////Overtime1 //$this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 2.5 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 5.0 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyOverTimePolicyD */ function testDifferentialDailyOverTimePolicyD() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 // //Test where combined_rate is different for the differential OT policies. // //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 90, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 3:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 3:30PM' ), strtotime( $date_stamp . ' 4:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:45PM' ), strtotime( $date_stamp . ' 5:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 5:30PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.75 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.75 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 2.5 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 0.50 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][6]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][6]['total_time'], ( 0.50 * 3600 ) ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyOverTimePolicyD2 */ function testDifferentialDailyOverTimePolicyD2() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 // //Test where combined_rate is the same for the differential OT policies. // //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 90, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 3:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 3:30PM' ), strtotime( $date_stamp . ' 4:45PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:45PM' ), strtotime( $date_stamp . ' 5:30PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 5:30PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 0.75 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 0.75 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 2.5 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 0.50 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][6]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][6]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][6]['total_time'], ( 0.50 * 3600 ) ); //Make sure no other hours $this->assertCount( 7, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyOverTimePolicyE1 */ function testDifferentialDailyOverTimePolicyE1() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 // //Test where combined_rate is higher for the differential OT policies that occur in the middle of the shift for just an hour or so. // The lower rate should then apply to records that haven't already been assigned to an OT policy. // //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1900, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 1:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 1:00PM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 2:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 5 * 3600 ) ); //Overtime2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialWeeklyOverTimePolicyA */ function testDifferentialWeeklyOverTimePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; // // This tests a specific bug that occurred due to calculateOverTimePolicy not sorting the input UDT records and therefore the output was incorrect // when there were multiple regular time policies in the same day, and weekly overtime that only applied with a differential criteria. // $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); //Regular $policy_ids['regular'][] = $this->createRegularTimePolicy( $this->company_id, 1010, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['pay_code'][101] ); //Branch 1 $policy_ids['regular'][] = $this->createRegularTimePolicy( $this->company_id, 1020, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['pay_code'][102] ); //Branch 2 //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1231, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence array_merge( [ $this->policy_ids['regular'][12] ], $policy_ids['regular'] ) //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 2:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 6 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 6 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 1:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 3:00PM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 3 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyA */ function testDifferentialDailyAndWeeklyOverTimePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyB */ function testDifferentialDailyAndWeeklyOverTimePolicyB() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyC */ function testDifferentialDailyAndWeeklyOverTimePolicyC() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyD */ function testDifferentialDailyAndWeeklyOverTimePolicyD() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyE */ function testDifferentialDailyAndWeeklyOverTimePolicyE() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyF */ function testDifferentialDailyAndWeeklyOverTimePolicyF() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyG */ function testDifferentialDailyAndWeeklyOverTimePolicyG() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 11:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 12:00PM' ), strtotime( $date_stamp . ' 9:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 3 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 5 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 9:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 10:00AM' ), strtotime( $date_stamp . ' 9:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 7 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 5:00PM' ), strtotime( $date_stamp . ' 9:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 7:00PM' ), strtotime( $date_stamp . ' 9:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 7:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00PM' ), strtotime( $date_stamp . ' 9:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 3 * 3600 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDifferentialDailyAndWeeklyOverTimePolicyH */ function testDifferentialDailyAndWeeklyOverTimePolicyH() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; //Test Daily>8, Daily>12, Weekly>40, Weekly>44, BiWeekly >80, BiWeekly >88, where the Weekly and BiWeekly have differential criteria //and only one of them applies. $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); //>8 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); //>9 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //>10 //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 230, $policy_ids['pay_formula_policy'][0] ); //>31 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //>39 //BiWeekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 300, $policy_ids['pay_formula_policy'][0] ); //>80 - BiWeekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 310, $policy_ids['pay_formula_policy'][1] ); //>84 - BiWeekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 320, $policy_ids['pay_formula_policy'][2] ); //>84 - BiWeekly $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1240, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][4] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1300, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][5] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1310, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][6] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1320, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][7] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Start two weeks ago... $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $current_pay_period_obj = $this->getCurrentPayPeriod( $date_epoch ); if ( is_object( $current_pay_period_obj ) ) { $date_stamp = TTDate::getDate( 'DATE', $current_pay_period_obj->getStartDate() ); $start_epoch = $date_epoch = TTDate::getMiddleDayEpoch( $current_pay_period_obj->getStartDate() ); } else { $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); } Debug::text( 'Using date stamp: ' . TTDate::getDate( 'DATE+TIME', $date_stamp ), __FILE__, __LINE__, __METHOD__, 10 ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) + ( 3 * 86400 + 3601 ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 9 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 8, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 10 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 9, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //Overtime >9 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); //Overtime >8 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 11 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 10, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////BiWeekly >86 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][7] ); //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); ////BiWeekly >86 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][7] ); //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //BiWeekly >86 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][7] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //BiWeekly >84 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][6] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); //BiWeekly >80 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][5] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 4 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 2 * 3600 ) ); //Overtime >9 - BiWeekly >86 is at 3.5x rate, so this is ignored. //$this->assertEquals( $udt_arr[$date_epoch][5]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][1] ); //$this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], (1*3600) ); //Overtime >8 - BiWeekly >84 is at 3.0x rate, so this is ignored. //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); // //Day of Week: 12 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 11, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //BiWeekly >86 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][7] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); //BiWeekly >86 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][7] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime >9 - BiWeekly >86 is at 3.5x rate, so this is ignored. //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Overtime >8 - BiWeekly >84 is at 3.0x rate, so this is ignored. //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); // //Day of Week: 13 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( $start_epoch ) ), 12, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //print_r($policy_ids['pay_code']); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //BiWeekly >86 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][7] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); //BiWeekly >86 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][7] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Overtime >10 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 2 * 3600 ) ); //Overtime >9 - BiWeekly >86 is at 3.5x rate, so this is ignored. //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Overtime >8 - BiWeekly >84 is at 3.0x rate, so this is ignored. //$this->assertEquals( $udt_arr[$date_epoch][4]['object_type_id'], 30 ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); //$this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], (1*3600) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testAverageHourlyRateOverTimePolicyA */ function testAverageHourlyRateOverTimePolicyA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1101 ); //Reg Alt Wage #1 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1102 ); //Reg Alt Wage #2 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1200 ); //OT1.5 AVGING $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1210 ); //OT2.0 AVGING $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1220 ); //OT2.5 AVGING //Regular $policy_ids['regular'][] = $this->createRegularTimePolicy( $this->company_id, 1010, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['pay_code'][101] ); //Branch 1 $policy_ids['regular'][] = $this->createRegularTimePolicy( $this->company_id, 1020, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['pay_code'][102] ); //Branch 2 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][2] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][3] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][4] ); //Weekly $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][2] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 240, $policy_ids['pay_formula_policy'][1] ); //$policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 250, $policy_ids['pay_formula_policy'][2] ); //Contributing Pay Codes $policy_ids['contributing_pay_code_policy'][] = $dd->createContributingPayCodePolicy( $this->company_id, 20, array_merge( [ $this->policy_ids['pay_code'][100], $this->policy_ids['pay_code'][101], $this->policy_ids['pay_code'][102], $this->policy_ids['pay_code'][190], $this->policy_ids['pay_code'][192] ], $policy_ids['pay_code'] ) ); //Regular+OT+Meal/Break //Contributing Shifts $policy_ids['contributing_shift_policy'][] = $dd->createContributingShiftPolicy( $this->company_id, 30, $policy_ids['contributing_pay_code_policy'][0] ); //Regular+OT+Meal/Break $this->updatePayFormulaPolicy( $policy_ids['pay_formula_policy'][2], 0, $policy_ids['contributing_shift_policy'][0], $policy_ids['contributing_shift_policy'][0] ); $this->updatePayFormulaPolicy( $policy_ids['pay_formula_policy'][3], 0, $policy_ids['contributing_shift_policy'][0], $policy_ids['contributing_shift_policy'][0] ); $this->updatePayFormulaPolicy( $policy_ids['pay_formula_policy'][4], 0, $policy_ids['contributing_shift_policy'][0], $policy_ids['contributing_shift_policy'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][10], $policy_ids['pay_code'][3] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1000, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 1001, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 230, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence array_merge( [ $this->policy_ids['regular'][12] ], $policy_ids['regular'] ) //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 10.00 * 1.135 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 10.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 10.00 * 1.135 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 10.00 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); ////Regular Time B2-- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 10.00 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 20.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 20.00 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 3 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); ////Regular Time B2 //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 20.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); //Overtime1 $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 24.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], Misc::MoneyRound( ( 1 * 24.00 * 1.135 ), 4 ) ); /* OT AVGing formula: 24hrs @ $10.00 = $240.00 36hrs @ $20.00 = $720.00 ------------------------ 60hrs = $960.00 $960/60hrs = $16/hr avg regular time rate. $24 @ 1.5x */ //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 4:00PM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Weekly Overtime1 B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 25.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 25.00 * 1.135 ) ); ////Weekly Overtime1 B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Overtime //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 25.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 25.00 * 1.135 ) ); //Weekly Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //Overtime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][3] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 25.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 25.00 * 1.135 ) ); /* OT AVGing formula: 24hrs @ $10.00 = $240.00 48hrs @ $20.00 = $960.00 ------------------------ 72hrs = $1200.00 $1200/72hrs = $16.6667/hr avg regular time rate. $25 @ 1.5x */ //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Since its averaging, make sure the hourly rate changed on all previous days as well. // //Day 1 $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 10.00 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); //Day 2 $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 10.00 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][101] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 10.00 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); //Day 3 $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 20.00 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); //Day 4 $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 20.00 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); //Day 5 $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); ////Regular Time B1 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 3 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); ////Regular Time B2 -- This was compacted out with compactUserDateTotalDataBasedOnTimeStamps() //$this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time //$this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 20.00 ) ); //$this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][102] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 20.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 20.00 * 1.135 ) ); //Overtime1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][3] ); //Overtime1 $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 25.00 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 25.00 * 1.135 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testBiWeeklyOverTimeWeekModifierA */ function testBiWeeklyOverTimeWeekModifierA() { $cp = TTnew( 'CalculatePolicy' ); /** @var CalculatePolicy $cp */ /* * * Bi-Weekly Pay Period Start Dates: 06-Dec-15 20-Dec-15 03-Jan-16 17-Jan-16 31-Jan-16 */ $start_date = $first_pay_period_start_date = TTDate::getMiddleDayEpoch( strtotime( '04-Jul-2010' ) ); //Sunday $end_date = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) + ( 365 * 86400 ) ); while ( $start_date <= $end_date ) { $pp_start_date = $start_date; $pp_end_date = ( strtotime( 'next Sunday', strtotime( 'next Sunday', $start_date ) ) - 43200 ); //BiWeekly, so do this twice. Debug::text( 'PP Start Date: ' . TTDate::getDate( 'DATE', $pp_start_date ) . ' End Date: ' . TTDate::getDate( 'DATE', $pp_end_date ), __FILE__, __LINE__, __METHOD__, 10 ); $x = 1; //for( $i = $pp_start_date; $i <= $pp_end_date; $i += 86400 ) { foreach ( TTDate::getDatePeriod( $pp_start_date, $pp_end_date, 'P1D' ) as $i ) { $i = TTDate::getMiddleDayEpoch( $i ); //Make sure DST doesn't make the date walk causing failures after 4-5years. if ( $x >= 8 && $x <= 14 ) { $is_second_week = true; } else { $is_second_week = false; } //$retval = $cp->isSecondBiWeeklyOverTimeWeek( $i, $first_pay_period_start_date, 0 ); //Start Week on Wed. $ot_period_dates = $cp->getOverTimePeriodDates( $i, 2, $first_pay_period_start_date, 0 ); $retval = $ot_period_dates['is_last_week']; //Debug::text(' Test Date: '. TTDate::getDate('DATE', $i) .' Is Second Week: '. (int)$retval .' Assert: '. (int)$is_second_week, __FILE__, __LINE__, __METHOD__,10); $this->assertEquals( $retval, $is_second_week ); $x++; } $start_date = TTDate::getBeginDayEpoch( $pp_end_date + 43400 ); } } /** * @group OvertimePolicy_testBiWeeklyOverTimeWeekModifierB */ function testBiWeeklyOverTimeWeekModifierB() { $cp = TTnew( 'CalculatePolicy' ); /** @var CalculatePolicy $cp */ $start_date = $first_pay_period_start_date = TTDate::getMiddleDayEpoch( strtotime( '30-Jun-2010' ) ); //Wed - Must span at least 5yrs for a full test. $end_date = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) + ( 365 * 86400 ) ); while ( $start_date <= $end_date ) { $pp_start_date = $start_date; $pp_end_date = ( strtotime( 'next Wednesday', strtotime( 'next Wednesday', $start_date ) ) - 43200 ); //BiWeekly, so do this twice. Debug::text( 'PP Start Date: ' . TTDate::getDate( 'DATE+TIME', $pp_start_date ) . ' End Date: ' . TTDate::getDate( 'DATE+TIME', $pp_end_date ), __FILE__, __LINE__, __METHOD__, 10 ); $x = 1; //for( $i = $pp_start_date; $i <= $pp_end_date; $i += 86400 ) { foreach ( TTDate::getDatePeriod( $pp_start_date, $pp_end_date, 'P1D' ) as $i ) { $i = TTDate::getMiddleDayEpoch( $i ); //Make sure DST doesn't make the date walk causing failures after 4-5years. if ( $x >= 8 && $x <= 14 ) { $is_second_week = true; } else { $is_second_week = false; } //$retval = $cp->isSecondBiWeeklyOverTimeWeek( $i, $first_pay_period_start_date, 3 ); //Start Week on Wed. $ot_period_dates = $cp->getOverTimePeriodDates( $i, 2, $first_pay_period_start_date, 3 ); $retval = $ot_period_dates['is_last_week']; Debug::text( ' X: ' . $x . ' Test Date: ' . TTDate::getDate( 'DATE+TIME', $i ) . ' Is Second Week: ' . (int)$retval . ' Assert: ' . (int)$is_second_week, __FILE__, __LINE__, __METHOD__, 10 ); $this->assertEquals( $retval, $is_second_week ); $x++; } $start_date = TTDate::getBeginDayEpoch( $pp_end_date + 43400 ); } } /** * @group OvertimePolicy_testManualTimeSheetDailyOverTimePolicyA */ function testManualTimeSheetDailyOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid problems with Sunday and DST which over. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), $this->branch_ids[0] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 1.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][4]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 1.5 * 21.50 * 1.135 ) ) ); //13.5% //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.0 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate_with_burden'], ( 2.0 * 21.50 * 1.135 ) ); //13.5% //Overtime 3 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 2.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 2.5 * 21.50 * 1.135 ) ) ); //13.5% //Make sure no other hours $this->assertCount( 5, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testManualTimeSheetDailyOverTimePolicyB */ function testManualTimeSheetDailyOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid problems with Sunday and DST which over. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 2 ), $this->branch_ids[0] ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 11 ), $this->branch_ids[1] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 13 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time - Branch0 $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 2:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time - Branch1 $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 6 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 2:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Overtime 3 (>10) $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 3 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 1:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][3]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 2.5 * 21.50 * 1.135 ) ) ); //13.5% //Overtime 2 (>9) $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 2.0 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate_with_burden'], ( 2.0 * 21.50 * 1.135 ) ); //13.5% //Overtime 1 (>8) $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['hourly_rate'], ( 1.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][5]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 1.5 * 21.50 * 1.135 ) ) ); //13.5% //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testManualTimeSheetDailyOverTimePolicyC */ function testManualTimeSheetDailyOverTimePolicyC() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 100, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 110, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 120, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //$dd->createUserDateTotal( $this->user_id, $date_epoch, (3600 * 2), $this->branch_ids[0] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 10:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 11 ), $this->branch_ids[1] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 13 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); //Punch End Time $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time - Branch0 $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 2 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Regular Time - Branch1 $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 6 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 10:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate'], ( 1 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['hourly_rate_with_burden'], ( 1 * 21.50 * 1.135 ) ); //13.5% //Overtime 3 (>10) $this->assertEquals( 30, $udt_arr[$date_epoch][3]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( 3 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 9:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['hourly_rate'], ( 2.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][3]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 2.5 * 21.50 * 1.135 ) ) ); //13.5% //Overtime 2 (>9) $this->assertEquals( 30, $udt_arr[$date_epoch][4]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][4]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][4]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['start_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['end_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate'], ( 2.0 * 21.50 ) ); $this->assertEquals( $udt_arr[$date_epoch][4]['hourly_rate_with_burden'], ( 2.0 * 21.50 * 1.135 ) ); //13.5% //Overtime 1 (>8) $this->assertEquals( 30, $udt_arr[$date_epoch][5]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][5]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][5]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['start_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][5]['hourly_rate'], ( 1.5 * 21.50 ) ); $this->assertEquals( Misc::MoneyRound( $udt_arr[$date_epoch][5]['hourly_rate_with_burden'] ), Misc::MoneyRound( ( 1.5 * 21.50 * 1.135 ) ) ); //13.5% //Make sure no other hours $this->assertCount( 6, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testManualTimeSheetWeeklyOverTimePolicyA */ function testManualTimeSheetWeeklyOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), 0 ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) + TTDate::getDSTOffset( strtotime( $date_stamp . ' 12:00AM' ), strtotime( $date_stamp . ' 12:00PM' ) ) ); //Punch End Time - Account for DST change as well. //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), 0 ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), 0 ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), 0 ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 11:00AM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 11:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), 0 ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 11:00AM' ) ); //Punch End Time //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 11:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 12 ), 0 ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['start_time_stamp'] ); $this->assertEquals( false, $udt_arr[$date_epoch][0]['end_time_stamp'] ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 11:00AM' ) ); //Punch End Time //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 11:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testManualTimeSheetWeeklyOverTimePolicyB */ function testManualTimeSheetWeeklyOverTimePolicyB() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 200, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 0 ), 0 ); //Create 0 hour manual timesheet entries. $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 0 ), 0 ); //Create 0 hour manual timesheet entries. $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 0 ), 0 ); //Create 0 hour manual timesheet entries. $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 0 ), 0 ); //Create 0 hour manual timesheet entries. $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 0 ), 0 ); //Create 0 hour manual timesheet entries. $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start tie $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch End Time //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createUserDateTotal( $this->user_id, $date_epoch, ( 3600 * 0 ), 0 ); //Create 0 hour manual timesheet entries. $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start tie $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch End Time //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Recalculate timesheet and recheck all start/end timestamps now. // $ulf = TTNew( 'UserListFactory' ); /** @var UserListFactory $ulf */ $ulf->getById( $this->user_id ); if ( $ulf->getRecordCount() > 0 ) { UserDateTotalFactory::reCalculateDay( $ulf->getCurrent(), TTDate::getDateArray( TTDate::getBeginWeekEpoch( time() ), TTDate::getEndWeekEpoch( $date_epoch ) ) ); } else { $this->assertTrue( false ); } $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start tie $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch End Time //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][2]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $policy_ids['pay_code'][1] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Punch Start tie $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch End Time //Overtime 2 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][2] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Punch Start time $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 8:00PM' ) ); //Punch End Time //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_test2ConsecutiveDaysPerWeekOverTimePolicyA */ function test2ConsecutiveDaysPerWeekOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 2150, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_test7ConsecutiveDaysPerWeekOverTimePolicyA */ function test7ConsecutiveDaysPerWeekOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 2155, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_test2ConsecutiveDaysOverTimePolicyA */ function test2ConsecutiveDaysOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 2300, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_test7ConsecutiveDaysOverTimePolicyA */ function test7ConsecutiveDaysOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 2305, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_test2DaysPerWeekOverTimePolicyA */ function test2DaysPerWeekOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 2400, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); // $date_stamp = TTDate::getDate('DATE', $date_epoch ); // // $dd->createPunchPair( $this->user_id, // strtotime($date_stamp.' 8:00AM'), // strtotime($date_stamp.' 8:00PM'), // array( // 'in_type_id' => 10, // 'out_type_id' => 10, // 'branch_id' => 0, // 'department_id' => 0, // 'job_id' => 0, // 'job_item_id' => 0, // ), // TRUE // ); // // $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); // //Total Time // $this->assertEquals( $udt_arr[$date_epoch][0]['object_type_id'], 5 ); //5=System Total // $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); // $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], (12 * 3600) ); // //Regular Time // $this->assertEquals( $udt_arr[$date_epoch][1]['object_type_id'], 20 ); //Regular Time // $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time // $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], (12 * 3600) ); // //Make sure no other hours // $this->assertEquals( count($udt_arr[$date_epoch]), 2 ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_test6DaysPerWeekOverTimePolicyA */ function test6DaysPerWeekOverTimePolicyA() { global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 200, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 210, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 220, $policy_ids['pay_formula_policy'][2] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 2404, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][0] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 210, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][1] ); //$policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 220, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][2] ); //print_r($policy_ids['overtime']); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); // $date_stamp = TTDate::getDate('DATE', $date_epoch ); // // $dd->createPunchPair( $this->user_id, // strtotime($date_stamp.' 8:00AM'), // strtotime($date_stamp.' 8:00PM'), // array( // 'in_type_id' => 10, // 'out_type_id' => 10, // 'branch_id' => 0, // 'department_id' => 0, // 'job_id' => 0, // 'job_item_id' => 0, // ), // TRUE // ); // // $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); // //Total Time // $this->assertEquals( $udt_arr[$date_epoch][0]['object_type_id'], 5 ); //5=System Total // $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); // $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], (12 * 3600) ); // //Regular Time // $this->assertEquals( $udt_arr[$date_epoch][1]['object_type_id'], 20 ); //Regular Time // $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time // $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], (12 * 3600) ); // //Make sure no other hours // $this->assertEquals( count($udt_arr[$date_epoch]), 2 ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Overtime 1 $this->assertEquals( 30, $udt_arr[$date_epoch][1]['object_type_id'] ); //OverTime $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $policy_ids['pay_code'][0] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 8 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 7, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 8:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 12 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleA */ function testHolidayAndScheduleA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday //$policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); //$this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '4:30PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 7.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 3:30PM' ) ); //Holiday Absence -- Absence is directly from the schedule, no holiday policy is involved. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 3:30PM' ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleA2 */ function testHolidayAndScheduleA2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday //$policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); //$this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Test with split shift absences of the same type. $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '4:30PM', ] ); $schedule_id[1] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '6:00PM', 'end_time' => '9:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 10.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 9:00PM' ) ); //Holiday Absence -- Absence is directly from the schedule, no holiday policy is involved. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 3.0 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 9:00PM' ) ); //Holiday Absence -- Absence is directly from the schedule, no holiday policy is involved. $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 7.5 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 3:30PM' ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleB */ function testHolidayAndScheduleB() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 10 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '1:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Holiday policy calculates 0 hrs, so the scheduled time should be overridden to 0 (or no records at all). $this->assertCount( 0, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleC */ function testHolidayAndScheduleC() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '8:00PM', //Longer than the what the actual holiday time appears on the timesheet will be. ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); //Holiday Absence -- Calculated by the Holiday Policy, so its less than the scheduled time. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleC2 */ function testHolidayAndScheduleC2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); //Test split shift schedules that are both overridden by the holiday policy. $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '8:00PM', //Longer than the what the actual holiday time appears on the timesheet will be. ] ); $schedule_id[1] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '9:00PM', 'end_time' => '11:00PM', //Longer than the what the actual holiday time appears on the timesheet will be. ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); //Holiday Absence -- Calculated by the Holiday Policy, so its less than the scheduled time. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 4:00PM' ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleC3 */ function testHolidayAndScheduleC3() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '8:00PM', //Longer than the what the actual holiday time appears on the timesheet will be. ] ); //Override the schedule and the holiday policy to put in just 1hr of Holiday time directly on the timesheet. $dd->createAbsence( $this->user_id, $date_epoch, ( 1 * 3600 ), $this->policy_ids['absence'][10] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 1:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //Holiday Absence -- Calculated by the Holiday Policy, so its less than the scheduled time. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 1:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleD */ function testHolidayAndScheduleD() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $policy_ids['absence'][] = $dd->createAbsencePolicy( $this->company_id, 30, $this->policy_ids['pay_code'][920] ); $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense $policy_ids['absence'], //Absences [ $this->policy_ids['regular'][12] ] //Regular ); //Test switching the scheduled shift to a different absence policy and make sure both $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $policy_ids['absence'][0], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '4:00PM', //Less than the what the actual holiday time appears on the timesheet will be. ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 15 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 3:00PM' ) ); //Schedule Absence -- From overridden scheduled shift above that is different than holiday policy specifies. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][920] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 7 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 3:00PM' ) ); //Holiday Absence -- Calculated by the Holiday Policy, so its less than the scheduled time. $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAndScheduleD2 */ function testHolidayAndScheduleD2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 20 ); $this->createHoliday( $this->company_id, 10, $date_epoch, $policy_ids['holiday'][0] ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //$policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 510 ); //OT4.0 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $policy_ids['absence'][] = $dd->createAbsencePolicy( $this->company_id, 30, $this->policy_ids['pay_code'][920] ); $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense $policy_ids['absence'], //Absences [ $this->policy_ids['regular'][12] ] //Regular ); //Test switching the scheduled shift to a different absence policy and make sure both $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $policy_ids['absence'][0], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '6:00PM', //Longer than the what the actual holiday time appears on the timesheet will be. ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 17 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); //Schedule Absence -- From overridden scheduled shift above that is different than holiday policy specifies. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][920] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 9 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 5:00PM' ) ); //Holiday Absence -- Calculated by the Holiday Policy, so its less than the scheduled time. $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testScheduleAndAbsenceA */ function testScheduleAndAbsenceA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '8:00PM', ] ); //Add absence with a *same* absence policy, and same pay code, which *should* override it. $dd->createAbsence( $this->user_id, $date_epoch, ( 1 * 3600 ), $this->policy_ids['absence'][10] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 1:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //TimeSheet Absence -- Taken from the timesheet and overrides the schedule. $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 1:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testScheduleAndAbsenceB */ function testScheduleAndAbsenceB() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 //Daily $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $policy_ids['pay_formula_policy'][0] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Holiday $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 500, $policy_ids['pay_formula_policy'][0] ); $policy_ids['overtime'][] = $this->createOverTimePolicy( $this->company_id, 510, $this->policy_ids['contributing_shift_policy'][12], $policy_ids['pay_code'][3] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 120 ); //AutoDeduct 1hr $schedule_policy_id = $this->createSchedulePolicy( 10, $policy_ids['meal'][0] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, $policy_ids['overtime'], //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $schedule_id[0] = $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '8:00PM', ] ); //Add absence with a different absence policy, but same pay code, which should be in addition to the schedule entry, and *not* override it. $dd->createAbsence( $this->user_id, $date_epoch, ( 1 * 3600 ), $this->policy_ids['absence'][11] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Schedule Absence -- Taken from the schedule $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 12:00AM' ) ); $this->assertEqualsWithDelta( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 1:00AM' ), 3600 ); //3600 delta due to DST when run on 04-Nov-19 //TimeSheet Absence -- Taken from the timesheet $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 11 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 7:00PM' ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceCalendarDayBeforeAndAfterA */ function testHolidayAbsenceCalendarDayBeforeAndAfterA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -1, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 100 ); //Calendar Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Sat of previous week. //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA1 */ function testHolidayAbsenceScheduledDayBeforeAndAfterA1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA2 */ function testHolidayAbsenceScheduledDayBeforeAndAfterA2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -1, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA3 */ function testHolidayAbsenceScheduledDayBeforeAndAfterA3() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -1, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -2, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); $this->assertArrayNotHasKey( $holiday_epoch, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA4 */ function testHolidayAbsenceScheduledDayBeforeAndAfterA4() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -1, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); $this->assertArrayNotHasKey( $holiday_epoch, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA5A */ function testHolidayAbsenceScheduledDayBeforeAndAfterA5A() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -1, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -2, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); $this->assertArrayNotHasKey( $holiday_epoch, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA5B */ function testHolidayAbsenceScheduledDayBeforeAndAfterA5B() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -1, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -2, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA6A */ function testHolidayAbsenceScheduledDayBeforeAndAfterA6A() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -2, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -1, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); $this->assertArrayNotHasKey( $holiday_epoch, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterA6B */ function testHolidayAbsenceScheduledDayBeforeAndAfterA6B() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -2, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absence 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterB1 */ function testHolidayAbsenceScheduledDayBeforeAndAfterB1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -14, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterB2 */ function testHolidayAbsenceScheduledDayBeforeAndAfterB2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -14, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -28, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 0, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceScheduledDayBeforeAndAfterC1 */ function testHolidayAbsenceScheduledDayBeforeAndAfterC1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); $holiday_epoch2 = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -0, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 200 ); //Scheduled Days before and after //Two holidays, to simiulate one on Friday and one on Monday. $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week $this->createHoliday( $this->company_id, 20, $holiday_epoch2, $policy_ids['holiday'][0] ); //Sun of current week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'start_time' => ' 8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday1 time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); // //Check holiday2 time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch2, $holiday_epoch2 ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch2][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch2][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch2][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch2][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch2][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch2][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayAbsenceHolidayWeekDayBeforeAndAfterA */ function testHolidayAbsenceHolidayWeekDayBeforeAndAfterA() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 300 ); //Scheduled Days before and after $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$holiday_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$holiday_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$holiday_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$holiday_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Holiday Time $this->assertEquals( $udt_arr[$holiday_epoch][1]['total_time'], ( 8 * 3600 ) ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayA1 */ function testHolidayShiftOnHolidayA1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 400 ); //Must Work On Holiday $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayA2 */ function testHolidayShiftOnHolidayA2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 400 ); //Must Work On Holiday $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Check holiday time // $udt_arr = $this->getUserDateTotalArray( $holiday_epoch, $holiday_epoch ); //Make sure no other hours $this->assertCount( 0, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayB1 */ function testHolidayShiftOnHolidayB1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 420 ); //Must Never Work $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayB2 */ function testHolidayShiftOnHolidayB2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 420 ); //Must Never Work $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = $holiday_epoch; // //Recalculate timesheet and recheck all start/end timestamps now. // $ulf = TTNew( 'UserListFactory' ); /** @var UserListFactory $ulf */ $ulf->getById( $this->user_id ); if ( $ulf->getRecordCount() > 0 ) { UserDateTotalFactory::reCalculateDay( $ulf->getCurrent(), TTDate::getDateArray( TTDate::getBeginWeekEpoch( $date_epoch ), TTDate::getEndWeekEpoch( $date_epoch ) ) ); } else { $this->assertTrue( false ); } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayC1 */ function testHolidayShiftOnHolidayC1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 430 ); //Must Work Only If Scheduled $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = $holiday_epoch; // //Recalculate timesheet and recheck all start/end timestamps now. // $ulf = TTNew( 'UserListFactory' ); /** @var UserListFactory $ulf */ $ulf->getById( $this->user_id ); if ( $ulf->getRecordCount() > 0 ) { UserDateTotalFactory::reCalculateDay( $ulf->getCurrent(), TTDate::getDateArray( TTDate::getBeginWeekEpoch( $date_epoch ), TTDate::getEndWeekEpoch( $date_epoch ) ) ); } else { $this->assertTrue( false ); } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayC2 */ function testHolidayShiftOnHolidayC2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 430 ); //Must Work Only If Scheduled $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayC3 */ function testHolidayShiftOnHolidayC3() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 430 ); //Must Work Only If Scheduled $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 10, //Working //'absence_policy_id' => $this->policy_ids['absence'][10], //'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 16 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayC4 */ function testHolidayShiftOnHolidayC4() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 430 ); //Must Work Only If Scheduled $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 10, //Working //'absence_policy_id' => $this->policy_ids['absence'][10], //'schedule_policy_id' => $schedule_policy_id, 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Make sure no other hours $this->assertCount( 0, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayD1 */ function testHolidayShiftOnHolidayD1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 440 ); //Must Not Work (Only if Scheduled Absent) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absent 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayD2 */ function testHolidayShiftOnHolidayD2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 440 ); //Must Not Work (Only if Scheduled Absent) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 10, //Working //'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayD3 */ function testHolidayShiftOnHolidayD3() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 440 ); //Must Not Work (Only if Scheduled Absent) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absent 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayE1 */ function testHolidayShiftOnHolidayE1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 472 ); //Must Not Work (Must be Scheduled Absent) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absent 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayE2 */ function testHolidayShiftOnHolidayE2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 472 ); //Must Not Work (Must be Scheduled Absent) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 10, //Working //'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Make sure no other hours $this->assertCount( 0, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayE3 */ function testHolidayShiftOnHolidayE3() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 472 ); //Must Not Work (Must be Scheduled Absent) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absent 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayF1 */ function testHolidayShiftOnHolidayF1() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 475 ); //Must Not Work (Must not be Scheduled) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absent 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Make sure no other hours $this->assertCount( 0, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayF2 */ function testHolidayShiftOnHolidayF2() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 475 ); //Must Not Work (Must not be Scheduled) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 10, //Working //'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Make sure no other hours $this->assertCount( 0, $udt_arr ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayF3 */ function testHolidayShiftOnHolidayF3() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 475 ); //Must Not Work (Must not be Scheduled) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $this->createSchedule( $this->user_id, $date_epoch, [ 'status_id' => 20, //Absent 'absence_policy_id' => $this->policy_ids['absence'][10], 'schedule_policy_id' => TTUUID::getZeroID(), 'start_time' => '8:00AM', 'end_time' => '4:00PM', ] ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testHolidayShiftOnHolidayF4 */ function testHolidayShiftOnHolidayF4() { global $dd; $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $holiday_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( $date_epoch ), -3, 'day' ); //Holiday $policy_ids['holiday'][] = $this->createHolidayPolicy( $this->company_id, 475 ); //Must Not Work (Must not be Scheduled) $this->createHoliday( $this->company_id, 10, $holiday_epoch, $policy_ids['holiday'][0] ); //Thu of previous week //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception $policy_ids['holiday'], null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10], $this->policy_ids['absence'][11] ], //Absence, //Absence [ $this->policy_ids['regular'][12] ] //Regular ); // //Day of Week: 1 // //$date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), -10, 'day' ); $date_epoch = $holiday_epoch; // //Recalculate timesheet and recheck all start/end timestamps now. // $ulf = TTNew( 'UserListFactory' ); /** @var UserListFactory $ulf */ $ulf->getById( $this->user_id ); if ( $ulf->getRecordCount() > 0 ) { UserDateTotalFactory::reCalculateDay( $ulf->getCurrent(), TTDate::getDateArray( TTDate::getBeginWeekEpoch( $date_epoch ), TTDate::getEndWeekEpoch( $date_epoch ) ) ); } else { $this->assertTrue( false ); } $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); //Holiday Time $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Holiday Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group testNegativeAbsencePolicyA */ function testNegativeAbsencePolicyA() { //Test handling negative absence that matches the amount of time worked. There should still be a system row of 0hrs but the start/end time stamps will be populated. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $this->policy_ids['pay_formula_policy'][910] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][12] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 9:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createAbsence( $this->user_id, $date_epoch, ( -1 * 3600 ), $this->policy_ids['absence'][10] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 0 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); //Absence Time $this->assertEquals( 25, $udt_arr[$date_epoch][2]['object_type_id'] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Absence Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( -1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 9:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 8:00AM' ) ); //Make sure no other hours $this->assertCount( 3, $udt_arr[$date_epoch] ); return true; } /** * @group testDuplicateRegularTimePolicyA */ function testDuplicateRegularTimePolicyA() { //Test handling meal policy at Active After time, along with regular time policies that include the meal and some that don't. This ensures that the regular time never gets double up or shows more than the employee worked. global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 200 ); //OT1.5 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 210 ); //OT2.0 $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 220 ); //OT2.5 $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 100, $this->policy_ids['pay_formula_policy'][910] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 110, $policy_ids['pay_formula_policy'][1] ); $policy_ids['pay_code'][] = $this->createPayCode( $this->company_id, 120, $policy_ids['pay_formula_policy'][2] ); $policy_ids['regular'][500] = $dd->createRegularTimePolicy( $this->company_id, 21, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['pay_code'][100] ); $policy_ids['regular'][501] = $dd->createRegularTimePolicy( $this->company_id, 22, $this->policy_ids['contributing_shift_policy'][12], $this->policy_ids['pay_code'][101] ); $policy_ids['meal'][] = $this->createMealPolicy( $this->company_id, 130 ); //AutoDeduct 1hr At Active After Time //Create Policy Group $dd->createPolicyGroup( $this->company_id, $policy_ids['meal'], //Meal null, //Exception null, //Holiday null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense null, //Absence [ $policy_ids['regular'][500], $policy_ids['regular'][501] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ); //Start on Monday to avoid DST issues on Sunday morning. $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $date_epoch2 = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time(), 1 ) ), 1, 'day' ); $date_stamp2 = TTDate::getDate( 'DATE', $date_epoch2 ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 6:00AM' ), strtotime( $date_stamp . ' 6:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 11:45PM' ), strtotime( $date_stamp2 . ' 1:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => 0, 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 13.25 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['start_time_stamp'], strtotime( $date_stamp . ' 6:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][0]['end_time_stamp'], strtotime( $date_stamp2 . ' 1:00AM' ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1.25 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['start_time_stamp'], strtotime( $date_stamp . ' 11:45PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['end_time_stamp'], strtotime( $date_stamp2 . ' 1:00AM' ) ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][2]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][2]['total_time'], ( 12 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['start_time_stamp'], strtotime( $date_stamp . ' 6:00AM' ) ); $this->assertEquals( $udt_arr[$date_epoch][2]['end_time_stamp'], strtotime( $date_stamp . ' 6:00PM' ) ); //Lunch $this->assertEquals( 100, $udt_arr[$date_epoch][3]['object_type_id'] ); $this->assertEquals( $udt_arr[$date_epoch][3]['pay_code_id'], $this->policy_ids['pay_code'][190] ); $this->assertEquals( $udt_arr[$date_epoch][3]['total_time'], ( -1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['start_time_stamp'], strtotime( $date_stamp . ' 12:00PM' ) ); $this->assertEquals( $udt_arr[$date_epoch][3]['end_time_stamp'], strtotime( $date_stamp . ' 1:00PM' ) ); //Make sure no other hours $this->assertCount( 4, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAverageHourlyRateA */ function testDailyAverageHourlyRateA() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1300, 0, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['contributing_shift_policy'][10] ); //Modify existing pay code to use the above pay formula. $pclf = TTnew( 'PayCodeListFactory' ); $pclf->getById( $this->policy_ids['pay_code'][900] ); if ( $pclf->getRecordCount() > 0 ) { $pc_obj = $pclf->getCurrent(); $pc_obj->setPayFormulaPolicy( $policy_ids['pay_formula_policy'][0] ); if ( $pc_obj->isValid() ) { $pc_obj->Save(); } } else { $this->assertTrue( false, 'Pay Code not found!' ); } //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 9:00AM' ), //This is before the averaging lookback period, so make it small so we know if it affects the averaging formula. [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 8 * 3600 ), $this->policy_ids['absence'][10] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Absence $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } /** * @group OvertimePolicy_testDailyAverageHourlyRateB */ function testDailyAverageHourlyRateB() { if ( getTTProductEdition() == TT_PRODUCT_COMMUNITY ) { return true; } global $dd; $policy_ids['pay_formula_policy'][] = $this->createPayFormulaPolicy( $this->company_id, 1300, 0, $this->policy_ids['contributing_shift_policy'][10], $this->policy_ids['contributing_shift_policy'][10] ); //Modify existing pay code to use the above pay formula. $pclf = TTnew( 'PayCodeListFactory' ); $pclf->getById( $this->policy_ids['pay_code'][900] ); if ( $pclf->getRecordCount() > 0 ) { $pc_obj = $pclf->getCurrent(); $pc_obj->setPayFormulaPolicy( $policy_ids['pay_formula_policy'][0] ); if ( $pc_obj->isValid() ) { $pc_obj->Save(); } } else { $this->assertTrue( false, 'Pay Code not found!' ); } //Create Policy Group $dd->createPolicyGroup( $this->company_id, null, //Meal null, //Exception null, //Holiday null, //OT null, //Premium null, //Round [ $this->user_id ], //Users null, //Break null, //Accrual null, //Expense [ $this->policy_ids['absence'][10] ], //Absence [ $this->policy_ids['regular'][10] ] //Regular ); $date_epoch = TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); // //Day of Week: 1 // $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 9:00AM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 1 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 2 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 1, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[0], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 3 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 2, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 4 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 3, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 5 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 4, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 12:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 4 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 6 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 5, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $dd->createPunchPair( $this->user_id, strtotime( $date_stamp . ' 8:00AM' ), strtotime( $date_stamp . ' 4:00PM' ), [ 'in_type_id' => 10, 'out_type_id' => 10, 'branch_id' => $this->branch_ids[1], 'department_id' => 0, 'job_id' => 0, 'job_item_id' => 0, 'punch_tag_id' => [] ], true ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Regular Time $this->assertEquals( 20, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][100] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 21.50 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 21.50 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); // //Day of Week: 7 // $date_epoch = TTDate::incrementDate( TTDate::getMiddleDayEpoch( TTDate::getBeginWeekEpoch( time() ) ), 6, 'day' ); $date_stamp = TTDate::getDate( 'DATE', $date_epoch ); $absence_id = $dd->createAbsence( $this->user_id, $date_epoch, ( 8 * 3600 ), $this->policy_ids['absence'][10] ); $udt_arr = $this->getUserDateTotalArray( $date_epoch, $date_epoch ); //print_r($udt_arr); //Total Time $this->assertEquals( 5, $udt_arr[$date_epoch][0]['object_type_id'] ); //5=System Total $this->assertEquals( $udt_arr[$date_epoch][0]['pay_code_id'], TTUUID::getZeroID() ); $this->assertEquals( $udt_arr[$date_epoch][0]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate'] ); $this->assertEquals( 0, $udt_arr[$date_epoch][0]['hourly_rate_with_burden'] ); //Absence $this->assertEquals( 25, $udt_arr[$date_epoch][1]['object_type_id'] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['pay_code_id'], $this->policy_ids['pay_code'][900] ); //Regular Time $this->assertEquals( $udt_arr[$date_epoch][1]['total_time'], ( 8 * 3600 ) ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate'], 17.20 ); $this->assertEquals( $udt_arr[$date_epoch][1]['hourly_rate_with_burden'], ( 17.20 * 1.135 ) ); //Make sure no other hours $this->assertCount( 2, $udt_arr[$date_epoch] ); return true; } // function testUserFactoryCache() { // //Make sure that UserFactory caches are cleared when saving a user record. // //This is here since the setup/tearDown functions create user records already. // // However this won't work when run in parallel. :( // $ulf = new UserListFactory(); // // $ulf->removeCache( $this->user_id ); //Make sure we start with the cache cleared. // $this->assertFalse( $ulf->getCache( $this->user_id ) ); //Confirm its cleared. // // $ulf->getById( $this->user_id ); // if ( $ulf->getRecordCount() > 0 ) { // $user_obj = $ulf->getCurrent(); // $old_data = $user_obj->data; // // $this->assertNotFalse( $user_obj->getCache( $this->user_id ) ); // // $this->assertEquals( $user_obj->getNote(), FALSE ); // $user_obj->setNote('Test1'); // if ( $user_obj->isValid() ) { // $user_obj->Save( FALSE ); // // $this->assertFalse( $user_obj->getCache( $this->user_id ) ); // // //Cache should be cleared at this point // $ulf_b = new UserListFactory(); // $ulf_b->getById( $this->user_id ); // if ( $ulf_b->getRecordCount() > 0 ) { // $user_obj_b = $ulf_b->getCurrent(); // $new_data = $user_obj_b->data; // // $this->assertNotEquals( $old_data, $new_data ); //Updated Date and NOTE fields would have changed. // $this->assertEquals( $user_obj->getNote(), 'Test1' ); // $this->assertEquals( $user_obj->getNote(), $user_obj_b->getNote() ); // } else { // $this->assertTrue( FALSE ); // } // // } else { // $this->assertTrue( FALSE ); // } // } else { // $this->assertTrue( FALSE ); // } // } } ?>