Open mgkimsal opened 3 years ago
Looking at this more, I'm guessing more people use a 'loose collection' style... ?
Invoice::create([
'CustomerRef'=>['value'=>58],
'Lines'=>[],// etc
]);
and perhaps this wasn't/isn't a problem?
I was/am using code more like this...
$customerRef = new IPPReferenceType();
$customerRef->value = $qbCustomer->Id;
$customerRef->name = $qbCustomer->FullyQualifiedName;
$qbInvoice = new IPPInvoice();
$qbInvoice->CustomerRef = $customerRef;
...
$qbInvoice->Lines = []; // multiple IPPLines there
$quickbooks->Add($qbInvoice);
This is where I kept getting "CustomerRef is missing" errors, because the Add() call something that eventually gets down to a serializer - XML or JSON. The XML one never worked for me...
Trying to get property 'CustomLogger' of non-object in .../vendor/quickbooks/v3-php-sdk/src/Core/Http/Serialization/XmlObjectSerializer.php
When I discovered you could swap with ->useJson() it seemed to get much farther than that, and I got real 'error messages' back - I tried to dig in to the XmlObjectSerializer.php a bit more but... there's some magic going on there that I couldn't get past.
This was a problem for me on both PHP 7.4.20 and 8.0.6. The 'fix' I have works in both cases.
https://github.com/intuit/QuickBooks-V3-PHP-SDK/pull/420
I've seen others with the same error messages I was seeing yesterday
"CustomerRef is missing" from posting an Invoice object.
Using JSON, the serializer 'removeNullProperties' method was filtering out the "CustomerRef" key/value, because the value itself was not a 'recurrsiveArray' (typo there - wasn't sure if I should change that too?)
Added a test to validate/demonstrate what I need (and assume should be correct behavior).
If there's a better way to fix this, please let me know.
I can't be the only one who's hit this, but... I've also been able to simply create an invoice for a customer for 2 days now, and traced it down to this.