FIx an issue reported by Eileen, a customer payment and billing page not loading

This commit is contained in:
Dillon Ngo
2026-03-07 00:46:09 +08:00
parent f5f278fb77
commit 8b2ef2acd4
2 changed files with 10 additions and 1 deletions
@@ -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();
@@ -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;
}
}