diff --git a/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php b/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php index 1ebc952d..2c598ea3 100644 --- a/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php +++ b/app/Classes/General/Eloquent/Filters/PackingListLimitOneByTypeOrderedByInvoiceDate.php @@ -28,6 +28,40 @@ class PackingListLimitOneByTypeOrderedByInvoiceDate implements Filter SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1 ))'); })->orderBy('transactions.updated_at', 'DESC'); - } + //Original with problem + // return $builder->select('packing_lists.*')->join('transactions', function($join){ + // $join->on('transactions.owner_id', '=', 'packing_lists.id'); + // $join->where('transactions.owner_type', '=', PackingList::class); + // $join->where('transactions.status', '=', ApprovalStatus::APPROVED); + // $join->whereNull('transactions.deleted_at'); + // $join->whereRaw('(transactions.type <> 16 OR transactions.id = ( + // SELECT id FROM transactions WHERE owner_id = packing_lists.id AND type = 16 LIMIT 1 + // ))'); + // })->orderBy('transactions.updated_at', 'DESC'); + + //Attempt 1 + // return $builder->with(['transactions' => function ($query) { + // $query->where('status', ApprovalStatus::APPROVED) + // ->whereNull('deleted_at') + // ->whereRaw('( + // transactions.type <> 16 OR transactions.id = ( + // SELECT id FROM transactions AS t2 + // WHERE t2.owner_id = transactions.owner_id + // AND t2.owner_type = ? + // AND t2.type = 16 + // LIMIT 1 + // ) + // )', [PackingList::class]) + // ->orderBy('updated_at', 'DESC'); + // }]); + + //Attempt 2 + // return $builder->with(['transactions' => function ($query) { + // $query->where('status', ApprovalStatus::APPROVED) + // ->where('type', '<>', 16 ) + // ->whereNull('deleted_at') + // ->orderBy('updated_at', 'DESC'); + // }]); + } } diff --git a/app/Classes/General/Eloquent/Filters/PackingListOrderedByInvoiceDate.php b/app/Classes/General/Eloquent/Filters/PackingListOrderedByInvoiceDate.php index a8981a19..1fdb2321 100644 --- a/app/Classes/General/Eloquent/Filters/PackingListOrderedByInvoiceDate.php +++ b/app/Classes/General/Eloquent/Filters/PackingListOrderedByInvoiceDate.php @@ -23,6 +23,7 @@ class PackingListOrderedByInvoiceDate implements Filter $join->on('transactions.owner_id', '=', 'packing_lists.id'); $join->where('transactions.owner_type', '=', PackingList::class); $join->where('transactions.status', '=', ApprovalStatus::APPROVED); + $join->whereNull('transactions.deleted_at'); })->orderBy('transactions.updated_at', 'DESC'); } diff --git a/app/Classes/Jobs/Commands/V2/CheckStorageInvoicesSingleOrderV2CommandJob.php b/app/Classes/Jobs/Commands/V2/CheckStorageInvoicesSingleOrderV2CommandJob.php new file mode 100644 index 00000000..db6f06eb --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/CheckStorageInvoicesSingleOrderV2CommandJob.php @@ -0,0 +1,44 @@ +order = $order; + } + + public function handle() + { + Log::info(Carbon::now() . ': Start job - Check single order for storage invoice.'); + $start = new Carbon(); + + try{ + Log::info("Processing Order - ID: {$this->order->id}, Reference: {$this->order->reference}"); + (App()->make(CheckStorageInvoiceTransactionProcessor::class))->executeOrder($this->order); + } + catch(\Exception $ex){ + Log::info('Exception '.$ex->getMessage()); + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - Check single order for storage invoice. ElapsedTime: ' . $elapsedTime . '.'); + } +} diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php index 16ac1272..70c02729 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/ListPackingListsLogic.php @@ -55,9 +55,6 @@ class ListPackingListsLogic extends AbstractControllerLogic $query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters'))); - $data = json_encode($request->input('storages')); - Log::info("ListPackingListsLogic storages A"); - // if($request->input('storages')){ // Log::info("ListPackingListsLogic storages B"); // foreach ($query->items() as $item) { @@ -67,6 +64,8 @@ class ListPackingListsLogic extends AbstractControllerLogic // } $filters = json_decode($request->input('filters'), true); + Log::info('ListPackingListsLogic storages A with Filters:' . json_encode($filters)); + $useNew = false; foreach ($query->items() as $item) { //from middleware diff --git a/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php index a393e3b5..ac293df4 100644 --- a/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php +++ b/app/Http/Middleware/CheckForStorageInvoiceByPackingLists.php @@ -2,6 +2,7 @@ namespace App\Http\Middleware; +use App\Classes\Jobs\Commands\V2\CheckStorageInvoicesSingleOrderV2CommandJob; use Closure; use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor; use App\Classes\Modules\PackingLists\Services\ListsPackingLists; @@ -47,15 +48,25 @@ class CheckForStorageInvoiceByPackingLists // } if(isset($filters['check_for_storage_invoice'])){ - unset($filters['order_by']); - $packinglists = $this->listsPackingLists->execute($filters); + // unset($filters['order_by']); //cief todo: 90 - DEBUG, original + // $packinglists = $this->listsPackingLists->execute($filters); //cief todo: 90 - DEBUG, original + + $packinglists = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters'))); //cief todo: 90 - DEBUG + Log::info('CheckForStorageInvoiceByPackingLists $packinglists ' . count($packinglists)); + Log::info('CheckForStorageInvoiceByPackingLists $packinglists ' . json_encode($packinglists)); //cief todo: 90 - DEBUG 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); + if(isset($filters['check_for_storage_invoice_asynchronously'])){ + Log::info("check_for_storage_invoice_asynchronously Order - ID: {$order->id}, Reference: {$order->reference}"); + CheckStorageInvoicesSingleOrderV2CommandJob::dispatch($order); + } + else{ + $storages = $this->storageInvoiceTransactionProcessor->executeOrder($order); + if($storages){ + $results = array_merge($results, $storages); + } } } } diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue index f4a9fb53..5839794f 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithStorageComponent.vue @@ -16,14 +16,14 @@

Container

-
{{item.packages[0].container.container_reference}}
+
{{item.packages[0].container.container_reference}}
{{item.container.container_reference}}

Invoice Date

({{ singleInvoice.bill_no }})
n/a
-
{{ singleInvoice.updated_at }}
+
{{ singleInvoice.created_at }}
@@ -75,9 +75,9 @@
-
+
@@ -96,7 +96,7 @@
-
+
diff --git a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue index 3b9aafab..f92fee28 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/SingleAdminPaymentsBillingWithoutStorageComponent.vue @@ -75,9 +75,9 @@
-
+
@@ -196,7 +196,7 @@
-
+ +
MYR {{(Math.round((item.shipping_transaction.paid_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
Paid Total
@@ -259,7 +259,7 @@
Floating Amount:
- +
MYR {{(Math.round((item.shipping_transaction.floating_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
Floating Amount
@@ -295,7 +295,7 @@ - + --> diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue index a8315f55..e928bb21 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingPollingSectionComponent.vue @@ -113,7 +113,8 @@
- + +
diff --git a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue index 92d8ef4c..bd23d9ae 100644 --- a/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue +++ b/resources/assets/vue/components/paymentsBilling/sections/AdminPaymentsBillingSectionComponent.vue @@ -113,7 +113,8 @@
- + +