convert 1688 purchase order to po

This commit is contained in:
omair saleh
2022-09-29 03:34:03 +08:00
parent c50b84d440
commit 6d4475920b
+3 -4
View File
@@ -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);
});