Example #1
0
 function testCalculateOneSupportContractTotalWithStartDate()
 {
     $sc = new SupportContract();
     $sc->set(array('domain_name' => 'Test', 'start_date' => '2010-01-01', 'end_date' => '2010-04-30', 'hourly_rate' => '120', 'support_hours' => '.5', 'monthly_rate' => '50'));
     $sc->save();
     # Hour is in date range
     $h = new Hour();
     $h->set(array('description' => 'Test', 'support_contract_id' => $sc->id, 'date' => '2010-02-20', 'hours' => '2.5'));
     $h->save();
     # Hour is out of date range
     $h = new Hour();
     $h->set(array('description' => 'Test', 'support_contract_id' => $sc->id, 'date' => '2010-01-20', 'hours' => '1'));
     $h->save();
     # start date: 2010-02-01 end date: 2010-04-30
     # 3 monthes at 50 + 2 hours at 120 = 390
     $date_range = array('start_date' => '2010-02-01', 'end_date' => '2010-05-31');
     $sc_total = $sc->calculateTotal($date_range);
     $this->assertEqual($sc_total, 390);
     $date_range = array('start_date' => '2010-02-01');
     $sc_no_end_date_total = $sc->calculateTotal($date_range);
     $this->assertEqual($sc_no_end_date_total, 390);
     ## clean up
     $sc->destroyAssociatedRecords();
     $sc->delete();
 }