From 8b2ef2acd47f96e178ce41f4561e1e6bb4aa4415 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sat, 7 Mar 2026 00:46:09 +0800 Subject: [PATCH] FIx an issue reported by Eileen, a customer payment and billing page not loading --- .../DeletePackingListByPackageIdLogic.php | 9 +++++++++ .../ControllersLogic/ListTransactionsLogic.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListByPackageIdLogic.php b/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListByPackageIdLogic.php index a221c501..9f6949e0 100644 --- a/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListByPackageIdLogic.php +++ b/app/Classes/Modules/PackingLists/ControllersLogic/DeletePackingListByPackageIdLogic.php @@ -9,10 +9,12 @@ use App\Classes\Modules\PackingLists\Services\FetchesPackingList; use App\Classes\Modules\PackingLists\Services\Packages\FetchesPackage; use App\Classes\Modules\PackingLists\Standards\Rules\CanDeletePackingList; use App\Classes\ValueObjects\Constants\PackingListType; +use App\Classes\ValueObjects\Constants\TransactionType; use App\Models\PackingList; use ErrorException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; class DeletePackingListByPackageIdLogic extends AbstractControllerLogic { @@ -69,6 +71,13 @@ class DeletePackingListByPackageIdLogic extends AbstractControllerLogic $packingList = PackingList::where('reference', $packingList->reference)->get(); + foreach ($packingList as $singlePL) { + $invoice_transaction = $singlePL->transactions()->where('transactions.type', TransactionType::SHIPPING_INVOICE)->get(); + if($invoice_transaction->count() > 0){ + throw new ErrorException('Effective 2026, packages cannot be deleted if a related invoice has already been generated. Please delete the invoice first before proceeding with this action. Please contact IT support for more information.'); + } + } + $childPackingList = PackingList::where('owner_type', PackingList::class)->whereIn('owner_id', $packingList->pluck('id'))->get(); $packingList->each->delete(); diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php index e92ee966..a0030317 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ListTransactionsLogic.php @@ -39,7 +39,7 @@ class ListTransactionsLogic extends AbstractControllerLogic { $query = $this->listsTransactions->execute($this->listsTransactions->deserializeFilters($request->input('filters'))); foreach ($query->items() as $item) { - if($item instanceof \App\Models\Transaction && $item->owner->owner->companyModule){ + if($item instanceof \App\Models\Transaction && $item->owner && $item->owner->owner->companyModule){ $item['is_einvoice_applicable'] = $item->owner->owner->companyModule->company->e_invoice === 1; } }