From 36ff0332b2f97b6db5495f8c67b6e2c5fc85a8bd Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 26 Sep 2023 00:23:13 +0000 Subject: [PATCH] fix tests --- Controller/ApiController.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 790ab19..2eb2609 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -151,9 +151,9 @@ final class ApiController extends Controller // @todo: find possible candidate based on defined default stock for bill type/org/location // Handle to - if ($bill->client->id !== 0) { + if (($bill->client?->id ?? 0) !== 0) { $transaction->to = $bill->client->number; - } elseif ($bill->supplier->id !== 0) { + } elseif (($bill->supplier?->id ?? 0) !== 0) { $transaction->to = $bill->supplier->number; } @@ -164,9 +164,9 @@ final class ApiController extends Controller } } else { // Handle from - if ($bill->client->id !== 0) { + if (($bill->client?->id ?? 0) !== 0) { $transaction->from = $bill->client->number; - } elseif ($bill->supplier->id !== 0) { + } elseif (($bill->supplier?->id ?? 0) !== 0) { $transaction->from = $bill->supplier->number; } @@ -220,13 +220,14 @@ final class ApiController extends Controller return; } elseif ($trigger === 'POST:Module:Billing-bill-delete') { + /** @var \Modules\Billing\Models\Bill $new */ /** @var \Modules\Billing\Models\Bill $bill */ $bill = BillMapper::get() ->with('type') ->with('elements') ->with('supplier') ->with('client') - ->where('id', $new->bill->id) + ->where('id', $new->id) ->execute(); foreach ($bill->elements as $element) {