Add file handling for invoice processing and cleanup in LocatorInvoiceValidation
This commit is contained in:
@@ -88,6 +88,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
|
||||
$folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH')
|
||||
->where('plant_id', $plantId)
|
||||
->value('c_value');
|
||||
|
||||
$fullFolderPath = "uploads/$folderPath";
|
||||
|
||||
$directory = $fullFolderPath;
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory . '/' . $filename;
|
||||
|
||||
try
|
||||
{
|
||||
// $record1 = LocatorInvoiceValidation::query()
|
||||
@@ -117,6 +129,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -261,9 +277,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath)) {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -290,9 +306,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath)) {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -351,10 +367,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath))
|
||||
// {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -432,10 +448,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath))
|
||||
// {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
@@ -585,9 +601,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath)) {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -614,10 +630,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath))
|
||||
// {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -677,9 +693,9 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath)) {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -736,10 +752,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(800)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
// if ($disk->exists($filePath))
|
||||
// {
|
||||
// $disk->delete($filePath);
|
||||
// }
|
||||
|
||||
$snoCount = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->count();
|
||||
|
||||
@@ -858,6 +874,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
|
||||
$UnknownSerialNumbers = [];
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
|
||||
$folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH')
|
||||
->where('plant_id', $plantId)
|
||||
->value('c_value');
|
||||
|
||||
$fullFolderPath = "uploads/$folderPath";
|
||||
|
||||
$directory = $fullFolderPath;
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory . '/' . $filename;
|
||||
|
||||
$invExist = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->first();
|
||||
if (!$invExist)
|
||||
{
|
||||
@@ -907,6 +935,10 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1206,6 +1238,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1304,6 +1341,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1376,6 +1418,18 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
|
||||
$InvoiceSerialNumber = '';
|
||||
|
||||
$filename = $invoiceNumber . '.xlsx';
|
||||
|
||||
$folderPath = Configuration::where('c_name', 'INVOICE_FOLDER_PATH')
|
||||
->where('plant_id', $plantId)
|
||||
->value('c_value');
|
||||
|
||||
$fullFolderPath = "uploads/$folderPath";
|
||||
|
||||
$directory = $fullFolderPath;
|
||||
$disk = Storage::disk('local');
|
||||
$filePath = $directory . '/' . $filename;
|
||||
|
||||
$invExist = LocatorInvoiceValidation::where('plant_id', $plantId)->where('invoice_number', $invoiceNumber)->first();
|
||||
if (!$invExist)
|
||||
{
|
||||
@@ -1424,6 +1478,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
@@ -1716,6 +1775,11 @@ class CreateLocatorInvoiceValidation extends CreateRecord
|
||||
->duration(1000)
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath))
|
||||
{
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
|
||||
$this->dispatch('loadData', '', $plantId);
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
|
||||
Reference in New Issue
Block a user