diff --git a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php
index 535e5d29..b0bcbd93 100644
--- a/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php
+++ b/app/Classes/Modules/PackingLists/Processors/ListPackingListsJobProcessor.php
@@ -7,8 +7,11 @@ use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
use App\Classes\Modules\Jobs\Processors\UpdateJobResultProcessor;
use App\Classes\General\Helper;
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;
+use App\Http\Middleware\CheckForStorageInvoiceByPackingLists;
use App\Http\Resources\ListPackingListJobResource;
use App\Http\Resources\ListPackingListDetailsJobResource;
+use App\Http\Resources\ListPackingListJobWithStorageResource;
+use Illuminate\Support\Facades\Log;
class ListPackingListsJobProcessor
{
@@ -19,15 +22,19 @@ class ListPackingListsJobProcessor
/** @var UpdateJobResultProcessor */
private $updateJobResultProcessor;
+ /** @var CheckForStorageInvoiceByPackingLists */
+ private $checkForStorageInvoiceByPackingLists;
+
/**
* ListPackingListsJobProcessor constructor.
* @param ListsPackingLists $listsPackingLists
* @param UpdateJobResultProcessor $updateJobResultProcessor
*/
- public function __construct(ListsPackingLists $listsPackingLists, UpdateJobResultProcessor $updateJobResultProcessor)
+ public function __construct(ListsPackingLists $listsPackingLists, UpdateJobResultProcessor $updateJobResultProcessor, CheckForStorageInvoiceByPackingLists $checkForStorageInvoiceByPackingLists)
{
$this->listsPackingLists = $listsPackingLists;
$this->updateJobResultProcessor = $updateJobResultProcessor;
+ $this->checkForStorageInvoiceByPackingLists = $checkForStorageInvoiceByPackingLists;
}
/**
@@ -41,18 +48,40 @@ class ListPackingListsJobProcessor
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page']]);
// $query = $this->listsPackingLists->execute(array_merge($this->listsPackingLists->deserializeFilters($listGenericJobObject->getPayload()['filters']), ['page' => $listGenericJobObject->getPayload()['page'], 'with_containers_packages' => true]));
- foreach ($query->items() as &$item) {
- $item['userInfo'] = $listGenericJobObject->getUserInfo();
+ $filtersArray = json_decode($listGenericJobObject->getPayload()['filters'], true);
+
+ $storages = [];
+ if(isset($filtersArray['check_for_storage_invoice']))
+ {
+ $myRequest = new \Illuminate\Http\Request();
+ $myRequest->setMethod('POST');
+ $myRequest->request->add($listGenericJobObject->getPayload());
+ $next = function ($request) {
+ return $request;
+ };
+
+ $response = $this->checkForStorageInvoiceByPackingLists->handle($myRequest, $next);
+ $storages = $response->input('storages');
}
- $filtersArray = json_decode($listGenericJobObject->getPayload()['filters'], true);
- if(isset($filtersArray['does_not_have_transaction_type'])){ //For Pending Invoice query
+ foreach ($query->items() as &$item) {
+ $item['userInfo'] = $listGenericJobObject->getUserInfo();
+ $item['storages'] = $storages;
+ }
+
+ if(isset($filtersArray['does_not_have_transaction_type'])){ //For Payment and Billing page > Pending Invoice tab
$resultCurrent = Helper::collectionResponse(ListPackingListDetailsJobResource::collection($query));
$this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
}
else{
- $resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query));
- $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
+ if($storages){ //For Payment and Billing page > Pending Payment tab, Paid Invoice tab
+ $resultCurrent = Helper::collectionResponse(ListPackingListJobWithStorageResource::collection($query));
+ $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
+ }
+ else{
+ $resultCurrent = Helper::collectionResponse(ListPackingListJobResource::collection($query));
+ $this->updateJobResultProcessor->execute($listGenericJobObject, $resultCurrent);
+ }
}
}
}
diff --git a/app/Http/Resources/ListPackingListJobWithStorageResource.php b/app/Http/Resources/ListPackingListJobWithStorageResource.php
new file mode 100644
index 00000000..2cb01699
--- /dev/null
+++ b/app/Http/Resources/ListPackingListJobWithStorageResource.php
@@ -0,0 +1,57 @@
+userInfo ? $this->userInfo->type : Auth()->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 PackingListV2Resource(PackingList::where('reference', $this->reference)->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->first(), $this->userInfo)),
+ // 'packages' => PackageResource::collection($packages),
+ // $this->mergeWhen($this->owner instanceof Order, [
+ // 'order' => New OrderResource($this->owner)
+ // ]),
+ 'container' => new ContainerResource($this->containers->first()),
+ 'packages' => PackageWithoutOrderResource::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()),
+ // 'suspended_invoices' => TransactionResource::collection($this->transactions()->where('type', TransactionType::SHIPPING_INVOICE)->whereIn('status', [ApprovalStatus::SUSPENDED])->get()),
+ ];
+ }
+}
diff --git a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue
index 9b2cc71f..6cbfa39e 100644
--- a/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue
+++ b/resources/assets/vue/components/paymentsBilling/elements/AdminPaymentsBillingWithSearchComponent.vue
@@ -34,18 +34,12 @@
-