diff --git a/routes/web.php b/routes/web.php index 2b779516..c3330f65 100644 --- a/routes/web.php +++ b/routes/web.php @@ -408,3 +408,24 @@ Route::get('/1688/fix/{reference}', function($reference){ // } })->name('ecommerce.fix'); +Route::get('/po/manual/fix', function($reference){ + + $purchaseOrders = Transaction::where('type', TransactionType::PURCHASE_ORDER)->where('owner', function($query){ + return $query->whereIn('company_id', [199, 510])->whereHas('documents', function($query){ + return $query->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER); + }); + })->first(); + dd($purchaseOrders); + foreach ($purchaseOrders as $purchaseOrder){ + $purchaseOrder->status = ApprovalStatus::PENDING_SUBMISSION; + $purchaseOrder->save(); + + $booking = $purchaseOrder->owner; + $booking->status = ApprovalStatus::APPROVED; + $booking->save(); + + $booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::INVOICE, DocumentType::SUPPLIER_DELIVER_ORDER])->delete(); + } + +})->name('ecommerce.fix'); +