fix tests

This commit is contained in:
Dennis Eichhorn 2023-09-26 00:23:13 +00:00
parent 8505a25ef9
commit 36ff0332b2

View File

@ -151,9 +151,9 @@ final class ApiController extends Controller
// @todo: find possible candidate based on defined default stock for bill type/org/location // @todo: find possible candidate based on defined default stock for bill type/org/location
// Handle to // Handle to
if ($bill->client->id !== 0) { if (($bill->client?->id ?? 0) !== 0) {
$transaction->to = $bill->client->number; $transaction->to = $bill->client->number;
} elseif ($bill->supplier->id !== 0) { } elseif (($bill->supplier?->id ?? 0) !== 0) {
$transaction->to = $bill->supplier->number; $transaction->to = $bill->supplier->number;
} }
@ -164,9 +164,9 @@ final class ApiController extends Controller
} }
} else { } else {
// Handle from // Handle from
if ($bill->client->id !== 0) { if (($bill->client?->id ?? 0) !== 0) {
$transaction->from = $bill->client->number; $transaction->from = $bill->client->number;
} elseif ($bill->supplier->id !== 0) { } elseif (($bill->supplier?->id ?? 0) !== 0) {
$transaction->from = $bill->supplier->number; $transaction->from = $bill->supplier->number;
} }
@ -220,13 +220,14 @@ final class ApiController extends Controller
return; return;
} elseif ($trigger === 'POST:Module:Billing-bill-delete') { } elseif ($trigger === 'POST:Module:Billing-bill-delete') {
/** @var \Modules\Billing\Models\Bill $new */
/** @var \Modules\Billing\Models\Bill $bill */ /** @var \Modules\Billing\Models\Bill $bill */
$bill = BillMapper::get() $bill = BillMapper::get()
->with('type') ->with('type')
->with('elements') ->with('elements')
->with('supplier') ->with('supplier')
->with('client') ->with('client')
->where('id', $new->bill->id) ->where('id', $new->id)
->execute(); ->execute();
foreach ($bill->elements as $element) { foreach ($bill->elements as $element) {