diff --git a/app/Classes/Jobs/GenerateInvoice.php b/app/Classes/Jobs/GenerateInvoice.php new file mode 100644 index 00000000..83191e25 --- /dev/null +++ b/app/Classes/Jobs/GenerateInvoice.php @@ -0,0 +1,43 @@ +booking = $booking; + } + + + public function handle() + { + $this->booking->transactions()->whereIn('transactions.type', [TransactionType::INVOICE, TransactionType::SUPPLIER_DELIVER])->delete(); + $this->booking->documents()->whereIn('document_type', [DocumentType::INVOICE, DocumentType::PURCHASE_ORDER, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->delete(); + $this->booking->status = ApprovalStatus::APPROVED; + $this->booking->save(); + + (App()->make(CreateInvoiceTransactionProcessor::class))->execute($this->booking); + } +} diff --git a/app/Classes/Modules/Companies/ControllersLogic/ListBusinessTypesLogic.php b/app/Classes/Modules/Companies/ControllersLogic/ListBusinessTypesLogic.php new file mode 100644 index 00000000..82e840ec --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/ListBusinessTypesLogic.php @@ -0,0 +1,44 @@ + 'Retrieved Business Types', + 'message' => 'You have successfully retrieved a list of Business Types' + ]; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $businessTypes = []; + + foreach(BusinessType::BUSINESS_TYPE_LIST as $key => $val) { + $type = (object)["id" => $key, "type" => $val]; + array_push($businessTypes, $type); + } + + return $this->collectionResponse(GeneralTypeResource::collection($businessTypes)); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllersLogic/ListCompanyTypesLogic.php b/app/Classes/Modules/Companies/ControllersLogic/ListCompanyTypesLogic.php new file mode 100644 index 00000000..0a9afdfb --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/ListCompanyTypesLogic.php @@ -0,0 +1,44 @@ + 'Retrieved Company Types', + 'message' => 'You have successfully retrieved a list of Company Types' + ]; + } + + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $businessTypes = []; + + foreach(CompanyType::COMPANY_TYPE_LIST as $key => $val) { + $type = (object)["id" => $key, "type" => $val]; + array_push($businessTypes, $type); + } + + return $this->collectionResponse(GeneralTypeResource::collection($businessTypes)); + } +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php new file mode 100644 index 00000000..e25fdbf6 --- /dev/null +++ b/app/Classes/Modules/Companies/ControllersLogic/UpdateCompanyProfileLogic.php @@ -0,0 +1,65 @@ + 'Update Company Details', + 'message' => 'You have successfully updated the Company Details' + ]; + } + + /** @var FetchesCompany */ + private $fetchesCompany; + + /** @var UpdatesCompanyProfile */ + private $updatesCompanyProfile; + + /** + * UpdateCompanyProfileLogic constructor. + * @param FetchesCompany $fetchesCompany + * @param UpdatesCompanyProfile $updatesCompanyProfile + */ + public function __construct( + FetchesCompany $fetchesCompany, + UpdatesCompanyProfile $updatesCompanyProfile + ) + { + $this->fetchesCompany = $fetchesCompany; + $this->updatesCompanyProfile = $updatesCompanyProfile; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $object = new CompanyProfileObject($request->input('email'), $request->input('phone'), $request->input('type')); + + $company = $this->fetchesCompany->execute(['id' => $request->route('id')]); + + $company_query = $this->updatesCompanyProfile->execute($company, $object); + + return $this->resourceResponse(new CompanyResource($company_query)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php b/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php new file mode 100644 index 00000000..0f3e8a54 --- /dev/null +++ b/app/Classes/Modules/Companies/DataTransferObjects/CompanyProfileObject.php @@ -0,0 +1,55 @@ +email = $email; + $this->phone = $phone; + $this->companyType = $companyType; + } + + /** + * @return null|string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @return string + */ + public function getPhone(): string + { + return $this->phone; + } + + /** + * @return int + */ + public function getCompanyType(): int + { + return $this->companyType; + } +} diff --git a/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php b/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php new file mode 100644 index 00000000..85da8836 --- /dev/null +++ b/app/Classes/Modules/Companies/Services/UpdatesCompanyProfile.php @@ -0,0 +1,32 @@ +type = $object->getCompanyType(); + + $contact = $model->contacts()->first(); + if ($contact) { + $contact->email = $object->getEmail(); + $contact->phone = $object->getPhone(); + $contact->save(); + } + + return $this->handler($model); + + } +} \ No newline at end of file diff --git a/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessorV2.php b/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessorV2.php index 8494f61e..b9566a4f 100644 --- a/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessorV2.php +++ b/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessorV2.php @@ -24,7 +24,7 @@ class TransactionToPerfexCRMProcessorV2 $projectName = 'Exchange | ' . $bookingInfo['serviceTypeName'] . ' | ' . $bookingInfo['bookingMarking']; $tasks = $this->defineTasks($model, $status); - Log::error("TransactionToPerfexCRMProcessorV2 status: ".$status." - for project name: ".$projectName); + //Log::error("TransactionToPerfexCRMProcessorV2 status: ".$status." - for project name: ".$projectName); if(count($tasks) > 0) { $updatePerfexCRMObject = new UpdatePerfexCRMObject( diff --git a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php index c16ac453..a078a01d 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/FetchCompanyTransactionStatementLogic.php @@ -55,6 +55,15 @@ class FetchCompanyTransactionStatementLogic extends AbstractControllerLogic ->where('owner_type', Wallet::class) ->where('type', '!=', TransactionType::PAYMENT); }) + ->orWhere(function ($query) use ($companyId) { + $query + ->where('type', TransactionType::INVOICE) + ->where('owner_type', Booking::class) + ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->whereHas('booking', function ($query) use ($companyId) { + $query->where('company_id', $companyId); + }); + }) ->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) ->orderBy('created_at', 'desc') ->get(); diff --git a/app/Classes/ValueObjects/Constants/BusinessType.php b/app/Classes/ValueObjects/Constants/BusinessType.php index 831568e9..69ea3202 100644 --- a/app/Classes/ValueObjects/Constants/BusinessType.php +++ b/app/Classes/ValueObjects/Constants/BusinessType.php @@ -12,4 +12,11 @@ final class BusinessType { public const TRANSFER_AGENT = 4; + public const BUSINESS_TYPE_LIST = [ + self::FREIGHT_FORWARDER => 'Freight Forwarder', + self::IMPORTER => 'Importer', + self::CURRENCY_VENDOR => 'Currency Vendor', + self::TRANSFER_AGENT => 'Transfer Agent', + ]; + } diff --git a/app/Classes/ValueObjects/Constants/CompanyType.php b/app/Classes/ValueObjects/Constants/CompanyType.php index 135aa700..f16e51c5 100644 --- a/app/Classes/ValueObjects/Constants/CompanyType.php +++ b/app/Classes/ValueObjects/Constants/CompanyType.php @@ -13,4 +13,9 @@ final class CompanyType { self::COMPANY_BUSINESS => 'COMPANY_BUSINESS', ]; + public const COMPANY_TYPE_LIST = [ + self::PERSONAL_BUSINESS => 'Personal Business', + self::COMPANY_BUSINESS => 'Company Business', + ]; + } diff --git a/app/Console/Commands/DeleteOrderCommand.php b/app/Console/Commands/DeleteOrderCommand.php index a4702ff0..849a0106 100644 --- a/app/Console/Commands/DeleteOrderCommand.php +++ b/app/Console/Commands/DeleteOrderCommand.php @@ -5,6 +5,7 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use Carbon\Carbon; use App\Classes\ValueObjects\Constants\ApprovalStatus; +use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\Booking; class DeleteOrderCommand extends Command @@ -40,7 +41,8 @@ class DeleteOrderCommand extends Command */ public function handle() { - $bookings_reference = $this->argument('bookings_reference'); + // $bookings_reference = $this->argument('bookings_reference'); + $bookings_reference = '28546,38599,44487,71086,70133,58580,42831,96028,41188,33894,95877,86732,31894,50962,44215,92894,40968,30303,89762,74693,45271,27169'; $bookings_reference = explode(',', $bookings_reference); $start = new Carbon(); @@ -52,9 +54,14 @@ class DeleteOrderCommand extends Command if (!$booking) { $this->logOutput('Booking not found: ' . $reference); } else { - $booking->status = ApprovalStatus::EXPIRED; - $booking->save(); - $this->logOutput('Booking deleted: ' . $reference); + $payment = $booking->transactions() + ->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED]) + ->first(); + + $payment->status = ApprovalStatus::EXPIRED; + $payment->save(); + + $this->logOutput('Booking ' . $reference . ' Payment deleted: ' . $payment->id); } } diff --git a/app/Http/Controllers/Companies/ListBusinessTypesController.php b/app/Http/Controllers/Companies/ListBusinessTypesController.php new file mode 100644 index 00000000..ecf1f0c9 --- /dev/null +++ b/app/Http/Controllers/Companies/ListBusinessTypesController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Companies/ListCompanyTypesController.php b/app/Http/Controllers/Companies/ListCompanyTypesController.php new file mode 100644 index 00000000..78c6abf9 --- /dev/null +++ b/app/Http/Controllers/Companies/ListCompanyTypesController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Companies/UpdateCompanyProfileController.php b/app/Http/Controllers/Companies/UpdateCompanyProfileController.php new file mode 100644 index 00000000..088c6ffd --- /dev/null +++ b/app/Http/Controllers/Companies/UpdateCompanyProfileController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Imports/ImportHoneyTrapController.php b/app/Http/Controllers/Imports/ImportHoneyTrapController.php index f19cbcd4..8f016ed4 100644 --- a/app/Http/Controllers/Imports/ImportHoneyTrapController.php +++ b/app/Http/Controllers/Imports/ImportHoneyTrapController.php @@ -34,12 +34,20 @@ class ImportHoneyTrapController $excelRows = $excelRows->toArray(); $returnArray = []; - $segment_name = 'honey trap campaign'; - $segment = Segment::where('name', $segment_name)->first(); + // $segment_name = 'honey trap campaign'; + // $segment = Segment::where('name', $segment_name)->first(); + $input_segment_id = $request->input('segment_id'); + if (!$input_segment_id) { + $row['status'] = 'Failed'; + $row['message'] = 'segment_id cannot be empty'; + $returnArray[] = $row; + return response()->json($returnArray); + } + $segment = Segment::where('id', $input_segment_id)->first(); if (!$segment) { $row['status'] = 'Failed'; - $row['message'] = '"' . $segment_name . '"' . ' not found'; + $row['message'] = 'Segment not found'; $returnArray[] = $row; return response()->json($returnArray); } diff --git a/app/Http/Resources/GeneralTypeResource.php b/app/Http/Resources/GeneralTypeResource.php new file mode 100644 index 00000000..b6dc2348 --- /dev/null +++ b/app/Http/Resources/GeneralTypeResource.php @@ -0,0 +1,22 @@ + $this->id, + 'type' => $this->type, + ]; + } +} diff --git a/composer.json b/composer.json index 47acc131..b8b505d5 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,8 @@ "staudenmeir/eloquent-has-many-deep": "^1.7", "timehunter/laravel-google-recaptcha-v3": "~2.5", "tymon/jwt-auth": "^1.0", - "webklex/laravel-pdfmerger": "^1.3" + "webklex/laravel-pdfmerger": "^1.3", + "ext-bcmath": "*" }, "require-dev": { "facade/ignition": "^2.3.6", diff --git a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue index 7b0aee28..026a76c5 100644 --- a/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue +++ b/resources/assets/vue/components/bookings/elements/CustomerTransactionHistorySectionComponent.vue @@ -24,7 +24,8 @@
This payment is designed to facilitate CNY payments from an enterprise bank account to your suppliers' enterprise bank accounts
+With this method, you can:
+