Merge pull request 'Updated invoice import functionality to allow unique record' (#422) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 18s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 18s
Reviewed-on: #422
This commit was merged in pull request #422.
This commit is contained in:
@@ -322,8 +322,13 @@ class InvoiceValidationImporter extends Importer
|
|||||||
$curPanelBoxSerialNumber = null;
|
$curPanelBoxSerialNumber = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$record = InvoiceValidation::where('serial_number', $serialNumber)
|
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
|
||||||
->where('plant_id', $plantId)
|
|
||||||
|
if ($record && $record->sticker_master_id != $stickId) {
|
||||||
|
$stickId = null;
|
||||||
|
$warnMsg[] = 'Item code mismatch with existing record!';
|
||||||
|
} elseif ($record) {
|
||||||
|
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)
|
||||||
->whereHas('stickerMasterRelation.item', function ($query) use ($plantId, $iCode) {
|
->whereHas('stickerMasterRelation.item', function ($query) use ($plantId, $iCode) {
|
||||||
$query->where('plant_id', $plantId)->where('code', $iCode);
|
$query->where('plant_id', $plantId)->where('code', $iCode);
|
||||||
})
|
})
|
||||||
@@ -338,28 +343,32 @@ class InvoiceValidationImporter extends Importer
|
|||||||
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
$hadPumpSetQr = $record->scanned_status_set ?? null;
|
||||||
$hadCapacitorQr = $record->capacitor_scanned_status ?? null;
|
$hadCapacitorQr = $record->capacitor_scanned_status ?? null;
|
||||||
|
|
||||||
if ($hadMotorQr) {
|
if ($hadMotorQr && $hasMotorQr) {
|
||||||
$curMotorQr = $hadMotorQr;
|
$curMotorQr = $hadMotorQr;
|
||||||
}
|
}
|
||||||
if ($hadPumpQr) {
|
if ($hadPumpQr && $hasPumpQr) {
|
||||||
$curPumpQr = $hadPumpQr;
|
$curPumpQr = $hadPumpQr;
|
||||||
}
|
}
|
||||||
if ($hadPumpSetQr) {
|
if ($hadPumpSetQr && $hasPumpSetQr) {
|
||||||
$curPumpSetQr = $hadPumpSetQr;
|
$curPumpSetQr = $hadPumpSetQr;
|
||||||
}
|
}
|
||||||
if ($hadCapacitorQr) {
|
if ($hadCapacitorQr && $hasCapacitorQr) {
|
||||||
$curCapacitorQr = $hadCapacitorQr;
|
$curCapacitorQr = $hadCapacitorQr;
|
||||||
$curPanelBoxCode = $record->panel_box_code ?? null;
|
$curPanelBoxCode = $record->panel_box_code ?? null;
|
||||||
$curPanelBoxSupplier = $record->panel_box_supplier ?? null;
|
$curPanelBoxSupplier = $record->panel_box_supplier ?? null;
|
||||||
$curPanelBoxSerialNumber = $record->panel_box_serial_number ?? null;
|
$curPanelBoxSerialNumber = $record->panel_box_serial_number ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($record->scanned_status == 'Scanned') {
|
$warnMsg[] = 'Record Item ID : '.$record->sticker_master_id.' Master Item ID : '.$stickId;
|
||||||
return null;
|
if ($record->invoice_number != $invoiceNumber) {
|
||||||
} elseif ($record->invoice_number != $invoiceNumber) {
|
$stickId = null;
|
||||||
throw new RowImportFailedException('Invoice number mismatch with existing record!');
|
$warnMsg[] = 'Invoice number mismatch with existing record!';
|
||||||
}
|
// throw new RowImportFailedException('Invoice number mismatch with existing record!');
|
||||||
|
} elseif ($record->scanned_status == 'Scanned') {
|
||||||
|
$stickId = null;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
// if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
// if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
|
||||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||||
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||||
@@ -384,6 +393,8 @@ class InvoiceValidationImporter extends Importer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($stickId) {
|
if ($stickId) {
|
||||||
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
$formats = ['d-m-Y H:i', 'd-m-Y H:i:s']; // '07-05-2025 08:00' or '07-05-2025 08:00:00'
|
||||||
@@ -426,6 +437,7 @@ class InvoiceValidationImporter extends Importer
|
|||||||
throw new RowImportFailedException(implode(', ', $warnMsg));
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($stickId) {
|
||||||
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
if ($hasMotorQr || $hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
|
||||||
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
$scanCnt = $curMotorQr ? $scanCnt + 1 : $scanCnt;
|
||||||
$scanCnt = $curPumpQr ? $scanCnt + 1 : $scanCnt;
|
$scanCnt = $curPumpQr ? $scanCnt + 1 : $scanCnt;
|
||||||
@@ -465,6 +477,7 @@ class InvoiceValidationImporter extends Importer
|
|||||||
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
'created_at' => $cDateTime->format('Y-m-d H:i:s'),
|
||||||
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
'updated_at' => $uDateTime->format('Y-m-d H:i:s'),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
// return new InvoiceValidation;
|
// return new InvoiceValidation;
|
||||||
|
|||||||
Reference in New Issue
Block a user