diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php index b9e3142d..1a63eb89 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php @@ -6,8 +6,8 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic; use App\Classes\General\Abstracts\AbstractControllerLogic; use App\Classes\Modules\PackingLists\Services\ListsPackingLists; use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists; -use App\Http\Resources\PackingListNullOrderResource; use App\Http\Resources\PackingListResource; +use App\Http\Resources\PackingListWithStorageResource; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; @@ -54,7 +54,14 @@ class ListPackingListsLogic extends AbstractControllerLogic $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters'))); - return $this->collectionResponse(PackingListResource::collection($query)); + if($request->input('storages')){ + foreach ($query->items() as $item) { + $item['storages'] = $request->input('storages'); + } + return $this->collectionResponse(PackingListWithStorageResource::collection($query)); + } + else{ + return $this->collectionResponse(PackingListResource::collection($query)); + } } - } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index d458f7b1..fcd38fae 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -73,5 +73,6 @@ class Kernel extends HttpKernel 'storage.invoice.check.byorder' => \App\Http\Middleware\CheckForStorageInvoiceByOrderId::class, 'storage.invoice.check.bytransactions' => \App\Http\Middleware\CheckForStorageInvoiceByTransactions::class, 'storage.invoice.check.bygroup' => \App\Http\Middleware\CheckForStorageInvoiceByGroup::class, + 'storage.invoice.check.bypackinglists' => \App\Http\Middleware\CheckForStorageInvoiceByPackingLists::class, ]; } diff --git a/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php new file mode 100644 index 00000000..28588555 --- /dev/null +++ b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php @@ -0,0 +1,67 @@ +storageInvoiceTransactionProcessor = $storageInvoiceTransactionProcessor; + $this->listsPackingLists = $listsPackingLists; + } + + + /** + * Handle an incoming request. + * + * @param Request $request + * @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse + */ + public function handle(Request $request, Closure $next) + { + $results = []; + $packinglists = null; + + $filters = json_decode($request->input('filters'), true); + // $filters['type_in'] = [TransactionType::SHIPPING_INVOICE]; + // if(json_encode($filters['order_by']) == '{"column":"id","DESC":true}'){ + // $filters['order_by_id_desc'] = true; + // } + // unset($filters['order_by']); + + if(isset($filters['check_for_storage_invoice'])){ + $packinglists = $this->listsPackingLists->execute($filters); + foreach($packinglists as $packingList){ + if($packingList){ + $order = $packingList->owner()->first(); + if($order instanceof Order){ + $storages = $this->storageInvoiceTransactionProcessor->executeOrder($order); + if($storages){ + $results = array_merge($results, $storages); + } + } + } + } + } + + $request->merge(['storages' => $results]); + + return $next($request); + } +} diff --git a/app/Http/Resources/PackingListWithStorageResource.php b/app/Http/Resources/PackingListWithStorageResource.php new file mode 100644 index 00000000..386af053 --- /dev/null +++ b/app/Http/Resources/PackingListWithStorageResource.php @@ -0,0 +1,56 @@ +user()->type, [RoleTypes::SHADOW_ADMIN, RoleTypes::SUPER_ADMIN]); + $packages = !$this->packingLists()->exists() || $exceptionUsers ? $this->packages : $this->packingLists->first()->packages; + $shippingTransaction = $this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereNotIn('status', [ApprovalStatus::SUSPENDED, ApprovalStatus::EXPIRED])->first(); + $transactions = $this->transactions()->whereNotIn('transactions.status', [0, 1])->whereIn('transactions.type', [TransactionType::SHIPPING_INVOICE, TransactionType::STORAGE_INVOICE])->get(); + $storages = []; + + if($this->storages){ + $transactionId = $shippingTransaction->id; + $filteredStorages = array_filter($this->storages, function ($storage) use ($transactionId) { + return isset($storage['parentInvoiceId']) && $storage['parentInvoiceId'] == $transactionId; + }); + $storages = $filteredStorages; + } + + return [ + 'id' => $this->id, + 'claimant_id' => $this->claimant_id, + 'reference' => $this->reference, + 'status' => $this->status, + 'transport' => new TransportResource($this->transports()->first()), + 'type' => $this->type, + 'receive_packing_list' => $this->when($this->type === PackingListType::SHIPPING_PACKING_LIST, new PackingListResource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first())), + 'packages' => PackageResource::collection($packages), + $this->mergeWhen($this->owner instanceof Order, [ + 'order' => New OrderResource($this->owner) + ]), + 'shipping_transaction' => count($storages) == 0 ? new TransactionWithStorageResource($shippingTransaction): null, + 'storages' => $storages, + 'invoices' => TransactionWithStorageResource::collection($transactions), + 'suspended_invoice' => new TransactionResource($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->first()), + ]; + } +} diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue index be4038bb..9b2cc71f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue @@ -37,7 +37,8 @@ +
+

Total CBM

+
{{ (parseFloat(cbm) + parseFloat(overweight)).toFixed(3) }}
+
+ + + + +
Invoice Details
+ + +
+
+

Subtotal

+
{{ item.shipping_transaction.amount - item.shipping_transaction.service_charge - item.shipping_transaction.tax }}
+
+
+

Service Charges

+
{{ item.shipping_transaction.service_charge }}
+
+
+

Tax

+
{{ item.shipping_transaction.tax }}
+
+
+

Total

+
{{ item.shipping_transaction.amount }}
+
+
+ + +
+
+
+
+
+
+
+
+
Payment Attempt
+
+
+
+
+ +
+
+
+
+
+
+
+
+
Payment History
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
Total Amount:
+
+
+
MYR {{(Math.round((item.shipping_transaction.amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
+
+
+
Paid Total:
+
+
+ +
Paid Total
+
+
+
+
+
Floating Amount:
+
+
+ +
Floating Amount
+
+
+
+
+
OutStanding Total:
+
+
+
MYR {{(Math.round((item.shipping_transaction.outstanding + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
+
+
+
+
+
Make Payment
+
+
+
+
+ + + +
+
+
+
+ + + + diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue new file mode 100644 index 00000000..acf2ed18 --- /dev/null +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleParentAdminPaymentsBillingComponent.vue @@ -0,0 +1,77 @@ + + diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index ee91d849..190ebe17 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -113,12 +113,12 @@
- +
- +
diff --git a/routes/packing_list.php b/routes/packing_list.php index 5282522a..dcee2dee 100644 --- a/routes/packing_list.php +++ b/routes/packing_list.php @@ -4,7 +4,8 @@ use Illuminate\Support\Facades\Route; Route::group(['namespace' => 'PackingLists', 'as' => 'packing_list.', 'prefix' => 'packing_list'], function () { Route::get('/{id}/show', 'FetchPackingListController@fetch')->name('show'); - Route::get('/list', 'ListPackingListsController@list')->name('list'); + Route::get('/list', 'ListPackingListsController@list')->middleware('storage.invoice.check.bypackinglists')->name('list'); + // Route::get('/list', 'ListPackingListsController@list')->name('list'); Route::get('/list/job', 'ListPackingListsJobController@list')->name('list.job'); Route::post('/create', 'CreatePackingListController@create')->name('create'); Route::post('/create/deliver', 'CreateDeliverPackingListController@create')->name('create.deliver');