delete 1688 purchase order for special customers

This commit is contained in:
omair saleh
2022-10-31 16:17:07 +08:00
parent 4f7f7bf7aa
commit 01aaae05f4
+21
View File
@@ -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');