I'm using the QBO .Net SDK v3.0 and I'm trying to get the last bit of data I need from purchases.
I can get all the data I need from the purchase, and most of what I need from the purchase line item. The thing is, I can't get the expense details (chart of account info). Here' s the XML response from the api explorer for a line item under a purchase. It shows what I need, essentially "Office Expense".
<Line>
<Id>1</Id>
<Amount>74.97</Amount>
<DetailType>AccountBasedExpenseLineDetail</DetailType>
<AccountBasedExpenseLineDetail>
<AccountRef name="Office Expense">52</AccountRef>
<BillableStatus>NotBillable</BillableStatus>
<TaxCodeRef>NON</TaxCodeRef>
</AccountBasedExpenseLineDetail>
</Line>
I can get the data not contained by the AccountBasedExpenseLineDetail section with something like the following code (edited for brevity):
// getting list of purchases....
string pQuery = string.Format("Select * FROM Purchase", startDate);
IEnumerable<Purchase> purchases = purchaseQueryService.ExecuteIdsQuery(pQuery).ToList();
// then loop through each line item of each purchase using an iterator
for (int lineItem = 0; lineItem < numLines; lineItem++)
// then get some data...
lineAmount = purchaseInfo.Line[lineItem].Amount.ToString();
Any ideas?
Attaching a sample code used for invoice..similarly you can write for Purchase-
foreach (Line invoiceLine in x.Line)
{
itm = new LineItem();
if (invoiceLine.Amount != 0)
{
itm.Description = invoiceLine.Description;
itm.Description = String.IsNullOrEmpty(itm.Description) ? "n/a" : itm.Description;
if (invoiceLine.DetailType == LineDetailTypeEnum.AccountBasedExpenseLineDetail)
{
AccountBasedExpenseLineDetail itemLineDetail =
invoiceLine.AnyIntuitObject as AccountBasedExpenseLineDetail;
itm.Quantity = 1;
itm.UnitAmount = invoiceLine.Amount;
itm.AccountCode = itemLineDetail.AccountRef.Value;
}