2 Commits

Author SHA1 Message Date
c7f4f49669 Merge pull request 'Added remark column for invoice data report' (#196) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #196
2026-01-20 04:57:05 +00:00
dhanabalan
cf7e0294c4 Added remark column for invoice data report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 2m59s
Laravel Larastan / larastan (pull_request) Failing after 4m6s
2026-01-20 10:26:38 +05:30
2 changed files with 10 additions and 13 deletions

View File

@@ -6,12 +6,8 @@ use App\Mail\InvoiceDataMail;
use App\Models\AlertMailRule; use App\Models\AlertMailRule;
use App\Models\InvoiceDataValidation; use App\Models\InvoiceDataValidation;
use App\Models\InvoiceOutValidation; use App\Models\InvoiceOutValidation;
use App\Models\Line;
use App\Models\Plant; use App\Models\Plant;
use App\Models\ProductionPlan;
use App\Models\ProductionQuantity;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class SendInvoiceDataReport extends Command class SendInvoiceDataReport extends Command
{ {
@@ -49,7 +45,7 @@ class SendInvoiceDataReport extends Command
$plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get(); $plants = ($plantId == 0) ? Plant::all() : Plant::where('id', $plantId)->get();
if ($plants->isEmpty()) { if ($plants->isEmpty()) {
$this->error("No valid plant(s) found."); $this->error('No valid plant(s) found.');
return; return;
} }
@@ -105,7 +101,7 @@ class SendInvoiceDataReport extends Command
->where('distribution_channel_desc', $selectedDistribution) ->where('distribution_channel_desc', $selectedDistribution)
->whereBetween('document_date', [$startDate, $endDate]) ->whereBetween('document_date', [$startDate, $endDate])
->orderBy('document_date', 'asc') ->orderBy('document_date', 'asc')
->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location') ->select('customer_code', 'document_number', 'document_date', 'customer_trade_name', 'customer_location', 'location', 'remark')
->get() ->get()
->unique('document_number') ->unique('document_number')
->values(); ->values();
@@ -114,7 +110,6 @@ class SendInvoiceDataReport extends Command
continue; continue;
} }
// Filter invoices directly — exclude ones with '-' in document_number
$invoices = $invoices->filter(function ($inv) { $invoices = $invoices->filter(function ($inv) {
return !empty($inv->document_number) && !str_contains($inv->document_number, '-'); return !empty($inv->document_number) && !str_contains($inv->document_number, '-');
}); });
@@ -134,7 +129,6 @@ class SendInvoiceDataReport extends Command
->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n))) ->map(fn($n) => preg_replace('/\s+/', '', strtoupper((string) $n)))
->toArray(); ->toArray();
//where('plant_id', $plant->id)
$wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers) $wentOutInvoices = InvoiceOutValidation::whereIn('qr_code', $invoiceNumbers)
//->whereBetween('scanned_at', [$startDate, $endDate]) //->whereBetween('scanned_at', [$startDate, $endDate])
->distinct('qr_code') ->distinct('qr_code')
@@ -164,7 +158,6 @@ class SendInvoiceDataReport extends Command
return !in_array($doc, $wentOutInvoices, true); return !in_array($doc, $wentOutInvoices, true);
}); });
if ($pendingInvoices->isEmpty()) { if ($pendingInvoices->isEmpty()) {
continue; continue;
} }
@@ -182,7 +175,7 @@ class SendInvoiceDataReport extends Command
} }
$tableData[] = [ $tableData[] = [
//'no' => $no++, // 'no' => $no++,
'plant' => $plant->name, 'plant' => $plant->name,
// 'distribution_type' => $selectedDistribution, // 'distribution_type' => $selectedDistribution,
'customer_code' => $inv->customer_code, 'customer_code' => $inv->customer_code,
@@ -194,6 +187,7 @@ class SendInvoiceDataReport extends Command
'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)), 'no_of_days_pending' => abs((int)now()->diffInDays($documentDate)),
'status' => 'Pending', 'status' => 'Pending',
'status_class' => $statusColor, 'status_class' => $statusColor,
'remark' => $inv->remark,
]; ];
} }
} }
@@ -203,6 +197,7 @@ class SendInvoiceDataReport extends Command
->values() ->values()
->map(function ($item, $index) { ->map(function ($item, $index) {
$item['no'] = $index + 1; $item['no'] = $index + 1;
return $item; return $item;
}) })
->toArray(); ->toArray();
@@ -214,7 +209,7 @@ class SendInvoiceDataReport extends Command
$this->info($contentVars['greeting'] ?? 'Invoice Data Report'); $this->info($contentVars['greeting'] ?? 'Invoice Data Report');
$this->table( $this->table(
['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status'],//'Distribution Type' ['No', 'Plant', 'Customer Code', 'Document Number', 'Document Date', 'Trade Name', 'Location', 'Pending Days', 'Status', 'Remark'],// 'Distribution Type'
$tableData $tableData
); );
$this->info($contentVars['wishes'] ?? ''); $this->info($contentVars['wishes'] ?? '');
@@ -236,13 +231,13 @@ class SendInvoiceDataReport extends Command
->toArray(); ->toArray();
if (empty($toEmails)) { if (empty($toEmails)) {
$this->warn("Skipping rule ID {$rule->id} — no valid To emails found."); $this->info("Skipping rule ID {$rule->id} — no valid To emails found.");
continue; continue;
} }
\Mail::to($toEmails)->cc($ccEmails)->send($mail); \Mail::to($toEmails)->cc($ccEmails)->send($mail);
$this->info("Mail sent for rule ID {$rule->id} → To: " . implode(', ', $toEmails) . ($ccEmails ? " | CC: " . implode(', ', $ccEmails) : '')); $this->info("Mail sent for rule ID {$rule->id} → To: ".implode(', ', $toEmails).($ccEmails ? ' | CC: '.implode(', ', $ccEmails) : ''));
} }
} }
} }

View File

@@ -88,6 +88,7 @@
<th>Location</th> <th>Location</th>
<th>Pending Days</th> <th>Pending Days</th>
<th>Status</th> <th>Status</th>
<th>Remark</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -117,6 +118,7 @@
<td class="{{ $row['status_class'] ?? '' }}"> <td class="{{ $row['status_class'] ?? '' }}">
{{ $row['status'] }} {{ $row['status'] }}
</td> </td>
<td>{{ $row['remark'] ?? '-'}}</td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>