convert 1688 purchase order to po

This commit is contained in:
omair saleh
2022-09-29 03:17:22 +08:00
parent e16b325036
commit 00ff3750dd
2 changed files with 39 additions and 13 deletions
+6 -5
View File
@@ -17,12 +17,13 @@
"doctrine/dbal": "^2.12.1",
"fideloper/proxy": "^4.2",
"fruitcake/laravel-cors": "^1.0",
"guzzlehttp/guzzle": "^6.3",
"guzzlehttp/guzzle": "^7.0.1",
"intervention/image": "^2.5",
"laravel/framework": "^7.0",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.0",
"maatwebsite/excel": "^3.1",
"rinvex/countries": "^6.1",
"smalot/pdfparser": "^2.2",
"spatie/laravel-activitylog": "^3.14",
"spatie/laravel-permission": "^3.17",
"staudenmeir/eloquent-has-many-deep": "^1.7",
@@ -31,12 +32,12 @@
"webklex/laravel-pdfmerger": "^1.3"
},
"require-dev": {
"facade/ignition": "^2.0",
"facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.9.1",
"laravel/dusk": "^6.23",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5"
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0"
},
"config": {
"optimize-autoloader": true,
+33 -8
View File
@@ -380,16 +380,41 @@ Route::get('/payments/manual', function(){
});
Route::get('/1688/fix', function(){
$transactions = Transaction::where('type', TransactionType::PURCHASE_ORDER)->where('bill_no', 'like', 'XPO-%')->whereHas('booking', function($query){
return $query->where('service_id', 4)->where('status', 2);
});
$transactions->delete();
// $purchaseOrderDocuments = \App\Models\Document::where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get();
// $transactions = Transaction::where('type', TransactionType::PURCHASE_ORDER)->where('bill_no', 'like', 'XPO-%')->whereHas('booking', function($query){
// return $query->where('service_id', 4)->where('status', 2);
// });
//
// foreach($purchaseOrderDocuments as $document){
// $transactions->delete();
$purchaseOrderDocuments = \App\Models\Document::where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get();
foreach($purchaseOrderDocuments as $document){
foreach($document->files as $file) {
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile($file>file->file_info->original->file);
$text = $pdf->getText();
$tables = explode('Amount (yuan)', $text);
array_shift($tables);
$purchaseOrder = [];
foreach ($tables as $table){
$products = preg_split('/(yuan\/|yuan \/)/', str_replace("\r\n","",$table));
array_pop($products);
foreach ($products as $product){
$product = preg_split('/[\t]/',$product);
$type = count($product) === 10 ? 2 : 1;
$purchaseOrder[] = [
'description' => str_replace("\n","",$product[$type === 2 ? 6 : 3]),
'quantity' => (int) str_replace("\n","",$product[$type === 2 ? 8 : 5]),
'unit_price' => (float) str_replace("\n","",$product[$type === 2 ? 9 : 6])
];
}
}
dd($purchaseOrder = []);
}
// if($document->owner->status === ApprovalStatus::COMPLETED) continue;
// (App()->make(createPurchaseOrderFor1688OrderProcessor::class))->execute($document->owner);
// }
}
});