api changes
This commit is contained in:
parent
291591f3a9
commit
fab61468d2
@ -1246,7 +1246,7 @@ private function cleanVisaData(array $visaDataInput): array
|
|||||||
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
||||||
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
||||||
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
||||||
$rawUidNo = $visaDataInput['uid_no'] ?? null;
|
$rawUidNo = $visaDataInput['uid_no'] ?? $visaDataInput['id_number'] ?? null;
|
||||||
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
||||||
$rawNationality = $visaDataInput['nationality'] ?? null;
|
$rawNationality = $visaDataInput['nationality'] ?? null;
|
||||||
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
||||||
|
|||||||
@ -768,7 +768,7 @@ private function cleanVisaData(array $visaDataInput): array
|
|||||||
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
||||||
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
||||||
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
||||||
$rawUidNo = $visaDataInput['uid_no'] ?? null;
|
$rawUidNo = $visaDataInput['uid_no'] ?? $visaDataInput['id_number'] ?? null;
|
||||||
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
||||||
$rawNationality = $visaDataInput['nationality'] ?? null;
|
$rawNationality = $visaDataInput['nationality'] ?? null;
|
||||||
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
||||||
|
|||||||
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$visaDocuments = \DB::table('worker_documents')->where('type', 'visa')->get();
|
||||||
|
foreach ($visaDocuments as $doc) {
|
||||||
|
$ocrData = json_decode($doc->ocr_data, true);
|
||||||
|
if (is_array($ocrData)) {
|
||||||
|
$cleaned = $this->cleanVisaData($ocrData);
|
||||||
|
\DB::table('worker_documents')->where('id', $doc->id)->update([
|
||||||
|
'ocr_data' => json_encode($cleaned)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Cleaning up or reverting structure is not strictly necessary or possible
|
||||||
|
// since we map legacy fields to modern ones.
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cleanVisaData(array $visaDataInput): array
|
||||||
|
{
|
||||||
|
$rawVisaType = $visaDataInput['visa_type'] ?? null;
|
||||||
|
$rawEntryPermitNo = $visaDataInput['entry_permit_no'] ?? $visaDataInput['file_number'] ?? $visaDataInput['id_number'] ?? $visaDataInput['number'] ?? null;
|
||||||
|
$rawIssueDate = $visaDataInput['issue_date'] ?? null;
|
||||||
|
$rawValidUntil = $visaDataInput['valid_until'] ?? $visaDataInput['expiry_date'] ?? null;
|
||||||
|
$rawUidNo = $visaDataInput['uid_no'] ?? $visaDataInput['id_number'] ?? null;
|
||||||
|
$rawFullName = $visaDataInput['full_name'] ?? $visaDataInput['name'] ?? null;
|
||||||
|
$rawNationality = $visaDataInput['nationality'] ?? null;
|
||||||
|
$rawPlaceOfBirth = $visaDataInput['place_of_birth'] ?? null;
|
||||||
|
$rawDateOfBirth = $visaDataInput['date_of_birth'] ?? $visaDataInput['dob'] ?? null;
|
||||||
|
$rawPassportNo = $visaDataInput['passport_no'] ?? $visaDataInput['passport_number'] ?? null;
|
||||||
|
$rawProfession = $visaDataInput['profession'] ?? null;
|
||||||
|
$rawSponsorName = $visaDataInput['sponsor_name'] ?? null;
|
||||||
|
$rawOcrAccuracy = $visaDataInput['ocr_accuracy'] ?? null;
|
||||||
|
|
||||||
|
// Clean sponsor
|
||||||
|
$sponsorData = $visaDataInput['sponsor'] ?? [];
|
||||||
|
if (is_string($sponsorData)) {
|
||||||
|
$sponsorNameFromObj = $sponsorData;
|
||||||
|
$sponsorAddress = '';
|
||||||
|
$sponsorPhone = '';
|
||||||
|
} else {
|
||||||
|
$sponsorNameFromObj = $sponsorData['name'] ?? $sponsorData['sponsor_name'] ?? $sponsorData['full_name'] ?? '';
|
||||||
|
$sponsorAddress = $sponsorData['address'] ?? '';
|
||||||
|
$sponsorPhone = $sponsorData['phone'] ?? $sponsorData['mobile'] ?? $sponsorData['mobile_number'] ?? $sponsorData['phone_number'] ?? '';
|
||||||
|
}
|
||||||
|
if (empty($rawSponsorName)) {
|
||||||
|
$rawSponsorName = $sponsorNameFromObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'document_type' => 'uae_visa',
|
||||||
|
'country' => 'United Arab Emirates',
|
||||||
|
'visa_type' => $rawVisaType ?: 'ENTRY PERMIT',
|
||||||
|
'entry_permit_no' => $rawEntryPermitNo ?: '',
|
||||||
|
'issue_date' => $rawIssueDate ?: '',
|
||||||
|
'valid_until' => $rawValidUntil ?: '',
|
||||||
|
'uid_no' => $rawUidNo ?: '',
|
||||||
|
'full_name' => $rawFullName ?: '',
|
||||||
|
'nationality' => $rawNationality ?: '',
|
||||||
|
'place_of_birth' => $rawPlaceOfBirth ?: '',
|
||||||
|
'date_of_birth' => $rawDateOfBirth ?: '',
|
||||||
|
'passport_no' => $rawPassportNo ?: '',
|
||||||
|
'profession' => $rawProfession ?: '',
|
||||||
|
'sponsor_name' => $rawSponsorName ?: '',
|
||||||
|
'ocr_accuracy' => $rawOcrAccuracy !== null ? (int)$rawOcrAccuracy : 99,
|
||||||
|
'sponsor' => [
|
||||||
|
'name' => $sponsorNameFromObj ?: '',
|
||||||
|
'address' => $sponsorAddress ?: '',
|
||||||
|
'phone' => $sponsorPhone ?: '',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -1102,92 +1102,85 @@
|
|||||||
},
|
},
|
||||||
"visa": {
|
"visa": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Optional JSON object containing extracted visa details.",
|
"description": "Standardized UAE Visa metadata.",
|
||||||
"properties": {
|
"properties": {
|
||||||
"accompanied_by": {
|
"document_type": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"example": "uae_visa"
|
||||||
},
|
},
|
||||||
"country": {
|
"country": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "United Arab Emirates"
|
"example": "United Arab Emirates"
|
||||||
},
|
},
|
||||||
"date_of_birth": {
|
"visa_type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "25-JUN-1999"
|
"example": "ENTRY PERMIT"
|
||||||
},
|
|
||||||
"document_type": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "uae_visa"
|
|
||||||
},
|
},
|
||||||
"entry_permit_no": {
|
"entry_permit_no": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "77003098 / 2019 / 204"
|
"example": "77003098 / 2019 / 204"
|
||||||
},
|
},
|
||||||
"expiry_date": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "2024-02-15"
|
|
||||||
},
|
|
||||||
"file_number": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"full_name": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "Mr.MUHAMMAD NADEEM RASHEED"
|
|
||||||
},
|
|
||||||
"id_number": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"issue_date": {
|
"issue_date": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "2022-02-16"
|
"example": "2022-02-16"
|
||||||
},
|
},
|
||||||
"name": {
|
"valid_until": {
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"nationality": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "PAKISTAN"
|
"example": "2024-02-15"
|
||||||
},
|
|
||||||
"ocr_accuracy": {
|
|
||||||
"type": "number",
|
|
||||||
"format": "float",
|
|
||||||
"example": 99
|
|
||||||
},
|
|
||||||
"passport_no": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "EN9458281"
|
|
||||||
},
|
|
||||||
"passport_number": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"place_of_birth": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "SIALKOT PAK"
|
|
||||||
},
|
|
||||||
"place_of_issue": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"profession": {
|
|
||||||
"type": "string",
|
|
||||||
"example": "SALES REPRESENTATIVE"
|
|
||||||
},
|
|
||||||
"sponsor": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"sponsor_name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
},
|
||||||
"uid_no": {
|
"uid_no": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "207404887"
|
"example": "207404887"
|
||||||
},
|
},
|
||||||
"valid_until": {
|
"full_name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "04-MAR-2019"
|
"example": "Mr.MUHAMMAD NADEEM RASHEED"
|
||||||
},
|
},
|
||||||
"visa_type": {
|
"nationality": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "ENTRY PERMIT"
|
"example": "PAKISTAN"
|
||||||
|
},
|
||||||
|
"place_of_birth": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "SIALKOT PAK"
|
||||||
|
},
|
||||||
|
"date_of_birth": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "25-JUN-1999"
|
||||||
|
},
|
||||||
|
"passport_no": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "EN9458281"
|
||||||
|
},
|
||||||
|
"profession": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "SALES REPRESENTATIVE"
|
||||||
|
},
|
||||||
|
"sponsor_name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Sponsor Name"
|
||||||
|
},
|
||||||
|
"ocr_accuracy": {
|
||||||
|
"type": "number",
|
||||||
|
"format": "float",
|
||||||
|
"example": 97.4
|
||||||
|
},
|
||||||
|
"sponsor": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Sponsor Name"
|
||||||
|
},
|
||||||
|
"address": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Dubai Marina, Dubai"
|
||||||
|
},
|
||||||
|
"phone": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "2977725"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6648,82 +6641,108 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "uploads/licenses/1234567890_emirates_id.pdf"
|
"example": "uploads/licenses/1234567890_emirates_id.pdf"
|
||||||
},
|
},
|
||||||
|
"license_expiry": {
|
||||||
|
"type": "string",
|
||||||
|
"nullable": true,
|
||||||
|
"example": "2026-05-03"
|
||||||
|
},
|
||||||
|
"validity": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Valid"
|
||||||
|
},
|
||||||
|
"joined_at": {
|
||||||
|
"type": "string",
|
||||||
|
"format": "date-time"
|
||||||
|
},
|
||||||
"fcm_token": {
|
"fcm_token": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "fcm_token_example"
|
"example": "fcm_token_example"
|
||||||
},
|
},
|
||||||
"document_type": {
|
"license": {
|
||||||
"type": "string",
|
"type": "object",
|
||||||
"example": "dubai_commercial_license"
|
"properties": {
|
||||||
},
|
"license_number": {
|
||||||
"country": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "828302"
|
||||||
"example": "United Arab Emirates"
|
},
|
||||||
},
|
"organization_name": {
|
||||||
"authority": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
||||||
"example": "Dubai Economy and Tourism"
|
},
|
||||||
},
|
"expiry_date": {
|
||||||
"license_no": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "2026-05-03"
|
||||||
"example": "828302"
|
},
|
||||||
},
|
"document_type": {
|
||||||
"company_name": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "dubai_commercial_license"
|
||||||
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
},
|
||||||
},
|
"country": {
|
||||||
"business_name": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "United Arab Emirates"
|
||||||
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
},
|
||||||
},
|
"authority": {
|
||||||
"license_category": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "Dubai Economy and Tourism"
|
||||||
"example": "Dep. of Economic Development"
|
},
|
||||||
},
|
"license_no": {
|
||||||
"legal_type": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "828302"
|
||||||
"example": "Limited Liability Company Single Owner(LLC- - SO)"
|
},
|
||||||
},
|
"company_name": {
|
||||||
"issue_date": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
||||||
"example": "06/03/2019"
|
},
|
||||||
},
|
"business_name": {
|
||||||
"expiry_date": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "MSJ INTERNATIONAL TECHNICAL SERVICES L.L.C"
|
||||||
"example": "05/03/2026"
|
},
|
||||||
},
|
"license_category": {
|
||||||
"main_license_no": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "Dep. of Economic Development"
|
||||||
"example": "828302"
|
},
|
||||||
},
|
"legal_type": {
|
||||||
"register_no": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "Limited Liability Company Single Owner(LLC- - SO)"
|
||||||
"example": "1656486"
|
},
|
||||||
},
|
"issue_date": {
|
||||||
"dcci_no": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "06/03/2019"
|
||||||
"example": "317412"
|
},
|
||||||
},
|
"main_license_no": {
|
||||||
"members": {
|
"type": "string",
|
||||||
"type": "array",
|
"example": "828302"
|
||||||
"items": {
|
},
|
||||||
"type": "object",
|
"register_no": {
|
||||||
"properties": {
|
"type": "string",
|
||||||
"person_no": {
|
"example": "1656486"
|
||||||
"type": "string",
|
},
|
||||||
"example": "752967"
|
"dcci_no": {
|
||||||
},
|
"type": "string",
|
||||||
"name": {
|
"example": "317412"
|
||||||
"type": "string",
|
},
|
||||||
"example": "Lo lo wallus issued in"
|
"members": {
|
||||||
},
|
"type": "array",
|
||||||
"nationality": {
|
"items": {
|
||||||
"type": "string",
|
"type": "object",
|
||||||
"example": "India"
|
"properties": {
|
||||||
},
|
"person_no": {
|
||||||
"role": {
|
"type": "string",
|
||||||
"type": "string",
|
"example": "752967"
|
||||||
"example": "Shares Owner Who"
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Lo lo wallus issued in"
|
||||||
|
},
|
||||||
|
"nationality": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "India"
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "Shares Owner Who"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -531,9 +531,13 @@ public function test_register_passport_and_visa_with_direct_json_payload()
|
|||||||
|
|
||||||
$visaDoc = \App\Models\WorkerDocument::where('worker_id', $workerId)->where('type', 'visa')->first();
|
$visaDoc = \App\Models\WorkerDocument::where('worker_id', $workerId)->where('type', 'visa')->first();
|
||||||
$this->assertNotNull($visaDoc->ocr_data);
|
$this->assertNotNull($visaDoc->ocr_data);
|
||||||
$this->assertEquals('784198839607839', $visaDoc->ocr_data['id_number']);
|
$this->assertEquals('784198839607839', $visaDoc->ocr_data['uid_no']);
|
||||||
$this->assertEquals('CLEANER', $visaDoc->ocr_data['profession']);
|
$this->assertEquals('CLEANER', $visaDoc->ocr_data['profession']);
|
||||||
$this->assertEquals('Sponsor Name', $visaDoc->ocr_data['sponsor']);
|
$this->assertEquals([
|
||||||
|
'name' => 'Sponsor Name',
|
||||||
|
'address' => '',
|
||||||
|
'phone' => '',
|
||||||
|
], $visaDoc->ocr_data['sponsor']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -630,7 +634,7 @@ public function test_register_visa_with_full_ocr_fields()
|
|||||||
$this->assertEquals('uae_visa', $visaDoc->ocr_data['document_type']);
|
$this->assertEquals('uae_visa', $visaDoc->ocr_data['document_type']);
|
||||||
$this->assertEquals('ENTRY PERMIT', $visaDoc->ocr_data['visa_type']);
|
$this->assertEquals('ENTRY PERMIT', $visaDoc->ocr_data['visa_type']);
|
||||||
$this->assertEquals('Mr.MUHAMMAD NADEEM RASHEED', $visaDoc->ocr_data['full_name']);
|
$this->assertEquals('Mr.MUHAMMAD NADEEM RASHEED', $visaDoc->ocr_data['full_name']);
|
||||||
$this->assertEquals(97.4, $visaDoc->ocr_data['ocr_accuracy']);
|
$this->assertEquals(97.4, $visaDoc->ocr_accuracy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user