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 @@ +
+ + +
@@ -19,7 +28,12 @@
- +
@@ -38,6 +52,11 @@
+
+
+ Edit Profile Info +
+
@@ -61,7 +80,15 @@ - + + + + + + + + + @@ -75,6 +102,10 @@ type:Object, required:true }, + section: { + type: String, + required: true + }, }, mounted(){ this.$root.$on('deleteAddressConfirm', (id) => { @@ -93,7 +124,7 @@ data(){ return { minWidth:{ - minWidth:'100px', + minWidth:'120px', }, minWidth150:{ minWidth:'150px', @@ -173,8 +204,22 @@ backToCompanyList() { this.$root.$emit('backToCompanyList'); }, - getBusinessTypeDesc(type){ - return (type==1) ? 'Company Account':'Personal Account'; + getBusinessTypeDesc(business_type_id) { + switch (business_type_id) { + case 1: + return 'Freight Forwarder'; + case 2: + return 'Importer'; + case 3: + return 'Currency Vendor'; + case 4: + return 'Transfer Agent'; + default: + return null; + } + }, + getCompanyTypeDesc(company_type_id) { + return (company_type_id == 1) ? 'Company Business' : 'Personal Business'; }, }, mixins: [componentHandler] diff --git a/resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue new file mode 100644 index 00000000..c15091b5 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EditCustomerCompanyTypeFormComponent.vue @@ -0,0 +1,71 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue new file mode 100644 index 00000000..0145e057 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EditCustomerContactNumberFormComponent.vue @@ -0,0 +1,70 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue b/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue new file mode 100644 index 00000000..949ab2a4 --- /dev/null +++ b/resources/assets/vue/components/companies/forms/EditCustomerProfileInfoFormComponent.vue @@ -0,0 +1,89 @@ + + \ No newline at end of file diff --git a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue index c8a07bf9..bd646426 100644 --- a/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue +++ b/resources/assets/vue/components/companies/sections/CustomerProfileSectionComponent.vue @@ -122,7 +122,7 @@
- +
diff --git a/resources/views/pages/pdfs/deliver_order.blade.php b/resources/views/pages/pdfs/deliver_order.blade.php index ba30bc68..c59cc5a9 100644 --- a/resources/views/pages/pdfs/deliver_order.blade.php +++ b/resources/views/pages/pdfs/deliver_order.blade.php @@ -69,6 +69,7 @@

+ @@ -81,34 +82,37 @@ @php - $subtotal = 0; - $voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null; - $voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0; - $currencyRate = $transaction->currency_rate; + $subtotal = calculateDoSubtotal($po_order_transaction, $transaction->currency_rate); + $voucherDiscount = getDoVoucherDiscount($voucher_redemption); + $displayedSubtotal = 0; @endphp + @foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail) + @php + $exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5); + $itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5); + $displayedItemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 2); + $displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2); + @endphp @endforeach + @php + $voucherDiscount = getDoVoucherDiscount($voucher_redemption); + $subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract + @endphp @@ -117,27 +121,17 @@ - + + @if($voucher_redemption) - + @endif - - - - - + @if($transaction->tax > 0) @@ -145,13 +139,21 @@ @endif + @php + $displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2); + $expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); + $discrepancy = bcsub($displayedTotal, $expectedTotal, 5); + $total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); // Keep precision + @endphp + + + + + @@ -165,4 +167,28 @@
No
{{ $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
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) }} -
{{ number_format($transaction->tax, 2) }}
Adjustment{{ roundUpDo($discrepancy,2) }}
Total - @php - $total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount; - @endphp {{ number_format($total, 2) }}
+ @php + function calculateDoSubtotal($po_order_transaction, $currencyRate) { + $subtotal = "0"; + foreach ($po_order_transaction->transactionDetails as $transaction_detail) { + $unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5); + $itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5); + $subtotal = bcadd($subtotal, $itemTotal, 5); + } + return $subtotal; + } + + function getDoVoucherDiscount($voucher_redemption) { + return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; + } + function roundUpDo($number, $decimals) { + $factor = pow(10, $decimals); + if ($number > 0) { + return ceil($number * $factor) / $factor; + } else { + return floor($number * $factor) / $factor; + } + } + + @endphp @endsection diff --git a/resources/views/pages/pdfs/invoice.blade.php b/resources/views/pages/pdfs/invoice.blade.php index ca45e766..066fb971 100644 --- a/resources/views/pages/pdfs/invoice.blade.php +++ b/resources/views/pages/pdfs/invoice.blade.php @@ -1,21 +1,21 @@ @extends('layouts.base_pdf') + @section('inner_content') +


{{ $transaction->bill_no }}
+ +
- - - 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 }}
 
@@ -38,37 +32,34 @@
- - 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 }}


