function reCalculateYTD()
 {
     //Get all pay stubs NEWER then this one.
     $pslf = new PayStubListFactory();
     $pslf->getByUserIdAndStartDateAndEndDate($this->getUser(), $this->getTransactionDate(), TTDate::getEndYearEpoch($this->getTransactionDate()));
     $total_pay_stubs = $pslf->getRecordCount();
     if ($total_pay_stubs > 0) {
         $pslf->StartTransaction();
         foreach ($pslf as $ps_obj) {
             $this->reCalculatePayStubYTD($ps_obj->getId());
         }
         $pslf->CommitTransaction();
     } else {
         Debug::Text('No Newer Pay Stubs found!', __FILE__, __LINE__, __METHOD__, 10);
     }
     return TRUE;
 }
Example #2
0
     break;
 case 'recalculate_paystub_ytd':
     //Debug::setVerbosity(11);
     Debug::Text('Recalculating Pay Stub YTDs!', __FILE__, __LINE__, __METHOD__, 10);
     Debug::Text('Pay Stub ID: ' . $pay_stub_ids, __FILE__, __LINE__, __METHOD__, 10);
     $init_progress_bar = TRUE;
     //Just need the pay_stub_id of the modified pay stub.
     $pslf = new PayStubListFactory();
     $pslf->StartTransaction();
     if (is_array($pay_stub_ids)) {
         foreach ($pay_stub_ids as $pay_stub_id) {
             $pslf->getByIdAndCompanyIdAndIgnoreDeleted($pay_stub_id, $current_company->getId());
             if ($pslf->getRecordCount() > 0) {
                 $main_ps_obj = $pslf->getCurrent();
                 //Get all pay stubs NEWER then this one.
                 $pslf->getByUserIdAndStartDateAndEndDate($main_ps_obj->getUser(), $main_ps_obj->getTransactionDate(), TTDate::getEndYearEpoch($main_ps_obj->getTransactionDate()));
                 $total_pay_stubs = $pslf->getRecordCount();
                 if ($total_pay_stubs > 0) {
                     if ($init_progress_bar == TRUE) {
                         InitProgressBar();
                         $init_progress_bar = FALSE;
                     }
                     $progress_bar->setValue(0);
                     $progress_bar->display();
                     $x = 1;
                     foreach ($pslf as $ps_obj) {
                         Debug::Text('ReCalculating Pay Stub ID: ' . $ps_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
                         $ps_obj->reCalculatePayStubYTD($ps_obj->getId());
                         $progress_bar->setValue(Misc::calculatePercent($x, $total_pay_stubs));
                         $progress_bar->display();
                         $x++;