M3 Integration fixes

This commit is contained in:
Mark Gregory
2026-09-21 13:33:05 +01:00
parent 3521e47ef0
commit 66aeefbba5
23 changed files with 674 additions and 691 deletions
+23 -33
View File
@@ -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