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/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/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/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/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue index 39eed578..8bc0b7a8 100644 --- a/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue +++ b/resources/assets/vue/components/companies/elements/CompanyDetailsComponent.vue @@ -9,6 +9,15 @@ +
| No | @@ -81,34 +82,37 @@||||||
|---|---|---|---|---|---|---|
| {{ $key + 1 }} | {{ $transaction_detail->product_code }} | {{ $transaction_detail->product_name }} | {{ $transaction_detail->quantity }} | - @php - $unitPrice = $transaction_detail->price / $currencyRate; - @endphp - {{ number_format($unitPrice, 2) }} + {{ number_format($exactUnitPrice, 2) }} | - @php - $itemTotal = $unitPrice * $transaction_detail->quantity; - $subtotal += $itemTotal; - @endphp {{ number_format($itemTotal, 2) }} | |
| Subtotal | @@ -117,27 +121,17 @@||||||
| Service Charges | -- {{ number_format($transaction->service_charge, 2) }} - | +{{ number_format($transaction->service_charge, 2) }} | ||||
| Voucher ({{ $voucher_redemption->voucher->code }}) | --{{ $voucherDiscount }} | +-{{ number_format($voucherDiscount, 2) }} | ||||
| - | Adjustment | -- @php - $adjustment = $transaction->amount - $subtotal; - @endphp - {{ number_format($adjustment, 2) }} - | -||||
| @@ -145,13 +139,21 @@ | {{ number_format($transaction->tax, 2) }} | |||||
| + | Adjustment | +{{ roundUpDo($discrepancy,2) }} | +||||
| Total | - @php - $total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount; - @endphp {{ number_format($total, 2) }} | |||||
|
-
-
- CIEF WORLDWIDE SDN BHD
-
-
+ CIEF WORLDWIDE SDN BHD
(1134596-M) No. 72-3, Jalan Jalil 1, The Earth Bukit Jalil, @@ -23,14 +23,8 @@ Tel: 03-8082 1252 |
-
-
- Invoice
-
-
-
+ Invoice
EI#: {{ $transaction->bill_no }}
-
Ref# {{ $po_order_transaction->booking->marking }}
Date: {{ $supplier->segments->whereIn('id', [23])->first() ? \Carbon\Carbon::now() : $po_order_transaction->booking->created_at }}
|
| - - Bill To - + Bill To | ||
|
-
- {{ $supplier->name }}
-
+ {{ $supplier->name }}
+ @php
+ $billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
+ @endphp
- @php
- $billingAddress = $supplier->addresses()->where('billing', '=', true)->first();
- @endphp
{{ $billingAddress->street_one }}
- {{ $billingAddress->street_two }} ,
+ {{ $billingAddress->street_two }},
{{ $billingAddress->district()->first()->name }},
{{ $billingAddress->postcode }}
{{ $billingAddress->state()->first()->name }},
{{ $billingAddress->country()->first()->name }}
-
- Phone: {{ $supplier->contacts()->first()->phone }}
-
+ Phone: {{ $supplier->contacts()->first()->phone }}
|
||
| No | @@ -81,35 +72,37 @@||||||
|---|---|---|---|---|---|---|
| {{ $key + 1 }} | {{ $transaction_detail->product_code }} | {{ $transaction_detail->product_name }} | {{ $transaction_detail->quantity }} | - @php - $unitPrice = $transaction_detail->price / $currencyRate; - @endphp - {{ number_format($unitPrice, 2) }} + {{ number_format($exactUnitPrice, 2) }} | - @php - $itemTotal = $unitPrice * $transaction_detail->quantity; - $subtotal += $itemTotal; - @endphp {{ number_format($itemTotal, 2) }} | |
| Subtotal | @@ -120,23 +113,15 @@Service Charges | {{ number_format($transaction->service_charge, 2) }} | ||||
| Voucher ({{ $voucher_redemption->voucher->code }}) | --{{ $voucherDiscount }} | +-{{ number_format($voucherDiscount, 2) }} | ||||
| - | Adjustment | -- @php - $adjustment = $transaction->amount - $subtotal; - @endphp - {{ number_format($adjustment, 2) }} - | -||||
| @@ -144,24 +129,59 @@ | {{ number_format($transaction->tax, 2) }} | |||||
| + | Adjustment | +{{ roundUp($discrepancy,2) }} | +||||
| Total | - @php - $total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount; - @endphp {{ number_format($total, 2) }} | |||||
| This is generated by computer. No signature required. | -Page {PAGENO} of {nbpg} | -
| No | @@ -89,34 +90,37 @@||||||
|---|---|---|---|---|---|---|
| {{ $key + 1 }} | {{ $transaction_detail->product_code }} | {{ $transaction_detail->product_name }} | {{ $transaction_detail->quantity }} | - @php - $unitPrice = $transaction_detail->price / $currencyRate; - @endphp - {{ number_format($unitPrice, 2) }} + {{ number_format($exactUnitPrice, 2) }} | - @php - $itemTotal = $unitPrice * $transaction_detail->quantity; - $subtotal += $itemTotal; - @endphp {{ number_format($itemTotal, 2) }} | |
| Subtotal | @@ -125,27 +129,17 @@||||||
| Service Charges | -- {{ number_format($transaction->service_charge, 2) }} - | +{{ number_format($transaction->service_charge, 2) }} | ||||
| Voucher ({{ $voucher_redemption->voucher->code }}) | --{{ $voucherDiscount }} | +-{{ number_format($voucherDiscount, 2) }} | ||||
| - | Adjustment | -- @php - $adjustment = $transaction->amount - $subtotal; - @endphp - {{ number_format($adjustment, 2) }} - | -||||
| @@ -153,13 +147,21 @@ | {{ number_format($transaction->tax, 2) }} | |||||
| + | Adjustment | +{{ roundUpPo($discrepancy,2) }} | +||||
| Total | - @php - $total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount; - @endphp {{ number_format($total, 2) }} | |||||