我正在使用QBO .Net SDK v3.0,我正在尝试从购买中获取最后一点数据。
我可以从购买中获取所需的所有数据,以及购买订单项中我需要的大部分数据。问题是,我无法获得费用明细(帐户信息图表)。以下是api资源管理器对购买下的订单项的XML响应。它显示了我需要的东西,主要是“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>
我可以使用以下代码(为简洁起见编辑)获取AccountBasedExpenseLineDetail部分包含的数据不:
// 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();
有什么想法吗?
答案 0 :(得分:1)
附上用于发票的示例代码。同样,您可以为购买 -
撰写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;
}