intuit / QuickBooks-V3-PHP-SDK

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

Reading an Invoice that is past the 'Closing date' causes an Exception #456

Open akolahi opened 2 years ago

akolahi commented 2 years ago

This appears to be a new issue as we've been Reading closed invoices for years and never encountered this problem.

Reading or querying an invoice that is past the closing date causes the following error: Exception: "Exception appears in converting Response to XML. in QuickBooksOnline\API\DataService\DataService->Query() (line 1035 of .../libraries/qbo/src/DataService/DataService.php)"

Comparing the two xml responses: Working non-closed Invoice xml: "<QueryResponse startPosition="1" maxResults="1" totalCount="1"><Invoice sparse="true"><Id>xxxx</Id><BillAddr><Id>yyyy</Id></BillAddr></Invoice></QueryResponse>"

Non-working closed Invoice xml: "<QueryResponse startPosition="1" maxResults="1" totalCount="1"><Invoice sparse="true"><Id>xxxx</Id><BillAddr><Id>yyyy</Id></BillAddr><GratuityEnabled>false</GratuityEnabled></Invoice></QueryResponse>"

Appears the primary difference is the inclusion of "<GratuityEnabled>false</GratuityEnabled>" in the second response.

Removing the Gratuity property resolves the issue for us (private app for internal use only. we never utilize gratuity in invoices).

$tmpXML = str_replace('<GratuityEnabled>false</GratuityEnabled>', '', $tmpXML);

I suspect responseSerializer->Deserialize is failing to parse <GratuityEnabled>