+ + + @@ -81,35 +72,37 @@ @php - $subtotal = 0; - $voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null; - - $voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0; - $currencyRate = $transaction->currency_rate; + $subtotal = calculateSubtotal($po_order_transaction, $transaction->currency_rate); + $voucherDiscount = getVoucherDiscount($voucher_redemption); + $displayedSubtotal = 0; @endphp + @foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail) + @php + $exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5); + $itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5); + $displayedItemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 2); + $displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2); + @endphp @endforeach + @php + $voucherDiscount = getVoucherDiscount($voucher_redemption); + $subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract + @endphp @@ -120,23 +113,15 @@ + @if($voucher_redemption) - + @endif - - - - - + @if($transaction->tax > 0) @@ -144,24 +129,59 @@ @endif + @php + $displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2); + $expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); + $discrepancy = bcsub($displayedTotal, $expectedTotal, 5); + $total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); // Keep precision + @endphp + + + + +
No
{{ $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) }}
SubtotalService 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) }} -
{{ 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}
-
+
+
+ Note: All items purchased are subject to our Terms & Conditions. Please refer to our official website for more information. +
+

+
+ Please transfer the payment to:
+ Bank: Maybank Berhad
+ Account Name: CIEF Worldwide Sdn Bhd
+ Account No: 564892103405
+
+ @php + function calculateSubtotal($po_order_transaction, $currencyRate) { + $subtotal = "0"; + foreach ($po_order_transaction->transactionDetails as $transaction_detail) { + $unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5); + $itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5); + $subtotal = bcadd($subtotal, $itemTotal, 5); + } + return $subtotal; + } + + function getVoucherDiscount($voucher_redemption) { + return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; + } + function roundUp($number, $decimals) { + $factor = pow(10, $decimals); + if ($number > 0) { + return ceil($number * $factor) / $factor; + } else { + return floor($number * $factor) / $factor; + } + } + + @endphp @endsection diff --git a/resources/views/pages/pdfs/purchase_order.blade.php b/resources/views/pages/pdfs/purchase_order.blade.php index 79841363..e9d1c8fd 100644 --- a/resources/views/pages/pdfs/purchase_order.blade.php +++ b/resources/views/pages/pdfs/purchase_order.blade.php @@ -77,6 +77,7 @@
+ @@ -89,34 +90,37 @@ @php - $subtotal = 0; - $voucher_redemption = isset($voucher_redemption) ? $voucher_redemption : null; - $voucherDiscount = $voucher_redemption ? $voucher_redemption->value * -1 : 0; - $currencyRate = $transaction->currency_rate; + $subtotal = calculatePoSubtotal($po_order_transaction, $transaction->currency_rate); + $voucherDiscount = getPoVoucherDiscount($voucher_redemption); + $displayedSubtotal = 0; @endphp + @foreach ($po_order_transaction->transactionDetails as $key => $transaction_detail) + @php + $exactUnitPrice = bcdiv($transaction_detail->price, $transaction->currency_rate, 5); + $itemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 5); + $displayedItemTotal = bcmul($exactUnitPrice, $transaction_detail->quantity, 2); + $displayedSubtotal = bcadd($displayedSubtotal, $displayedItemTotal, 2); + @endphp @endforeach + @php + $voucherDiscount = getPoVoucherDiscount($voucher_redemption); + $subtotalWithDiscount = bcsub($subtotal, $voucherDiscount, 5); // Use bcsub to subtract + @endphp @@ -125,27 +129,17 @@ - + + @if($voucher_redemption) - + @endif - - - - - + @if($transaction->tax > 0) @@ -153,13 +147,21 @@ @endif + @php + $displayedTotal = bcadd(bcadd(bcadd($displayedSubtotal, $transaction->service_charge, 2), $transaction->tax, 2), $voucherDiscount, 2); + $expectedTotal = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); + $discrepancy = bcsub($displayedTotal, $expectedTotal, 5); + $total = bcadd(bcadd(bcadd($subtotal, $transaction->service_charge, 5), $transaction->tax, 5), $voucherDiscount, 5); // Keep precision + @endphp + + + + + @@ -173,4 +175,28 @@
No
{{ $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
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) }} -
{{ number_format($transaction->tax, 2) }}
Adjustment{{ roundUpPo($discrepancy,2) }}
Total - @php - $total = $subtotal + $transaction->service_charge + $transaction->tax + $voucherDiscount; - @endphp {{ number_format($total, 2) }}
+ @php + function calculatePoSubtotal($po_order_transaction, $currencyRate) { + $subtotal = "0"; + foreach ($po_order_transaction->transactionDetails as $transaction_detail) { + $unitPrice = bcdiv((string)$transaction_detail->price, (string)$currencyRate, 5); + $itemTotal = bcmul($unitPrice, (string)$transaction_detail->quantity, 5); + $subtotal = bcadd($subtotal, $itemTotal, 5); + } + return $subtotal; + } + + function getPoVoucherDiscount($voucher_redemption) { + return $voucher_redemption ? bcmul((string)$voucher_redemption->value, "-1", 2) : "0"; + } + function roundUpPo($number, $decimals) { + $factor = pow(10, $decimals); + if ($number > 0) { + return ceil($number * $factor) / $factor; + } else { + return floor($number * $factor) / $factor; + } + } + + @endphp @endsection diff --git a/routes/company.php b/routes/company.php index 6571daa4..18997c8d 100644 --- a/routes/company.php +++ b/routes/company.php @@ -7,10 +7,14 @@ Route::group(['prefix' => 'company', 'as' => 'company.', 'namespace' => 'Compani Route::get('/list', 'ListCompaniesController@list')->name('list'); Route::post('/create', 'CreateCompanyController@create')->name('create'); Route::put('/update/{id}', 'UpdateCompanyController@update')->name('update'); + Route::put('/update/{id}/profile', 'UpdateCompanyProfileController@update')->name('profile.update'); Route::put('update/{id}/status', 'UpdateCompanyStatusController@update')->name('status.update'); Route::delete('/delete/{id}', 'DeleteCompanyController@destroy')->name('delete'); Route::put('/name-and-debtor/update/{id}', 'UpdateCompanyNameAndDebtorController@update')->name('update.nameAndDebtor'); + Route::get('/business-type/list', 'ListBusinessTypesController@list')->name('business_type.list'); + Route::get('/company-type/list', 'ListCompanyTypesController@list')->name('company_type.list'); + Route::put('/update/debtor/{id}', 'UpdateCompanyDebtorController@update')->name('delete'); Route::post('/team/create', 'AddNewMemberController@create')->name('team.create');