name('login'); Route::get('/signup', function () { return view('pages.accounts.sign_up'); })->name('signup'); Route::get('/account/email/verification/{token}', function ($token) { return view('pages.accounts.email_verified', ['token' => $token]); })->name('account.email.verification'); Route::get('/account/password/reset/{token}', function ($token) { return view('pages.accounts.reset_password', ['token' => $token]); })->name('account.password.reset'); Route::get('/dashboard', function () { return view('pages.dashboards.index'); })->name('dashboard'); Route::get('/banks', function () { return view('pages.banks.index'); })->name('banks'); Route::get('/settings', function () { return view('pages.settings'); })->name('settings'); Route::get('/customers', function () { return view('pages.customers.index'); })->name('customers'); Route::get('/customer/{marking}', function ($marking) { $id = \App\Models\Company::where('reference', '=', $marking)->first()->id; return view('pages.customers.profile', ['id' => $id]); })->name('customer.profile'); Route::get('/customer/{marking}/transactions', function ($marking) { $id = \App\Models\Company::where('reference', '=', $marking)->first()->id; return view('pages.transactions.history', ['id' => $id]); })->name('account.statment'); Route::get('/payments', function () { return view('pages.payments'); })->name('payments'); Route::get('/billings', function () { return view('pages.billings'); })->name('billings'); Route::get('/currency_orders', function () { return view('pages.currency_orders'); })->name('currency_orders'); Route::get('/transfers', function () { return view('pages.bookings.index'); })->name('bookings'); Route::get('/list-transfer', function () { return view('pages.bookings.filter'); })->name('list_transfer'); Route::get('/bookings/urgent', function () { return view('pages.urgent_list'); })->name('bookings.urgent'); Route::get('/transfer/{marking}', function ($marking) { return view('pages.bookings.profile', ['marking' => $marking]); })->name('booking.details'); Route::get('/transfer/merge/{marking}', function ($marking) { return view('pages.bookings.merge', ['marking' => $marking]); })->name('booking.merge'); Route::get('/purchase_orders', function () { return view('pages.purchase_orders'); })->name('purchase_orders'); Route::get('/support', function () { return view('pages.customer_support', [ 'marking' => null, 'email' => null, 'bookingReference' => null, 'company' => null, 'booking' => null ]); })->name('support'); Route::post('/support', function (Request $request) { $marking = $request->input('marking'); $email = $request->input('customer_email'); $bookingReference = $request->input('booking_reference'); $company = null; $booking = null; if($email) { $company = Company::whereHas('Employees', function($user) use($email) { return $user->where('email', $email); })->first(); } if($marking) { $company = Company::where('reference', $marking)->first(); } if($bookingReference) { $booking = Booking::where('marking', $bookingReference)->first(); $company = $booking->company; } return view('pages.customer_support', [ 'marking' => $marking, 'email' => $email, 'bookingReference' => $bookingReference, 'company' => $company, 'booking' => $booking, ]); })->name('support'); Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); Route::get('/export/analytic/booking', 'Exports\ExportAnalyticToExcelController@bookingData'); Route::get('/export/analytic/bills', 'Exports\ExportAnalyticToExcelController@billingData'); Route::get('/export/customers/leads', 'Exports\ExportCustomersToExcelController@leadsData')->name('leads.export'); Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); })->name('products.random'); Route::get('/fix_bills', function () { ini_set('max_execution_time', '1000000'); Auth()->login(User::find(1)); $bookings = \App\Models\Booking::where('status', 3)->whereHas('transactions', function ($query){ return $query->where('type', 1)->whereHas('transactions', function($query){ return $query->where('type', 3)->where('issuer', 2210); }); })->get(); foreach ($bookings as $booking){ $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->delete(); $po = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); $supplier_deliver_order_transaction = $booking->transactions()->where('type', TransactionType::SUPPLIER_DELIVER)->first(); $supplier = Company::find($booking->transactions()->where('type', TransactionType::PAYMENT)->where('status', 3)->first()->transactions()->first()); $supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po, 'supplier' => $supplier]); $document_object = new DocumentObject( DocumentType::SUPPLIER_DELIVER_ORDER, [chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))], '', ApprovalStatus::COMPLETED, 'supplier_delivery_orders' ); $document = (App()->make(CreatesDocument::class))->execute($booking, $document_object); (App()->make(CreatesFiles::class))->execute($document, $document_object); } })->name('products.random'); Route::get('/wallet/{marking}/details', function ($marking) { $id = \App\Models\Company::where('reference', '=', $marking)->first()->id; return view('pages.wallet.index', ['id' => $id]); })->name('wallet.details'); Route::get('/wallets', function () { return view('pages.wallet.wallets'); })->name('wallet.wallets'); Route::get('/bookings/billplz', function () { return view('pages.billplz_redirect'); })->name('bookings.billplz'); Route::get('/document/download', 'Bookings\DownloadBookingDocumentController@download')->name('documents.download'); Route::get('billplz/bills/{bill_no}', function($bill_no){ return redirect(env('BILLPLZ_BASE_URL').'/bills/'.$bill_no); })->name('billplz.bill'); Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions'); Route::get('/export/null-debtor/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@nullDebtor')->name('newDebtor.export'); Route::get('/export/payment-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@paymentTransactions')->name('paymentTransactions.export'); Route::get('/export/wallet-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@walletTransactions')->name('walletTransactions.export'); Route::get('/export/booking-transactions', 'Exports\ExportCustomersToExcelController@bookingTransactions')->name('export.transactions.booking'); Route::get('/export/invoice-transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@invoiceTransactions')->name('invoiceTransactions.export'); Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsProducts $exportsProducts) { $bookings = Booking::where(function($query){ return $query->whereMonth('created_at', 7)->orWhereMonth('created_at', 8)->orWhereMonth('created_at', 9)->orWhereMonth('created_at', 10)->orWhereMonth('created_at', 11)->orWhereMonth('created_at', 12); })->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); })->get(); dd($bookings->count()); return $exportsProducts->download('products.csv', Excel::CSV, ['Content-Type' => 'text/csv']); })->name('products.random'); Route::get('/auto-purchase-order-fill', 'Bookings\AutoPurchaseOrderFillController@auto')->name('assign'); Route::get('purchase/sensitive/', function(Request $request){ $keywords = json_decode($request->input('keywords')); $items = \App\Models\TransactionDetail::query(); foreach ($keywords as $key => $keyword){ if(!$key){ $items->Where('product_name', 'like', '%'.$keyword.'%'); continue; } $items->orWhere('product_name', 'like', '%'.$keyword.'%'); } $items = $items->get(); foreach ($items as $key => $item){ echo ($key+1).'. '.$item->product_name.' => '.$item->transaction->owner->marking.'

