Merge pull request 'removed unwanted serial validation mail logic in invoice validation' (#85) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s

Reviewed-on: #85
This commit was merged in pull request #85.
This commit is contained in:
2025-12-09 05:21:01 +00:00
2 changed files with 78 additions and 96 deletions

View File

@@ -3171,9 +3171,11 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name']; $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; $emails = $mailData['emails'];
$mUserName = Filament::auth()->user()->name;
if (! empty($emails)) { if (! empty($emails)) {
Mail::to($emails)->send( Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundInvoice') new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,$mUserName,'NotFoundInvoice')
); );
} else { } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
@@ -3379,18 +3381,18 @@ class CreateInvoiceValidation extends CreateRecord
->send(); ->send();
$this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial'; // $mInvoiceType = 'Serial';
$mailData = $this->getMail(); // $mailData = $this->getMail();
$mPlantName = $mailData['plant_name']; // $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; // $emails = $mailData['emails'];
if (! empty($emails)) { // if (! empty($emails)) {
Mail::to($emails)->send( // Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice') // new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice')
); // );
} else { // } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); // \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
} // }
$filename = $invoiceNumber.'.xlsx'; $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';
@@ -3509,19 +3511,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial'; // $mInvoiceType = 'Serial';
$mailData = $this->getMail(); // $mailData = $this->getMail();
$mPlantName = $mailData['plant_name']; // $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; // $emails = $mailData['emails'];
if (! empty($emails)) { // if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( // Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice') // new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice')
); // );
} else { // } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); // \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
} // }
$filename = $invoiceNumber.'.xlsx'; $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';
@@ -3582,19 +3584,21 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound'); $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial'; // $mInvoiceType = 'Serial';
$mailData = $this->getMail(); // $mailData = $this->getMail();
$mPlantName = $mailData['plant_name']; // $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; // $emails = $mailData['emails'];
if (! empty($emails)) { // $mUserName = Filament::auth()->user()->name;
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( // if (! empty($emails)) {
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateCapacitorQR') // // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
); // Mail::to($emails)->send(
} else { // new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, $mUserName, 'DuplicateCapacitorQR')
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); // );
} // } else {
// \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
// }
$this->form->fill([ $this->form->fill([
'plant_id' => $plantId, 'plant_id' => $plantId,
@@ -3719,19 +3723,19 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound'); $this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial'; // $mInvoiceType = 'Serial';
$mailData = $this->getMail(); // $mailData = $this->getMail();
$mPlantName = $mailData['plant_name']; // $mPlantName = $mailData['plant_name'];
$emails = $mailData['emails']; // $emails = $mailData['emails'];
if (! empty($emails)) { // if (! empty($emails)) {
// Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType)); // // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send( // Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv') // new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
); // );
} else { // } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial."); // \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
} // }
$filename = $invoiceNumber.'.xlsx'; $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp'; $directory = 'uploads/temp';

View File

@@ -82,12 +82,14 @@ class InvalidSerialMail extends Mailable
public $greeting; public $greeting;
public $subjectLine; public $subjectLine;
public $mUserName;
public $itemCode; public $itemCode;
/** /**
* Create a new message instance. * Create a new message instance.
*/ */
public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mailType = 'InvalidFormat') public function __construct($serial, $invoiceNumber, $mplantName, $mInvoiceType, $itemCode, $mUserName, $mailType = 'InvalidFormat')
{ {
$this->serial = $serial; $this->serial = $serial;
$this->invoiceNumber = $invoiceNumber; $this->invoiceNumber = $invoiceNumber;
@@ -95,6 +97,7 @@ class InvalidSerialMail extends Mailable
$this->mInvoiceType = $mInvoiceType; $this->mInvoiceType = $mInvoiceType;
$this->mailType = $mailType; $this->mailType = $mailType;
$this->itemCode = $itemCode; $this->itemCode = $itemCode;
$this->mUserName = $mUserName;
} }
/** /**
@@ -110,15 +113,18 @@ class InvalidSerialMail extends Mailable
case 'DuplicateCapacitorQR': case 'DuplicateCapacitorQR':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})"; $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break; break;
case 'CompletedSerialInvoice': case 'InvalidPanelBox':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'CSerialInvoice':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break;
case 'ComSerInv':
$this->subjectLine = "Invoice - Second Scanning({$this->mplantName})"; $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
break; break;
// case 'CompletedSerialInvoice':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
// case 'CSerialInvoice':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
// case 'ComSerInv':
// $this->subjectLine = "Invoice - Second Scanning({$this->mplantName})";
// break;
} }
return new Envelope( return new Envelope(
@@ -141,48 +147,20 @@ class InvalidSerialMail extends Mailable
<b>Invoice Type:</b> {$this->mInvoiceType}<br> <b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br> <b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br> <b>Scanned QR Code:</b> {$this->serial}<br>
<b>Employee Code:</b> {$this->mUserName}<br>
"; ";
break; break;
case 'DuplicateCapacitorQR': // case 'DuplicateCapacitorQR':
$this->greeting = " // $this->greeting = "
Dear Sir/Madam,<br><br> // Dear Sir/Madam,<br><br>
The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br> // The scanned <b>Capacitor</b> serial number has already completed the scanning process.<br><br>
<b>Plant:</b> {$this->mplantName}<br> // <b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br> // <b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br> // <b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br> // <b>Scanned QR Code:</b> {$this->serial}<br>
"; // <b>Employee Code:</b> {$this->mUserName}<br>
break; // ";
case 'CompletedSerialInvoice': // break;
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'CSerialInvoice':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
case 'ComSerInv':
$this->greeting = "
Dear Sir/Madam,<br><br>
Serial invoice <b>'{$this->invoiceNumber}'</b> completed the scanning process.<br>
<b>Plant:</b> {$this->mplantName}<br>
<b>Invoice Type:</b> {$this->mInvoiceType}<br>
<b>Invoice Number:</b> {$this->invoiceNumber}<br>
<b>Scanned QR Code:</b> {$this->serial}<br>
";
break;
} }
return new Content( return new Content(