intuit / QuickBooks-V3-PHP-SDK

Official PHP SDK for QuickBooks REST API v3.0: https://developer.intuit.com/
Apache License 2.0
241 stars 240 forks source link

Null Custom Logger - Can't use Update Method #484

Open BucksterBuckster opened 1 year ago

BucksterBuckster commented 1 year ago

When I try to use the update method, I am getting an error and can't get past that. The error is triggering from line 52 on XmlObjectSerializer.php. The specific error is Attempt to read property "CustomLogger" on null

Here is my code where I am calling the method: `public function updateQuickbooksInvoice(): void { $dataService = app('quickbooksConnector');

    $invoice = $dataService->client->FindById(\QuickBooksOnline\API\Facades\Invoice::create([
        'Id' => $this->id_qb_invoice,
    ]));
    $termId = $dataService->query("SELECT * FROM Term WHERE Name = '$this->payment_terms'")[0]->Id;
    $organization = $this->organization;
    if (! $organization->hasQbCustomerAccount()) {
        $organization->createQuickbooksCustomer();
    }

    $details = $this->details;
    $detailsToCreate = $details->filter(function ($detail) {
        return $detail->qb_id === '';
    });
    array_pop($invoice->Line);
    $lineDetails = [];
    foreach ($invoice->Line as $key => $item) {
        $detail = $details->where('qb_id', $item->Id)->first();
        if ($detail === null) {
            unset($invoice->Line[$key]);

            continue;
        }
        $item->Amount = $detail->total;
        $item->Description = $detail->description;
        $item->SalesItemLineDetail = [
            'Qty' => $detail->qty,
            'UnitPrice' => $detail->rate,
        ];
        $lineDetails[] = $item;
    }
    foreach ($detailsToCreate as $item) {
        $lineDetails[] = Line::create([
            'Amount' => $item->total,
            'DetailType' => 'SalesItemLineDetail',
            'Description' => $item->description,
            'SalesItemLineDetail' => [
                'Qty' => $item->qty,
                'UnitPrice' => $item->rate,
            ],
        ]);
    }
    $invoiceToUpdate = \QuickBooksOnline\API\Facades\Invoice::update($invoice, [
        'sparse' => true,
        'CustomerRef' => [
            'value' => $organization->getQbCustomerId(),
        ],
        'TxnDate' => $this->date_sent,
        'DueDate' => $this->date_due,
        'Balance' => $this->balance_due,
        'CurrencyRef' => [
            'value' => 'USD',
        ],
        'SalesTermRef' => [
            'value' => $termId,
        ],
        'Line' => $lineDetails,
    ]);
    $updatedInvoice = $dataService->update($invoiceToUpdate);
    $this->updateLineItemDetailsAfterQuickbooksSave($updatedInvoice);
}`

Is there any way I can get around this without having to call the API via a different means than the SDK?