/**
  *
  * @return int
  */
 public function getCurrentWeekSales()
 {
     $sumReporter = new SumReportFetcher();
     $monday = Carbon::parse('monday this week');
     $sunday = Carbon::parse('sunday this week');
     return $sumReporter->getSumReport((string) $monday, (string) $sunday);
 }
 public function getThisMonthsReport()
 {
     $sumReporter = new SumReportFetcher();
     $firstDayOfMonth = Carbon::parse('first day of this month');
     $lastDayOfMonth = Carbon::parse('last day of this month');
     return $sumReporter->getSumReport((string) $firstDayOfMonth, (string) $lastDayOfMonth);
 }
 public function getAnnualMonthlyReport()
 {
     $reportArr = array('January' => 0, 'February' => 0, 'March' => 0, 'April' => 0, 'May' => 0, 'June' => 0, 'July' => 0, 'August' => 0, 'September' => 0, 'October' => 0, 'November' => 0, 'December' => 0);
     $monthlySalesReporter = new SumReportFetcher();
     foreach ($reportArr as $key => $value) {
         $yearToday = date("Y");
         $dateFromStr = sprintf("first day of %s %s", $key, $yearToday);
         $dateToStr = sprintf("last day of %s %s", $key, $yearToday);
         $dateFrom = (string) Carbon::parse($dateFromStr);
         $dateTo = (string) Carbon::parse($dateToStr);
         $reportArr[$key] = $monthlySalesReporter->getSumReport($dateFrom, $dateTo);
     }
     return $reportArr;
 }
 public function testSumReportThisMonth()
 {
     $this->totalPaid = 0;
     foreach (range(0, 6) as $key => $value) {
         /*insert 5 orders row*/
         $newOrder = new Orders();
         $newOrder->paid = 5000.0;
         $newOrder->order_date = (string) Carbon::parse('wednesday last week');
         if ($newOrder->save(false)) {
             $this->totalPaid += doubleval($newOrder->paid);
         }
     }
     foreach (range(0, 5) as $key => $value) {
         /*insert 5 orders row*/
         $newOrder = new Orders();
         $newOrder->paid = 5000.0;
         $newOrder->order_date = date("Y-m-d H:i:s");
         if ($newOrder->save(false)) {
             $this->totalPaid += doubleval($newOrder->paid);
             $this->insertedOrders[] = $newOrder;
         }
     }
     $sumReporter = new SumReportFetcher();
     $firstDayOfMonth = Carbon::parse('first day of this month');
     $lastDayOfMonth = Carbon::parse('last day of this month');
     $tempContainer = $sumReporter->getSumReport((string) $firstDayOfMonth, (string) $lastDayOfMonth);
     $tempContainer = doubleval($tempContainer);
     $this->assertEquals($tempContainer, $this->totalPaid, "Asserting that the total for this month is equal to my calculated total this month. ");
 }