Search code examples
sdkquickbooksinventory

How do I retrieve Quickbooks inventory quantity by site using the SDK? (advanced inventory module)


This seems like a simple issue, but it's eluding me. Let's say I have items A,B,C, and D and sites W, X, Y, and Z. I want to know how many Cs there are at site X. With ItemInventoryQuery I can retrieve the total number of Cs across all sites, but how can I get site-specific quantities?

The only method I've found so far doesn't scale well. I can use InventoryAdjustmentQuery for item C and process through all the entries to calculate the current value, but that's going to become far too time-consuming as items are purchased,sold,transferred, etc.

Please help me discover what I'm missing.


Solution

  • The easiest way we've found to do this is with a ItemSitesQueryRq. You can filter by specific site(s) or leave it blank to get the quantities on hand for all sites.

    The request looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="10.0"?>
    <QBXML>
        <QBXMLMsgsRq onError="stopOnError">
            <ItemSitesQueryRq>
    
                <ItemSiteFilter>
                    <SiteFilter>
    
                        <FullName>Your Site Name Here</FullName>
    
                    </SiteFilter>
                </ItemSiteFilter>
    
                <MaxReturned>25</MaxReturned>
    
                <ActiveStatus>All</ActiveStatus>
            </ItemSitesQueryRq>
        </QBXMLMsgsRq>
    </QBXML>
    

    QuickBooks qbXML example request from our QuickBooks development wiki.

    And the response you get back includes elements such as:

    ItemInventoryRef/ListID
    ItemInventoryRef/FullName
    
    InventorySiteRef/ListID
    InventorySiteRef/FullName
    
    ReorderLevel
    QuantityOnHand
    
    QuantityOnPurchaseOrders
    QuantityOnOrder
    QuantityOnSalesOrders
    QuantityOnSalesOrder
    
    QuantityToBeBuiltByPendingBuildTxns
    QuantityRequiredByPendingBuildTxns
    QuantityOnPendingTransfers