diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php index fb21f138..49a59f05 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateGroupsLogic.php @@ -84,6 +84,25 @@ class CreateGroupsLogic extends AbstractControllerLogic // $invoices = $this->fetchesTransaction->execute(['id_in' => $invoice_ids]); $invoices = Transaction::whereIn('id', $invoice_ids)->get(); + foreach ($invoices as $invoice) { + $order = null; + if ($invoice->owner instanceof Transaction) { + if ($invoice->owner) { + if ($invoice->owner->owner) { + $order = $invoice->owner->owner->owner; + } + } + } else if (!($invoice->owner instanceof Transaction) && !($invoice->owner instanceof Wallet)) { + if ($invoice->owner) { + $order = $invoice->owner->owner; + } + } + + if (!$order) { + throw new MalformedRequestException("There is an error while paying for invoice {$invoice->bill_no}"); + } + } + if ($payment_method == PaymentMethodType::WALLET) { $companyModuleId = $invoices->first()->receiver; diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index 74fa69ad..87badb43 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -26,9 +26,15 @@ class TransactionResource extends JsonResource $groupTransactions = null; if ($this->owner instanceof Transaction) { - $order = new OrderResource($this->owner->owner->owner); + if ($this->owner) { + if ($this->owner->owner) { + $order = new OrderResource($this->owner->owner->owner); + } + } } else if (!($this->owner instanceof Transaction) && !($this->owner instanceof Wallet)) { - $order = new OrderResource($this->owner->owner); + if ($this->owner) { + $order = new OrderResource($this->owner->owner); + } } else { $group = Group::where('reference', $this->payment_reference)->first(); if ($group) { diff --git a/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue b/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue index 1bbc1253..daf67ab6 100644 --- a/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue +++ b/resources/assets/vue/components/paymentsBilling/elements/PaymentsBillingComponents.vue @@ -1,5 +1,5 @@