From 6d4475920b1335da0b3bea9f16bca9dc995ee0f5 Mon Sep 17 00:00:00 2001 From: omair saleh Date: Thu, 29 Sep 2022 03:34:03 +0800 Subject: [PATCH] convert 1688 purchase order to po --- routes/web.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index b77f5a62..285e66b1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -382,8 +382,8 @@ Route::get('/payments/manual', function(){ Route::get('/1688/fix', function(){ $purchaseOrderDocuments = \App\Models\Document::where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get(); + $bookings = []; foreach($purchaseOrderDocuments as $document){ - var_dump($document->owner->marking); foreach($document->files as $file) { $parser = new \Smalot\PdfParser\Parser(); $pdf = $parser->parseFile(Storage::disk('documents')->path($file->file->file_info->original->file)); @@ -392,7 +392,6 @@ Route::get('/1688/fix', function(){ $tables = explode('Amount (yuan)', $text); array_shift($tables); - $purchaseOrder = []; foreach ($tables as $table){ $products = preg_split('/(yuan\/|yuan \/)/', str_replace("\r\n","",$table)); @@ -400,17 +399,17 @@ Route::get('/1688/fix', function(){ foreach ($products as $product){ $product = preg_split('/[\t]/',$product); $type = count($product) === 10 ? 2 : 1; - $purchaseOrder[] = [ + $bookings[$document->owner->marking] = [ '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); } + dd($bookings); });