createsDocument = $createsDocument; $this->createsFile = $createsFile; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; $this->sendUserPaymentProofUploadedEmail = $sendUserPaymentProofUploadedEmail; } /** * @param Transaction $transaction * @param array $files * @return void * @throws \App\Classes\Exceptions\MalformedRequestException */ public function execute(Transaction $transaction, array $files) { $object = new DocumentObject(DocumentType::CURRENCY_VENDOR_PAYMENT_PROOF, $files, '', ApprovalStatus::APPROVED, 'china_bank_slip'); /** @var Document $document */ $document = $this->createsDocument->execute($transaction, $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 $companyEmployee = $transaction->owner->booking->company->employees; foreach ($companyEmployee as $employee) { if (app()->environment('production') || in_array($employee->email, ['cief.enquirycntr@gmail.com', 'tech.ciefmalaysia@gmail.com'])) { $this->sendUserPaymentProofUploadedEmail::dispatch($employee, $transaction->owner->booking, $file[0]); } } } }