Sam.E
Sam.E

Reputation: 175

Quickbooks PHP - qbXML mapping TransactionRet(Invoice) with ItemServiceRet

I'm developing a rountine to store invoice into local database based on QuickBooks invoices.

Using this qbXML request:

$xml ='<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="8.0"?>
        <QBXML>
          <QBXMLMsgsRq onError="stopOnError">
            <InvoiceQueryRq requestID="'.$requestID.'">
            </InvoiceQueryRq>
          </QBXMLMsgsRq>
        </QBXML>';
return $xml;

And I get the results I want, example data:

<InvoiceRet>
<TxnID>11-1428375941</TxnID>
<TimeCreated>2015-04-06T23:05:41-05:00</TimeCreated>
<TimeModified>2015-04-06T23:05:41-05:00</TimeModified>
<EditSequence>1428375941</EditSequence>
<TxnNumber>5</TxnNumber>
<CustomerRef>
    <ListID>8000005A-1424374192</ListID>
    <FullName>Fake</FullName>
</CustomerRef>
<ARAccountRef>
    <ListID>80000010-1424374182</ListID>
    <FullName>Accounts Receivable</FullName>
</ARAccountRef>
<TemplateRef>
    <ListID>8000000B-1424373504</ListID>
    <FullName>Time &amp; Expense Invoice</FullName>
</TemplateRef>
<TxnDate>2015-04-06</TxnDate>
<RefNumber>3</RefNumber>
<BillAddress>
    <Addr1>Fake </Addr1>
    <Addr2>Fake Address</Addr2>
    <City>Fake City</City>
    <State>ON</State>
    <PostalCode>123 ABC</PostalCode>
</BillAddress>
<BillAddressBlock>
    <Addr1>Fake Address</Addr1>
    <Addr2>Fake Address</Addr2>
    <Addr3>Fake Address</Addr3>
</BillAddressBlock>
<IsPending>false</IsPending>
<IsFinanceCharge>false</IsFinanceCharge>
<TermsRef>
    <ListID>80000006-1424373984</ListID>
    <FullName>Net 30</FullName>
</TermsRef>
<DueDate>2015-05-06</DueDate>
<ShipDate>2015-04-06</ShipDate>
<Subtotal>1299.00</Subtotal>
<SalesTaxPercentage>13.00</SalesTaxPercentage>
<SalesTaxTotal>168.87</SalesTaxTotal>
<AppliedAmount>0.00</AppliedAmount>
<BalanceRemaining>1467.87</BalanceRemaining>
<IsPaid>false</IsPaid>
<IsToBePrinted>true</IsToBePrinted>
<IsToBeEmailed>false</IsToBeEmailed>
<IsTaxIncluded>false</IsTaxIncluded>
<CustomerSalesTaxCodeRef>
    <ListID>80000006-1424373984</ListID>
    <FullName>H</FullName>
</CustomerSalesTaxCodeRef>

I want to see which items are in this invoice. So I ran xml to get all items. example of what I got:

    <ItemServiceRet>
    <ListID>80000021-1424374186</ListID>
    <TimeCreated>2015-02-19T14:29:46-05:00</TimeCreated>
    <TimeModified>2015-02-19T14:29:46-05:00</TimeModified>
    <EditSequence>1424374186</EditSequence>
    <Name>Prep. of Electrical Drawing</Name>
    <FullName>Prep. of Electrical Drawing</FullName>
    <IsActive>true</IsActive>
    <Sublevel>0</Sublevel>
    <IsTaxIncluded>false</IsTaxIncluded>
    <SalesTaxCodeRef>
        <ListID>80000006-1424373984</ListID>
        <FullName>H</FullName>
    </SalesTaxCodeRef>
    <SalesOrPurchase>
        <Desc>For preparation of electrical drawings</Desc>
        <Price>0.00</Price>
        <AccountRef>
            <ListID>80000034-1424374183</ListID>
            <FullName>Engineering Revenue</FullName>
        </AccountRef>
    </SalesOrPurchase>
</ItemServiceRet>

I've tried for so long but I can't find any variable that I can use to link items to the proper invoice.

Which xml node on the item has Id/information on what invoice the item belongs to?

Is there better qbXML for this? I've tried everything from sales to JournalEntry as documented on this site:

http://developer-static.intuit.com/qbSDK-current/Common/newOSR/index.html

Upvotes: 1

Views: 426

Answers (1)

Keith Palmer Jr.
Keith Palmer Jr.

Reputation: 28032

If you refer to the QuickBooks OSR:

You'll see this option:

<IncludeLineItems>true</IncludeLineItems>

With this description:

This filter allows you to omit line items from a query response to get a smaller result. The default value is false, so line items are omitted by default. Set IncludeLineItems to true to include line items in the response if you dont mind getting a larger result.

So, if you want line items, change your request to:

$xml ='<?xml version="1.0" encoding="utf-8"?>
        <?qbxml version="8.0"?>
        <QBXML>
          <QBXMLMsgsRq onError="stopOnError">
            <InvoiceQueryRq requestID="'.$requestID.'">
              <IncludeLineItems>true</IncludeLineItems>
            </InvoiceQueryRq>
          </QBXMLMsgsRq>
        </QBXML>';
return $xml;

Upvotes: 1

Related Questions