firstOfMonth()->toDateString(); $lastDayOfYear = Carbon::parse($lastAllOfYear)->firstOfMonth()->toDateString(); $diffInPeriod = Carbon::parse($startDayOfYear)->diffInMonths(Carbon::parse($lastDayOfYear)); $periodList = []; for ($i = 0; $i < $diffInPeriod; $i++) { $periodList[] = Carbon::parse($firstAllOfYear)->addMonths($i)->format('Y-m'); }*/ //$periodList[] = '2025-09'; //BULK //$invoiceWithPeriod = $propertyInvoiceService->invoiceWithPeriod(623, '2025-10'); //dd($invoiceWithPeriod); //$periodList = ['2025-09']; //$lastOfMonth = '2025-10-30'; //$dayOfMonth = '2025-10-30'; //$lastOfMonth = Carbon::now()->lastOfMonth()->format('Y-m-d'); //$dayOfMonth = Carbon::now()->format('Y-m-d'); //if ($lastOfMonth != $dayOfMonth) { //$this->alert(date('Y-m-d H:i:s') . ' : ' . $lastOfMonth . ' - ' . $dayOfMonth); //return false; //} //$period = Carbon::parse($dayOfMonth)->lastOfMonth()->format('Y-m'); //$periodList = [$period]; $year = Carbon::now()->year; $currentMonth = Carbon::now()->month; $periodList = []; for ($month = $currentMonth; $month <= 12; $month++) { $periodList[] = Carbon::create($year, $month, 1)->format('Y-m'); } //$periodList = ['2025-03']; $this->info(date('Y-m-d H:i:s') . ' START'); $propertyList = Property::where('commission', '>', 1) ->where('status', 1) //->whereIn('id', [71]) ->get()->toArray(); $types[1] = 'Checkout'; $types[2] = 'Transaction'; foreach ($periodList as $period) { $this->alert('PERIOD: ' . $period); foreach ($propertyList as $property) { try { foreach ($types as $typeCode => $type) { $invoiceWithPeriod = $propertySummaryService->summaryWithPeriod($property['id'], $period, $typeCode); if ($invoiceWithPeriod['status'] == 'success') { $this->info(date('Y-m-d H:i:s') . ': ' . $period . ' ' . $property['id'] . ' - ' . $property['name'] . ' : ' . $type . ' : ' . $period . ' - ' . $invoiceWithPeriod['data']['total'] . ' ' . $invoiceWithPeriod['data']['currency']); } else { $this->error(date('Y-m-d H:i:s') . ': ' . $period . ' ' . $property['id'] . ' - ' . $invoiceWithPeriod['message']); } } } catch (ApiErrorException | Exception $e) { $this->error(date('Y-m-d H:i:s') . ' ERROR: L: ' . $e->getLine() . ' - ' . $e->getMessage() . ' - ' . $property['id'] . ' - ' . $property['name']); } } } $this->info(date('Y-m-d H:i:s') . ' FINISHED'); } }