intuit / QuickBooks-V3-PHP-SDK

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

Property JournalEntry does not exist. Class IPPRecurringTransaction #408

Open gmariani opened 3 years ago

gmariani commented 3 years ago

Trying to retrieve a list of RecurringTransactions and I get this error.

$dataService->Query("select * from RecurringTransaction");

I am getting the following exception in PhpObjFromXml in /src/Core/Http/Serialization/XmlObjectSerializer.php of the SDK. I"m using version 6.0.1 of the SDK.

Property JournalEntry does not exist. Class QuickBooksOnline\API\Data\IPPRecurringTransaction

gmariani commented 3 years ago

Managed to patch this by adding this to /src/Data/IPPRecurringTransaction.php

    /**
     * @xmlType element
     * @xmlName JournalEntry
     * @varz com\intuit\schema\finance\v3\JournalEntry
     * @var IPPJournalEntry
     */
    public $JournalEntry;

    /**
     * @xmlType element
     * @xmlName Purchase
     * @varz com\intuit\schema\finance\v3\Purchase
     * @var IPPPurchase
     */
    public $Purchase;

    /**
     * @xmlType element
     * @xmlName Invoice
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPInvoice
     */
    public $Invoice;
gmariani commented 3 years ago

Had to also add this:

    /**
     * @xmlType element
     * @xmlName SalesReceipt
     * @varz com\intuit\schema\finance\v3\SalesReceipt
     * @var IPPSalesReceipt
     */
    public $SalesReceipt;

In order to get the correct error message, I have to modify error message in /src/DataService/DataService.php with this in order to get the actual error message:

try {
    $responseXmlObj = simplexml_load_string($responseBody);
    if ($responseXmlObj && $responseXmlObj->QueryResponse) {
        $tmpXML = $responseXmlObj->QueryResponse->asXML();
        $parsedResponseBody = $this->responseSerializer->Deserialize($tmpXML, false);
        $this->serviceContext->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, $parsedResponseBody);
    }
} catch (\Exception $e) {
    throw new \Exception("Exception appears in converting Response to XML.");
}

to

try {
    $responseXmlObj = simplexml_load_string($responseBody);
    if ($responseXmlObj && $responseXmlObj->QueryResponse) {
        $tmpXML = $responseXmlObj->QueryResponse->asXML();
        $parsedResponseBody = $this->responseSerializer->Deserialize($tmpXML, false);
        $this->serviceContext->IppConfiguration->Logger->CustomLogger->Log(TraceLevel::Info, $parsedResponseBody);
    }
} catch (\Exception $e) {
    echo print_r($e);
    throw new \Exception("Exception appears in converting Response to XML.");
}
gmariani commented 3 years ago

Looks like this is the complete list of types that should probably be added to support: Bill, Purchase, CreditMemo, Deposit, Estimate, Invoice, JournalEntry, RefundReceipt, SalesReceipt, Transfer, VendorCredit, and PurchaseOrder

exintrovert commented 1 year ago

Here is the entire list of types:

    /**
     * @xmlType element
     * @xmlName JournalEntry
     * @varz com\intuit\schema\finance\v3\JournalEntry
     * @var IPPJournalEntry
     */
    public $JournalEntry;

    /**
     * @xmlType element
     * @xmlName Purchase
     * @varz com\intuit\schema\finance\v3\Purchase
     * @var IPPPurchase
     */
    public $Purchase;

    /**
     * @xmlType element
     * @xmlName SalesReceipt
     * @varz com\intuit\schema\finance\v3\SalesReceipt
     * @var IPPSalesReceipt
     */
    public $SalesReceipt;

    /**
     * @xmlType element
     * @xmlName Invoice
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPInvoice
     */
    public $Invoice;

    /**
     * @xmlType element
     * @xmlName Bill
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPBill
     */
    public $Bill;

    /**
     * @xmlType element
     * @xmlName PurchaseOrder
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPPurchaseOrder
     */
    public $PurchaseOrder;

    /**
     * @xmlType element
     * @xmlName VendorCredit
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPVendorCredit
     */
    public $VendorCredit;

    /**
     * @xmlType element
     * @xmlName Transfer
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPTransfer
     */
    public $Transfer;

    /**
     * @xmlType element
     * @xmlName RefundReceipt
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPRefundReceipt
     */
    public $RefundReceipt;

    /**
     * @xmlType element
     * @xmlName Estimate
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPEstimate
     */
    public $Estimate;

    /**
     * @xmlType element
     * @xmlName Deposit
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPDeposit
     */
    public $Deposit;

    /**
     * @xmlType element
     * @xmlName CreditMemo
     * @varz com\intuit\schema\finance\v3\Invoice
     * @var IPPCreditMemo
     */
    public $CreditMemo;

This fixed all issues with recurring transactions for me