From 0d2dc1ba0dfb3c46edfb80f961838b756be2d97e Mon Sep 17 00:00:00 2001 From: Omair Saleh Date: Thu, 29 Sep 2022 04:18:04 +0800 Subject: [PATCH] convert 1688 purchase orders to po --- routes/web.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/routes/web.php b/routes/web.php index 5b7f93f5..6aadda47 100644 --- a/routes/web.php +++ b/routes/web.php @@ -403,11 +403,14 @@ Route::get('/1688/fix', function(){ array_pop($products); foreach ($products as $product){ $product = preg_split('/[\t]/',$product); - $type = count($product) === 10 ? 2 : 1; + + $adjuster = (count($product) - 7); + $descriptionIndex = 3 + $adjuster; + $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]) + 'description' => str_replace("\n","",$product[$descriptionIndex]), + 'quantity' => (int) str_replace("\n","",$product[$descriptionIndex + 2]), + 'unit_price' => (float) str_replace("\n","",$product[$descriptionIndex + 3]) ]; } }