mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
open customer purchase order
This commit is contained in:
@@ -24,6 +24,8 @@ use Spatie\Activitylog\Models\Activity;
|
||||
use Webklex\PDFMerger\Facades\PDFMergerFacade as PDFMerger;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
use App\Classes\Modules\Bookings\Processors\CreatePurchaseOrderFor1688OrderProcessor;
|
||||
use App\Classes\Modules\Documents\Services\DeletesDocument;
|
||||
use App\Classes\Modules\Transactions\Services\DeletesTransaction;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -623,3 +625,35 @@ Route::get('/po/outsource/check', function(){
|
||||
Route::get('/upload-honey-trap', function () {
|
||||
return view('pages.honey_trap');
|
||||
})->name('upload_honey_trap');
|
||||
|
||||
Route::get('/open-purchase-order/{marking}/{from_date}/{to_date}', function ($marking, $from_date, $to_date, DeletesTransaction $deletesTransaction, DeletesDocument $deletesDocument) {
|
||||
$company_id = Company::where('reference', $marking)->first()->id;
|
||||
|
||||
$startDate = Carbon::createFromFormat('d-m-Y', $from_date)->startOfDay();
|
||||
$endDate = Carbon::createFromFormat('d-m-Y', $to_date)->endOfDay();
|
||||
|
||||
$bookings = Booking::where('company_id', $company_id)->whereBetween('created_at', [$startDate, $endDate])->get();
|
||||
|
||||
foreach ($bookings as $booking) {
|
||||
$booking->status = ApprovalStatus::APPROVED;
|
||||
$booking->save();
|
||||
|
||||
$transaction = $booking->transactions()->whereIn('type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->get();
|
||||
foreach ($transaction as $key => $row) {
|
||||
$deletesTransaction->execute($row);
|
||||
}
|
||||
|
||||
$document = $booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::INVOICE, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->get();
|
||||
foreach ($document as $key => $row) {
|
||||
$deletesDocument->execute($row);
|
||||
}
|
||||
|
||||
$puchase_order = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
|
||||
if($puchase_order) {
|
||||
$puchase_order->status = ApprovalStatus::PENDING_SUBMISSION;
|
||||
$puchase_order->save();
|
||||
}
|
||||
|
||||
dump('done - ' . $booking->marking);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user