'; } }); Route::get('/transactions/supplier/{id}/mock_up', 'Transactions\DownloadMockUpWhiteFormPdfController@download')->name('whiteForm.mockUp'); Route::get('/notifications/list', 'Notifications\ListNotificationsController@list')->name('notifications.list'); Route::get('/supplier/pi/export/{month}/{year}/{id?}', function($month, $year, $id = null){ if(!$id){ foreach (Company::where('business_type', \App\Classes\ValueObjects\Constants\BusinessType::CURRENCY_VENDOR)->get() as $supplier) { echo '

'.$supplier->name.'

'; } return; } echo '

Back to suppliers list

'; $groups = \App\Models\Group::where('issuer', $id)->whereMonth('created_at', $month)->whereYear('created_at', $year)->get(); echo ''; $i = 0; foreach ($groups as $group){ foreach ($group->transactions as $transaction){ $booking = $purchaseOrder = $transaction->owner->owner; $purchaseOrder = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->where('status', ApprovalStatus::APPROVED)->first(); if(!$purchaseOrder) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; continue; } foreach ($purchaseOrder->transactionDetails as $item){ $i++; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } } echo ''; echo '
-'.$group->created_at.'warning, booking ref.'.$booking->marking.' doesn\'t have purchase order000'.$booking->marking.'
'.$i.''.$group->created_at.''.$item->product_name.''.$item->quantity.''.$item->price * (1/$group->currency_rate).''.($item->price * $item->quantity) * (1/$group->currency_rate).''.$booking->marking.'
Service Charge'.$groups->sum('service_charge').'
'; }); Route::get('/segments', function (Request $request) { $segment = null; if ($request->has('id')) { $segment = App\Models\Segment::find($request->id); } return view('pages.segments.index', compact('segment')); })->name('segments'); Route::get('/pending_orders', function(){ $payments = Transaction::where('type', TransactionType::PAYMENT)->where('owner_type', Booking::class)->whereIn('status', [ApprovalStatus::APPROVED])->get(); echo ''; $i = 0; foreach ($payments as $payment){ $booking = $payment->owner; if(!$booking instanceof Booking){ dd($payment); } $bankType = str::length($booking->bank->holder_name) > 4 ? 'Company' : 'Personal'; if (!preg_match('/[^A-Za-z0-9]/', $booking->bank->holder_name)) { $bankType = str_word_count($booking->bank->holder_name) > 4 ? 'Company' : 'Personal'; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
'.$payment->updated_at->format('d-M-y').''.$booking->marking.''.\App\Classes\ValueObjects\Constants\PaymentMethodType::PAYMENT_METHODS_ID[$payment->payment_method].''.$payment->currency->short_code.''.$payment->amount.''.$booking->company->reference.''.$payment->original_currency->short_code.''.$payment->original_amount.''.$booking->service->name.''.$payment->updated_at->diffForHumans().''.$bankType.''.$booking->bank->holder_name.'
'; })->name('orders.pending'); Route::get('/group/text/{id}', function($id){ $group = \App\Models\Group::where('id', $id)->first(); echo 'RATE: '.$group->currency_rate.'
'; echo 'DATE: '.$group->created_at.'


