From 7bf94082fed0915e0fadb103f9c05dcf2e2f9df3 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 29 Sep 2022 03:21:08 +0800 Subject: [PATCH] convert 1688 purchase order to po --- routes/web.php | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/routes/web.php b/routes/web.php index 584bd455..fb3dc155 100644 --- a/routes/web.php +++ b/routes/web.php @@ -380,38 +380,11 @@ 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(); 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);