mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-22 14:04:01 +00:00
convert 1688 purchase order to po
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user