'; $i = 0; foreach ($group->transactions as $transaction){ $i++; $booking = $transaction->owner->owner; echo 'No.'.$i.'
'; echo 'Bank Details:'.$booking->bank->holder_name.'
'; echo $booking->bank->bank_name.' '.$booking->bank->bank_branch.'
'; echo 'Bank Account Number:'.$booking->bank->account_no.'
'; echo 'Order Amount:'.$transaction->original_currency->short_code.' '.(round($transaction->original_amount, 2) + 0).'

'; } })->name('group.text'); Route::get('/wallet/audit', function (Request $request) { $wallets = \App\Models\Wallet::all(); $i = 0; foreach ($wallets as $wallet){ $topups = 0; $credit = 0; $payments = 0; $debit = 0; foreach ($wallet->transactions as $transaction){ if(!in_array((int) $transaction->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])) continue; if((int) $transaction->type === TransactionType::TOP_UP) { $topups += (float) $transaction->amount; // $response = Http::withBasicAuth(config('billplz.api_key').':', '')->get(config('billplz.base_url').'/api/v3/bills/'.$transaction->payment_reference); // // if($response->successful()){ // $data = $response->json(); // if($data['paid']){ // // } else { // echo $transaction->id." => Fraud"; // } // }else{ // echo "billplz error"; // } } if((int) $transaction->type === TransactionType::CREDIT_NOTE) $credit += (float) $transaction->amount; if((int) $transaction->type === TransactionType::PAYMENT) $payments += (float) $transaction->amount; if((int) $transaction->type === TransactionType::DEBIT_NOTE) $debit += (float) $transaction->amount; } $auditBalance = ($topups + $credit) - ($payments + $debit); $diffenrence = round((float) $wallet->amount - (($topups + $credit) - ($payments + $debit)), 2); if((($diffenrence == 0) || ($diffenrence == -0)) AND $wallet->amount > -0.01) continue; $i++; echo $i.". Marking: ". $wallet->owner->reference ."(".$wallet->id.")
Current Balance: ". $wallet->amount ."
Audit Balance: ". ($auditBalance) ."
Difference: ". $diffenrence ."


