Example #1
0
 public static function getAvailableStartYears()
 {
     $years = [];
     $date = new Carbon('1 year ago');
     $years[] = (int) $date->format('Y');
     $years[] = (int) $date->addYear()->format('Y');
     $years[] = (int) $date->addYear()->format('Y');
     return $years;
 }
Example #2
0
 public function addInterval(Carbon $date)
 {
     switch ($this->interval) {
         case 'yearly':
             $date->addYear();
             break;
         case 'quarterly':
             $date->addMonths(3);
             break;
         case 'weekly':
             $date->addWeek();
             break;
         case 'monthly':
         default:
             $date->addMonth();
     }
     return $date;
 }
 public function testRegister()
 {
     $birthday = new Carbon();
     $birthday->addYear(-23);
     $this->visit('/auth/register')->type('user1', 'name')->type('*****@*****.**', 'email')->type('useruser', 'password')->type('useruser', 'password_confirmation')->type($birthday->toDateTimeString(), 'bdate')->select('1', 'gender')->type('2000', 'daily_calories');
     $map = [];
     $restrictions = Restriction::all();
     foreach ($restrictions as $restriction) {
         $val = round(mt_rand() / mt_getrandmax());
         $map[$restriction->id] = $val;
         $this->type($val + 1, 'restriction' . ($restriction->id + 1));
     }
     $this->press('Register')->seePageIs('/home');
     $this->seeInDatabase('users', ['name' => 'user1', 'email' => '*****@*****.**', 'bdate' => $birthday->toDateString(), 'gender' => '0', 'daily_calories' => '2000']);
     $user = \App\User::whereEmail('*****@*****.**')->first();
     foreach ($restrictions as $restriction) {
         if ($map[$restriction->id] == 1) {
             $this->seeInDatabase('restriction_user', ['user_id' => $user->id, 'restriction_id' => $restriction->id]);
         }
     }
 }
Example #4
0
 /**
  * @param array  $earned
  * @param array  $spent
  * @param Carbon $start
  * @param Carbon $end
  *
  * @return array
  */
 protected function multiYearInOut(array $earned, array $spent, Carbon $start, Carbon $end)
 {
     $entries = new Collection();
     while ($start < $end) {
         $incomeSum = $this->pluckFromArray($start->year, $earned);
         $expenseSum = $this->pluckFromArray($start->year, $spent) * -1;
         $entries->push([clone $start, $incomeSum, $expenseSum]);
         $start->addYear();
     }
     $data = $this->generator->multiYearInOut($entries);
     return $data;
 }
 /**
  * @param array  $earned
  * @param array  $spent
  * @param Carbon $start
  * @param Carbon $end
  *
  * @return array
  */
 protected function multiYearInOutSummarized(array $earned, array $spent, Carbon $start, Carbon $end)
 {
     $income = '0';
     $expense = '0';
     $count = 0;
     while ($start < $end) {
         $currentIncome = $this->pluckFromArray($start->year, $earned);
         $currentExpense = $this->pluckFromArray($start->year, $spent);
         $income = bcadd($income, $currentIncome);
         $expense = bcadd($expense, $currentExpense);
         $count++;
         $start->addYear();
     }
     $data = $this->generator->multiYearInOutSummarized($income, $expense, $count);
     return $data;
 }