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}} +