"; } }); Route::get('/wallets/active', function(){ $wallets = Wallet::all(); echo ''; foreach ($wallets as $wallet){ echo ''; echo ''; echo ''; echo ''; } echo '
'.$wallet->owner->reference.''.$wallet->amount.'
'; }); Route::get('/payments/manual', function(){ $payments = Transaction::where('type', TransactionType::PAYMENT)->whereIn('payment_method', [\App\Classes\ValueObjects\Constants\PaymentMethodType::CASH, \App\Classes\ValueObjects\Constants\PaymentMethodType::BA, \App\Classes\ValueObjects\Constants\PaymentMethodType::CHEQUE])->where('owner_type', Booking::class)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get(); $i = 0; echo ''; foreach ($payments as $payment){ $i++; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
'.$i.''.$payment->documents()->first()->created_at->format('d-m-Y').''.$payment->owner->marking.''.$payment->amount.'
'; }); Route::get('/invoice/fix', function(){ set_time_limit(1800); $bookings = Booking::where('status', ApprovalStatus::COMPLETED)->whereDate('updated_at', '>=', Carbon::parse('01-01-2023'))->get(); foreach($bookings as $booking){ $booking->transactions()->whereIn('transactions.type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete(); $booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->delete(); $booking->status = ApprovalStatus::APPROVED; $booking->save(); (App()->make(CreateInvoiceTransactionProcessor::class))->execute($booking); } })->name('invoice.fix'); Route::get('/1688/fix/{reference}', function($reference){ $booking = Booking::where('marking', $reference)->first(); (App()->make(createPurchaseOrderFor1688OrderProcessor::class))->execute($booking); // set_time_limit(1800); // $purchaseOrderDocuments = \App\Models\Document::where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER)->get(); // // foreach($purchaseOrderDocuments as $document){ // $booking = $document->owner; // $booking->status = ApprovalStatus::APPROVED; // $booking->save(); // // $booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->delete(); // // (App()->make(createPurchaseOrderFor1688OrderProcessor::class))->execute($document->owner); // } })->name('ecommerce.fix'); Route::get('/po/manual/fix', function(){ // $bookings = Booking::whereIn('company_id', [199, 510])->whereHas('documents', function($query){ // return $query->where('document_type', DocumentType::ECOMMERCE_PURCHASE_ORDER); // })->get(); // // foreach ($bookings as $booking){ // $booking->status = ApprovalStatus::APPROVED; // $booking->save(); // // $booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::INVOICE, DocumentType::SUPPLIER_DELIVER_ORDER])->delete(); // $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->update(['status' => ApprovalStatus::PENDING_SUBMISSION]); // // } })->name('ecommerce.fix'); Route::get('/payment/check', function(){ $transactions = Transaction::where('type', TransactionType::BILL)->whereDate('created_at', '>=', Carbon::today())->get(); foreach ($transactions as $transaction){ $booking = $transaction->owner->owner; $documents = $transaction->documents; if(!count($documents)){ echo $booking->marking.'

'; continue; } // echo $transaction->owner->owner->marking.'. payment: '.$transaction->updated_at.' -> document: '.$documents[0]->created_at.'
'; } })->name('payment.check'); Route::get('/refund/fix', function(){ $bookings = Booking::whereIn('marking', [82935, 92135, 96183, 94448, 29819, 30403, 63969, 42116, 79278, 89987, 51432, 76289, 67767, 98433, 47431, 93472, 50933, 87298, 35329, 93845, 55902, 82629, 51019, 42820, 90666, 40167, 29253, 48891, 67364, 64628, 91859, 22123, 34154, 84366, 27370, 58222, 67695, 71233, 26466, 83894, 35664, 65669, 68986, 40382, 63743, 39611, 60658, 32893, 98243, 23822, 64323, 79271, 79053, 48497, 48708, 86463, 30054, 50590, 85808, 88988, 79663, 57558, 85902, 95451, 95897, 33164, 82342, 38091, 27451, 64809, 39444, 32101, 27242, 71851, 50850, 70659, 89403, 55540, 65743, 77315, 22921, 35623, 77315, 32344, 81717, 57176, 48775, 34133, 39396, 67473, 42749, 89395, 32132, 23670, 36783, 21783, 66348, 47205, 72784, 22437, 96271, 45396, 45352, 47896, 61654, 73174, 47002, 25448, 95810, 80827, 81180, 52142, 37640, 30295, 59816, 99197, 76541, 94786, 30776, 89769, 77720, 30610, 28546, 50931, 94525, 43425, 37461, 20629, 60586, 87228, 24814, 68011, 90547, 30572, 26274, 26274, 38599, 44487, 96767, 63872, 29576, 20173, 23555, 64657, 71021, 65316, 86540, 73981, 32747, 71086, 83221, 66168, 90541, 52366, 29227, 30915, 45242, 81384, 37533, 89752, 70133, 45894, 21918, 85579, 48650, 88747, 23200, 37018, 21753, 21188, 60449, 63918, 68888, 49910, 30402, 96338, 36578, 82133, 37872, 90437, 54404, 73439, 94283, 97752, 83333, 38548, 74366, 21060, 43240, 94612, 33164, 98630, 33164, 22898, 44320, 31153, 36480, 55085, 64039, 99796, 42238, 71458, 34415, 49935, 37902, 25598, 51833, 89733, 38081, 71564, 51366, 20173, 91400, 86540, 92131, 76724, 22657, 62117, 86443, 85827, 46570, 99809, 89258, 68834, 20785, 24478, 79588, 49111, 24838, 41989, 79081, 48440, 57375, 86104, 78719, 61502, 96167, 23398, 27873, 80065, 33048, 83138, 99211, 98183, 28639, 54547, 70098, 27216, 67404, 47761, 85049, 41906, 62328, 63645, 46750, 86975, 69955, 21714, 33889, 87344, 58345, 34183, 82504, 68636, 70962, 92553, 20125, 88625, 20661, 98146, 92075, 67543, 99045, 27395, 67163, 32245, 43347, 87947, 97897, 59860, 26003, 47852, 96008, 54166, 50037, 31435, 35821, 81929, 76751, 80379, 32473, 81598, 58716, 70554, 67473, 82491, 93859, 99159, 84772, 84772, 32473, 42050, 26532, 81526, 81526, 45780, 46570, 78657, 35293, 98311, 62095, 86914, 45215, 37650, 57708, 60449, 46750, 91834, 60989, 54877, 98298, 52382, 86346, 65219]) ->get(); $notPlaced = []; $placed = []; $completed = []; foreach ($bookings as $booking){ $payments = $booking->transactions()->where('type', TransactionType::PAYMENT)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->get(); foreach ($payments as $payment){ if($payment->status === ApprovalStatus::APPROVED){ $notPlaced[] = $booking; continue; } $bill = $payment->transactions()->where('type', TransactionType::BILL)->first(); if(!$bill){ $notPlaced[] = $booking; continue; } if(in_array($bill->status, [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])){ $completed[] = $booking; continue; } $placed[] = $booking; } } echo '

Customer Paid ('.count($notPlaced).')

'; foreach ($notPlaced as $booking){ echo ''.$booking->marking.'
'; } echo '

White Form Generated ('.count($placed).')

'; foreach ($placed as $booking){ echo ''.$booking->marking.'
'; } echo '

China Bankslip Uploaded ('.count($completed).')

'; foreach ($completed as $booking){ echo ''.$booking->marking.'
'; } }); Route::get('/currency-rate-history', function () { $paymentMethods = PaymentMethodType::PAYMENT_METHODS; return view('pages.rate_histories')->with('paymentMethods', $paymentMethods); })->name('currency_rate.history'); Route::get('/statements', [BankStatementController::class, 'index'])->name('statements.index'); Route::get('/statements/v2', [BankStatementController::class, 'indexv2'])->name('statements.indexv2'); Route::post('/statements/import', [BankStatementController::class, 'import'])->name('statements.import'); Route::get('/statements/{statement}/details', function ($statement) { return view('pages.accounting.bank-statements.details', ['statement' => $statement]); })->name('statements.transactions.details'); Route::get('/statements/{account}/transactions', function ($account) { return view('pages.accounting.bank-statements.bank_statement', ['account' => $account]); })->name('statements.account.transactions'); Route::get('/statements/{statement}', [BankStatementController::class, 'show'])->name('statements.show'); Route::get('/statements/mapping/rerun', [BankStatementController::class, 'rerun'])->name('statements.rerun'); Route::get('/statements/{statement}/download', 'StatementController@download')->name('statements.download'); Route::get('/bank-record', 'Imports\ImportBankRecordController@import'); Route::get('/po/outsource/check', function(){ $bookings = Booking::whereIn('marking', [34735, 43980, 35339, 28104, 40185, 46648, 34192, 21512, 84607, 31319, 23566, 48372, 59239, 72665, 81127, 46881, 41055, 67368, 41817, 60443, 28958, 46782, 98512, 43356, 78469, 88173, 52592, 77036, 76750, 77732, 31980, 57146, 38544, 78567, 98297, 90128, 43680, 86478, 80340, 41961, 26857, 33992, 79929, 53226, 88107, 31187, 68015, 43762, 34928, 55525, 44528, 57146, 31980, 27399, 63141, 74987, 85935, 37032, 95911, 59511, 47395, 97293, 43906, 74944, 53418, 61988, 81406, 83889, 83359, 66896, 21425, 61124, 23536, 56129, 21116, 64213, 72950, 20502, 20067, 64213, 59854, 44783, 35681, 74828, 28179, 32961, 46412, 99908, 49008, 77655, 45250, 65047, 37167, 90598, 26275, 58013, 38994, 63187, 33219, 52669, 79885, 74828, 91775, 29282, 46781, 96415, 36318, 84491, 32659, 23846, 38994, 65329, 25936, 68209, 72866, 63231, 32216, 82977, 24819, 32600, 38019, 80872, 65505, 37236, 82262, 30815, 59033, 46776, 87317, 89548, 36548, 54468, 35340, 98242, 29234, 47129, 67047, 64210, 36698, 39353, 86435, 65240, 37116, 71007, 40148, 88187, 76368, 91155, 57040, 95456, 29961, 66447, 43023, 29396, 30637, 60789, 84221, 35805, 44552, 35524, 43457, 22810, 83545, 92252, 83603, 59797, 40526, 32520, 71011, 95151, 90464, 78629, 61225, 74864, 73518, 53793, 26478, 57640, 43674, 23476, 76683, 23920, 22810, 44603, 56291, 23580, 94241, 51565, 83769, 63123, 58369, 99399, 41098, 60942, 69442, 80963, 48392, 73169, 59764, 66099, 21107, 33029, 38288, 32223, 55931, 43685, 24267, 83865, 52066, 61501, 83210, 20731, 55951, 82502, 66618, 62216, 22020, 42402, 99644, 35305, 49263, 37387, 73928, 92279, 26445, 83497, 96740, 38374, 29273, 94073, 99785, 21502, 51269, 31609, 97369, 73078, 28982, 64902, 41380, 87008, 59377, 39441, 81341, 62750, 29410, 85975, 37215, 43386, 80627, 79967, 81729, 81738, 58658, 40579, 56179, 37548, 72436, 77165, 32069, 97447, 84575, 49167, 45507, 96371, 90835, 27942, 87691, 30431, 47815, 82960, 43228, 87534, 93737, 98938, 69548, 82923, 48463, 24385, 96569, 53812, 32926, 54418, 34399, 53189, 49377, 27036, 68832, 72799, 76120, 78203, 87009, 86992, 97722, 96262, 95551, 77632, 54408, 33931, 62397, 58343, 52347, 59419, 50339, 54941, 31199, 92385, 90028, 90379, 43070, 25357, 24591, 60276, 91851, 96371, 81886, 24377, 21236, 66737, 93637, 85844, 23130, 75659, 27318, 43587, 46555, 28903, 44930, 52377, 20387, 40705, 79255, 29196, 30968, 76319, 54600, 29881, 37920, 43319, 35893, 65863, 33102, 71589, 45905, 49031, 97435, 70157, 78795, 47570, 71881, 92076, 45847, 35957, 58785, 84896, 65918, 25550, 49031, 50624, 83286, 63111, 21402, 56300, 77238, 21271, 21984, 30500, 76170, 95325, 22888, 84895, 26100, 84952, 49302, 41944, 43703, 84028, 53672, 49162, 28342, 47182, 70484, 59467, 85415, 20202, 97967, 58011, 85807, 79868, 81192, 86985, 43867, 47473, 28063, 68849, 61628, 96641, 37285, 58384, 86505, 51720, 63951, 91958, 28082, 46229, 57439, 55178, 96813, 34444, 28100, 75967, 33204, 75922, 68707, 71960, 34769, 29161, 49088, 79773, 91131, 53033, 77611, 81034, 72625, 36273, 78240, 34647, 21838, 73195, 83282, 60911, 29019, 98859, 44064, 82113, 51118, 54681, 59751, 64347, 21623, 47023, 62168, 23466, 62137, 85432, 85043, 41984, 30417, 40616, 97170, 69106, 81484, 68902, 78149, 62438, 67710, 57370, 99207, 64271, 33959, 60821, 51292, 44130, 28469, 77069, 91088, 47702, 89046, 84958, 41601, 99752, 72976, 26393, 85548, 32920, 86353, 97430, 71507, 36667, 57059, 71148, 44588, 35807, 80213, 89884, 76616, 35999, 79860, 37284, 72249, 32885, 70622, 47036, 97366, 60483, 89171, 37048, 34227, 76290, 46761, 31389, 73977, 54421, 87527, 75925, 68236, 31131, 43871, 54753, 90896, 41653, 82304, 87123, 80391, 42368, 35553, 60587, 30941, 31843, 25076]) ->get(); $averageItems = 5; $totalItems = 0; $pay = 0; foreach ($bookings as $booking){ $po = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::PENDING_VERIFICATION])->first(); if(!$po){ echo ''.$booking->marking.' Purchase order not found!
'; continue; } // $items = $po->transactionDetails()->get(); // // foreach ($items as $item){ // $activity = Activity::where('causer_id', 4332)->where('subject_id', $item->id)->where('subject_type', \App\Models\TransactionDetail::class)->get(); // if($activity) { // $totalItems++; // } // } // // check activities by user $itemsCount = $po->transactionDetails()->count(); $totalItems += $itemsCount; $sum = $itemsCount / $averageItems; $pay += $sum < 1 ? 1 : round($sum); } echo '

Total Items: '.$totalItems.'

'; echo '

Total Pay: '.$pay.'

'; }); 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); } }); Route::get('/vouchers', function () { return view('pages.rewards.index'); })->name('rewards'); Route::get('/customer/vouchers/{marking}', function ($marking) { $id = \App\Models\Company::where('reference', '=', $marking)->first()->employees->first()->id; return view('pages.customers.reward', ['id' => $id]); })->name('customer.reward'); Route::get('transaction/{id}/credit_note/download', 'Transactions\GenerateCreditNotePdfController@download')->name('transaction.credit_note.download');