M3 Integration fixes
This commit is contained in:
@@ -87,16 +87,13 @@ class ClosedOrderSaveXls extends Command
|
||||
: $warehouse . '/Closedorderlinesreport_' . $from . '-' . $to . '-' . $warehouse . self::XLSX_EXTENSION;
|
||||
|
||||
$this->info('Generate Last Month Report...');
|
||||
$this->generateReport(
|
||||
$company,
|
||||
$warehouse,
|
||||
$plant,
|
||||
str_replace('-', '', $from),
|
||||
str_replace('-', '', $to),
|
||||
$file,
|
||||
! Storage::disk('publicCL')->exists($file),
|
||||
'Last Month',
|
||||
);
|
||||
$this->generateReport($company, $warehouse, $plant, [
|
||||
'from' => str_replace('-', '', $from),
|
||||
'to' => str_replace('-', '', $to),
|
||||
'file' => $file,
|
||||
'shouldGenerate' => ! Storage::disk('publicCL')->exists($file),
|
||||
'label' => 'Last Month',
|
||||
]);
|
||||
}
|
||||
|
||||
private function generateCurrentMonthReport(string $company, string $warehouse, string $plant): void
|
||||
@@ -109,47 +106,40 @@ class ClosedOrderSaveXls extends Command
|
||||
: $warehouse . '/first_of_month_to_current_date_' . $warehouse . self::XLSX_EXTENSION;
|
||||
|
||||
$this->info('Generate Current Month Report...');
|
||||
$this->generateReport(
|
||||
$company,
|
||||
$warehouse,
|
||||
$plant,
|
||||
str_replace('-', '', $from),
|
||||
str_replace('-', '', $to),
|
||||
$file,
|
||||
true,
|
||||
'Current Month',
|
||||
);
|
||||
$this->generateReport($company, $warehouse, $plant, [
|
||||
'from' => str_replace('-', '', $from),
|
||||
'to' => str_replace('-', '', $to),
|
||||
'file' => $file,
|
||||
'shouldGenerate' => true,
|
||||
'label' => 'Current Month',
|
||||
]);
|
||||
}
|
||||
|
||||
private function generateReport(
|
||||
string $company,
|
||||
string $warehouse,
|
||||
string $plant,
|
||||
string $from,
|
||||
string $to,
|
||||
string $file,
|
||||
bool $shouldGenerate,
|
||||
string $label,
|
||||
array $report,
|
||||
): void {
|
||||
$this->info('From Date: ' . $from);
|
||||
$this->info('To Date: ' . $to);
|
||||
$this->info('From Date: ' . $report['from']);
|
||||
$this->info('To Date: ' . $report['to']);
|
||||
|
||||
if (! $shouldGenerate || ! $this->hasReportScope($company, $warehouse, $plant)) {
|
||||
if (! $report['shouldGenerate'] || ! $this->hasReportScope($company, $warehouse, $plant)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = $this->closedOrderRows($company, $warehouse, $plant, $from, $to);
|
||||
$rows = $this->closedOrderRows($company, $warehouse, $plant, $report['from'], $report['to']);
|
||||
if ($rows->isEmpty()) {
|
||||
Log::channel('dailyCron')->info($label . ' report, no records found: Nothing to save...');
|
||||
Log::channel('dailyCron')->info($report['label'] . ' report, no records found: Nothing to save...');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$rows->prepend($this->headers());
|
||||
$this->logRecordLimit($rows->count());
|
||||
$this->info('Saving ' . $label . ' Excel Report to Disk');
|
||||
Log::channel('dailyCron')->info('Saving ' . $label . ' Excel Report to Disk');
|
||||
app(SpreadsheetExport::class)->store($rows, $file, 'publicCL');
|
||||
$this->info('Saving ' . $report['label'] . ' Excel Report to Disk');
|
||||
Log::channel('dailyCron')->info('Saving ' . $report['label'] . ' Excel Report to Disk');
|
||||
app(SpreadsheetExport::class)->store($rows, $report['file'], 'publicCL');
|
||||
}
|
||||
|
||||
private function hasReportScope(string $company, string $warehouse, string $plant): bool
|
||||
|
||||
Reference in New Issue
Block a user