diff --git a/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php b/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php new file mode 100644 index 00000000..072dfa15 --- /dev/null +++ b/app/Classes/Jobs/SendUserPaymentProofUploadedEmail.php @@ -0,0 +1,47 @@ +user = $user; + $this->booking = $booking; + $this->file = $file; + } + + + public function handle() + { + $this->user->notify(new PaymentProofUploadedEmail($this->user, $this->booking, $this->file)); + } +} diff --git a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php index 617691e8..8eb47681 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/AutoPurchaseOrderFillLogic.php @@ -65,7 +65,7 @@ class AutoPurchaseOrderFillLogic extends AbstractControllerLogic public function logic(Request $request) : JsonResponse { $bookings = Booking::where('service_id', '!=', 4)->where(function($query){ - return $query->whereMonth('created_at', '=', 04)->whereYear('created_at', 2023); + return $query->whereMonth('created_at', '=', 03)->whereYear('created_at', 2023); })->whereDoesntHave('transactions', function($q){ $q->where('type', TransactionType::PURCHASE_ORDER); $q->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED]); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php index fdda9019..00ca9a85 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreatePaymentProofDocumentLogic.php @@ -14,6 +14,7 @@ use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus; use App\Classes\ValueObjects\Constants\ApprovalStatus; use App\Classes\ValueObjects\Constants\CompanyType; use App\Classes\ValueObjects\Constants\DocumentType; +use App\Classes\Jobs\SendUserPaymentProofUploadedEmail; use App\Models\Company; use App\Models\Document; use Illuminate\Http\JsonResponse; @@ -50,6 +51,9 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic /** @var CreateInvoiceTransactionProcessor */ private $createInvoiceTransactionProcessor; + /** @var SendUserPaymentProofUploadedEmail */ + private $sendUserPaymentProofUploadedEmail; + /** * CreatePaymentProofDocumentLogic constructor. * @param FetchesTransaction $fetchesTransaction @@ -58,13 +62,14 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic * @param UpdatesTransactionStatus $updatesTransactionStatus * @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor */ - public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor) + public function __construct(FetchesTransaction $fetchesTransaction, CreatesDocument $createsDocument, CreatesFiles $createsFile, UpdatesTransactionStatus $updatesTransactionStatus, CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor, SendUserPaymentProofUploadedEmail $sendUserPaymentProofUploadedEmail) { $this->fetchesTransaction = $fetchesTransaction; $this->createsDocument = $createsDocument; $this->createsFile = $createsFile; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; + $this->sendUserPaymentProofUploadedEmail = $sendUserPaymentProofUploadedEmail; } /** @@ -82,12 +87,21 @@ class CreatePaymentProofDocumentLogic extends AbstractControllerLogic /** @var Document $document */ $document = $this->createsDocument->execute($transaction, $object); - $this->createsFile->execute($document, $object); + $file = $this->createsFile->execute($document, $object); $this->updatesTransactionStatus->execute($transaction, ApprovalStatus::APPROVED); $this->createInvoiceTransactionProcessor->execute($transaction->owner->booking); + // send email to customer + // todo: a function to send a proof to the receipiant, they have to give us a email of the receipiant and also need to submiited purchase order + if (app()->environment('production')) { + $companyEmployee = $transaction->owner->booking->company->employees; + foreach ($companyEmployee as $employee) { + $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking, $file[0]); + } + } + return $this->response([]); } diff --git a/app/Classes/Notifications/PaymentProofUploadedEmail.php b/app/Classes/Notifications/PaymentProofUploadedEmail.php new file mode 100644 index 00000000..cc611236 --- /dev/null +++ b/app/Classes/Notifications/PaymentProofUploadedEmail.php @@ -0,0 +1,54 @@ +user = $user; + $this->booking = $booking; + $this->file = $file; + } + + + public function toMail() + { + $attachedFile = null; + $file_info = $this->file->getFileAttribute($this->file)->file->file_info; + foreach ($file_info as $fileCount => $fileVal) { + if (isset($fileVal->original)) { + $file_path = $fileVal->original->file; + $attachedFile = storage_path('app/documents/' . $file_path); + } + } + + return (new MailMessage) + ->subject('Transfer Completed (REF: ' . $this->booking->marking . ')') + ->attach($attachedFile) // todo-new: add attachement + ->view('emails.accounts.payment_proof_email', ['user' => $this->user, 'booking' => $this->booking]); + } + + +} diff --git a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue index e1fd6f0d..fee69b79 100644 --- a/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue +++ b/resources/assets/vue/components/banks/forms/BankAccountFormComponent.vue @@ -27,9 +27,10 @@
- + + {{ serviceType.id != 4 ? '*Please ensure to use the appropriate company name for corporate transfers, instead of personal names.' : ''}}
diff --git a/resources/views/emails/accounts/payment_proof_email.blade.php b/resources/views/emails/accounts/payment_proof_email.blade.php new file mode 100644 index 00000000..eb1357ea --- /dev/null +++ b/resources/views/emails/accounts/payment_proof_email.blade.php @@ -0,0 +1,12 @@ +@extends('emails.layout.base') + +@section('content') +

Dear {{ucwords($user->name)}},

+

Thank you for using CIEF Exchange service!

+

We have completed your RMB transfer transaction for the ref. no {{$booking->marking}}. The RMB bank slip has been attached to this email. If you would like to view the transaction, please click on the following link:

+
+ +
+ + +@endsection \ No newline at end of file