diff --git a/app/Classes/General/Eloquent/Filters/IssuerNot.php b/app/Classes/General/Eloquent/Filters/IssuerNotIn.php similarity index 74% rename from app/Classes/General/Eloquent/Filters/IssuerNot.php rename to app/Classes/General/Eloquent/Filters/IssuerNotIn.php index 77423b5d..61ca4f4c 100644 --- a/app/Classes/General/Eloquent/Filters/IssuerNot.php +++ b/app/Classes/General/Eloquent/Filters/IssuerNotIn.php @@ -4,7 +4,7 @@ namespace App\Classes\General\Eloquent\Filters; use Illuminate\Database\Eloquent\Builder; -class IssuerNot implements Filter +class IssuerNotIn implements Filter { /** @@ -14,7 +14,7 @@ class IssuerNot implements Filter */ public static function apply(Builder $builder, $value) { - return $builder->where('issuer', '!=', $value); + return $builder->whereNotIn('issuer', $value); } } \ No newline at end of file diff --git a/app/Classes/Modules/Exports/Services/ExportsCustomers.php b/app/Classes/Modules/Exports/Services/ExportsCustomers.php index a397e6f5..1972935e 100644 --- a/app/Classes/Modules/Exports/Services/ExportsCustomers.php +++ b/app/Classes/Modules/Exports/Services/ExportsCustomers.php @@ -47,6 +47,8 @@ class ExportsCustomers implements FromQuery, WithHeadingRow, WithMapping return [ $company->reference, $company->name, + $company->employees()->first() ? $company->employees()->first()->name : '', + $company->contacts()->first() ? $company->contacts()->first()->phone : '', $company->type === CompanyType::COMPANY_BUSINESS ? 'Company' : 'individual', count($company->bookings), $company->bookings()->sum('fix_amount'), diff --git a/app/Console/Commands/EmailDoToVTCommand.php b/app/Console/Commands/EmailDoToVTCommand.php new file mode 100644 index 00000000..66e4f7b4 --- /dev/null +++ b/app/Console/Commands/EmailDoToVTCommand.php @@ -0,0 +1,91 @@ +format('Y_m_d').'.zip'; + $attachment = storage_path().'/'.$zip_file; + + $zip = new ZipArchive(); + if ($zip->open($attachment, ZIPARCHIVE::CREATE | ZipArchive::OVERWRITE)) { + + $bookings = \App\Models\Booking::where('status', ApprovalStatus::COMPLETED)->whereDate('updated_at', Carbon::yesterday()) + ->whereHas('transactions', function ($query){ + return $query->where('type', TransactionType::BILL)->where('issuer', 2); + })->get(); + + if(!count($bookings)){ return; } + + foreach ($bookings as $booking) { + $file = $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); + $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), $booking->created_at->format('d_m_Y').'_'.$booking->marking.'.pdf'); + + } + + $zip->close(); + + Mail::raw( "Attention to VT Admin team:\r\n\r\nKindly refer to the attachment for our DAILY DO COMPILATION ".Carbon::yesterday()->format('d-m-Y').".\r\n\r\n**This is an automatically generated email – please do not reply to it. If you have any queries kindly contact our admin team through Wechat.\r\n\r\n\r\nCIEF WORLDWIDE SDN BHD", function($message) use ($attachment){ + $message->from('exchange@cief-malaysia.com'); + $message->to(['vtnation16@gmail.com', 'vtnation@gmail.com', 'atvantic04@gmail.com', 'vtnation2@gmail.com']); + $message->cc(['shafiqa_sukeri@cief-malaysia.com', 'frontendcief@gmail.com', 'pm@cief-malaysia.com', 'hasan@cief-malaysia.com', 'shipping_admin@cief-malaysia.com', 'hasanakbar27@gmail.com', 'pmwong2019@gmail.com', 'uldvstar@gmail.com']); + $message->subject('CIEF DO COMPILATION '.Carbon::yesterday()->format('d-m-Y')); + + $message->attach($attachment); + }); + + File::delete($attachment); + + echo 'success'; + + } + } + +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 16f673e8..8edaaa22 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,8 +2,15 @@ namespace App\Console; +use App\Models\User; +use Carbon\Carbon; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; +use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\File; +use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Storage; +use ZipArchive; class Kernel extends ConsoleKernel { @@ -23,7 +30,10 @@ class Kernel extends ConsoleKernel */ protected function schedule(Schedule $schedule) { + // $schedule->command('inspire')->hourly(); + $schedule->command('mail:EmailDoToVTCommand')->dailyAt('10:00')->withoutOverlapping(); + } /** diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 266f8fc2..633985cf 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -3,7 +3,6 @@ namespace App\Http\Resources; use App\Classes\ValueObjects\Constants\TransactionType; -use App\Models\Transaction; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; @@ -25,6 +24,7 @@ class TransactionResource extends JsonResource 'payment_reference' => $this->payment_reference, 'payment_method' => (float) $this->payment_method, 'recipient_bank_account' => new BankResource($this->when((int) $this->type === TransactionType::BILL, $this->booking->bank)), + 'issuer_name' => $this->issuerCompany->name, 'amount' => (double) $this->amount, 'original_amount' => (double) $this->original_amount, 'currency' => new CurrencyResource($this->currency), diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php index 03c53e51..0250514f 100644 --- a/app/Models/Transaction.php +++ b/app/Models/Transaction.php @@ -48,6 +48,14 @@ class Transaction extends AbstractModel implements Documentable return $this->BelongsTo(Wallet::class, 'owner_id', 'id'); } + /** + * @return BelongsTo + */ + public function issuerCompany(): BelongsTo + { + return $this->BelongsTo( Company::class, 'issuer', 'id'); + } + /** * @return BelongsTo */ diff --git a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue index c403af9d..7266f591 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentProofComponent.vue @@ -28,12 +28,23 @@ {{item.booking.company.reference}} +
+
+ + + +
+
-
+
diff --git a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue index 26cd0c81..1fda9c0a 100644 --- a/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue +++ b/resources/assets/vue/components/bookings/sections/BookingDetailsSectionComponent.vue @@ -318,7 +318,7 @@
Payable
- {{item.original_currency.short_code}} {{(Math.round((item.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}} + {{item.currency.short_code}} {{(Math.round((item.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
diff --git a/resources/views/pages/bookings.blade.php b/resources/views/pages/bookings/index.blade.php similarity index 100% rename from resources/views/pages/bookings.blade.php rename to resources/views/pages/bookings/index.blade.php diff --git a/resources/views/pages/booking_merge.blade.php b/resources/views/pages/bookings/merge.blade.php similarity index 100% rename from resources/views/pages/booking_merge.blade.php rename to resources/views/pages/bookings/merge.blade.php diff --git a/resources/views/pages/booking_details.blade.php b/resources/views/pages/bookings/profile.blade.php similarity index 100% rename from resources/views/pages/booking_details.blade.php rename to resources/views/pages/bookings/profile.blade.php diff --git a/resources/views/pages/currency_orders.blade.php b/resources/views/pages/currency_orders.blade.php new file mode 100644 index 00000000..defd8e26 --- /dev/null +++ b/resources/views/pages/currency_orders.blade.php @@ -0,0 +1,161 @@ +@extends('layouts.base_portal') +@section('inner_content') +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Complete
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Payment Proof
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Verification
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
Complete
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+@endsection \ No newline at end of file diff --git a/resources/views/pages/dashboards/account_admin.blade.php b/resources/views/pages/dashboards/account_admin.blade.php index 51ce8ebe..f3638dd6 100644 --- a/resources/views/pages/dashboards/account_admin.blade.php +++ b/resources/views/pages/dashboards/account_admin.blade.php @@ -2,7 +2,14 @@
- + + + +
+
+ diff --git a/resources/views/partials/header.blade.php b/resources/views/partials/header.blade.php index 43a843a1..e25b8f93 100644 --- a/resources/views/partials/header.blade.php +++ b/resources/views/partials/header.blade.php @@ -31,6 +31,11 @@
Payments & Billing
+
Transfers
diff --git a/routes/web.php b/routes/web.php index b0c44548..61cccb47 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,10 +1,6 @@ name('payments'); +Route::get('/currency_orders', function () { + return view('pages.currency_orders'); +})->name('currency_orders'); + Route::get('/bookings', function () { - return view('pages.bookings'); + return view('pages.bookings.index'); })->name('bookings'); Route::get('/bookings/urgent', function () { @@ -64,50 +64,12 @@ Route::get('/bookings/urgent', function () { })->name('bookings.urgent'); Route::get('/transfer/{marking}', function ($marking) { - return view('pages.booking_details', ['marking' => $marking]); + return view('pages.bookings.profile', ['marking' => $marking]); })->name('booking.details'); Route::get('/transfer/merge/{marking}', function ($marking) { - return view('pages.booking_merge', ['marking' => $marking]); + return view('pages.bookings.merge', ['marking' => $marking]); })->name('booking.merge'); -Route::get('/test', function(){ - -// Auth::login(User::findOrFail(1)); -// try { -// $zip_file = 'cief_jun_to_september_delivery_orders.zip'; // Name of our archive to download -// $zip = new ZipArchive(); -// if ($zip->open(storage_path().'/'.$zip_file, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) === TRUE) { -// -// //whereMonth('created_at', 5)->whereYear('created_at', 2021)-> -// $bookings = \App\Models\Booking::where('status', \App\Classes\ValueObjects\Constants\ApprovalStatus::COMPLETED)->get(); -// -// foreach ($bookings as $booking) { -// $file = $booking->documents()->where('document_type', \App\Classes\ValueObjects\Constants\DocumentType::SUPPLIER_DELIVER_ORDER)->first()->files()->first(); -// if (! $zip->addFile(Storage::disk('documents')->path($file->file->file_info->original->file), Carbon::now()->format('d_m_Y').'_'.$booking->marking.'.pdf')) { -// echo 'Could not add file to ZIP: ' . $file; -// } -// } -// -// // Close ZipArchive -// $zip->close(); -// } else { -// echo 'Could not open ZIP file.'; -// } -// } catch (Exception $exception) { -// dd($exception); -// } - - -}); - - -Route::get('/online_payment/redirect', 'Billplz\CallbackBillplzController@callback')->name('online_payment.redirect'); - -//Route::get('/online_payment/redirect', function () { -// return view('pages.billplz_redirect'); -//})->name('online_payment.redirect'); - - Route::get('/export/customers/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@export'); Route::get('/export/transactions/f614e339d7058904a831aad742e24d55', 'Exports\ExportCustomersToExcelController@transactions');