0

我一直在为朋友制作应用程序,但最近卡住了。出于某种原因,当我尝试测试“itemSubtotalAddRq”时,出现以下错误:

请求 [3]:ItemSubtotalAddRq ItemSubtotalAdd 名称:缺少必需的文件 End of ItemSubtotalAdd

我不确定它是什么,但我知道它是 ItemSubtotalAddRq 行之一,或者我使用 iItemSubtotalAdd 错误。

        public void SalesInfoAdd(IMsgSetRequest requestMsgSet)
    {

        ISalesReceiptAdd salesReceiptAddRq = requestMsgSet.AppendSalesReceiptAddRq();
        //IItemSubtotalAdd itemSubtotalAddRq = requestMsgSet.AppendItemSubtotalAddRq();
        salesReceiptAddNew = new List<ISalesReceiptLineAdd>();

        salesReceiptAddRq.CustomerRef.FullName.SetValue(Form.phoneNumber.Text);
        salesReceiptAddRq.IsPending.SetValue(true);
        salesReceiptAddRq.IsTaxIncluded.SetValue(false);
        salesReceiptAddRq.FOB.SetValue(Form.orderID.Text);

        salesReceiptAddNew.Clear();
        int cnt = 0;
        //while (i < Form.productID.Count)
        for (int j = 0; j < Form.productID.Count; j++)
        {
            salesReceiptAddNew.Add(salesReceiptAddRq.ORSalesReceiptLineAddList.Append().SalesReceiptLineAdd);

            salesReceiptAddNew[j].ItemRef.FullName.SetValue(Form.productID[j].ToString());
            salesReceiptAddNew[j].ORRatePriceLevel.Rate.SetValue(Convert.ToDouble(Form.pricesList.Items[j]));
            salesReceiptAddNew[j].Quantity.SetValue(Form.QBqt[j]);
            salesReceiptAddNew[j].Desc.SetValue(Form.productsList.Items[j].ToString().ToUpper() + " -" + " " +
                                            Form.QBsku[j].ToString().ToUpper());
            cnt = j;
        }

        if (Form.DiscountType.Text != "None" || Form.DiscountType.Text != " ")
        {
            if (Form.productID.Count >= 2)
            {
                cnt++;
                salesReceiptAddNew.Add(salesReceiptAddRq.ORSalesReceiptLineAddList.Append().SalesReceiptLineAdd);
                salesReceiptAddNew[cnt].ItemRef.FullName.SetValue("SUBTOTAL");
                salesReceiptAddNew[cnt].ORRatePriceLevel.Rate.SetValue(Form.totalOfAllItems);
                //itemSubtotalAddRq.Name.SetValue("SUBTOTAL");
                //itemSubtotalAddRq.IsActive.SetValue(true);
            }
            else
                itemSubtotalAddRq.IsActive.SetValue(false);

            cnt++;
            salesReceiptAddNew.Add(salesReceiptAddRq.ORSalesReceiptLineAddList.Append().SalesReceiptLineAdd);
            salesReceiptAddNew[cnt].ItemRef.FullName.SetValue(Form.DiscountType.Text);
        }

        if(Form.freeShipping.Checked == false)
        {
            cnt++;
            salesReceiptAddNew.Add(salesReceiptAddRq.ORSalesReceiptLineAddList.Append().SalesReceiptLineAdd);
            salesReceiptAddNew[cnt].ItemRef.FullName.SetValue("SHIPPING");
            salesReceiptAddNew[cnt].ORRatePriceLevel.Rate.SetValue(Convert.ToDouble(Form.shipping.Text));
        }

        IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

    }

这是我能想到的唯一解决方案,但它仍然不起作用。有什么想法吗?

4

1 回答 1

-1

我认为您指的是“Line”标签下的“ItemType”

参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0600_object_reference/salesreceipt

XML

<Add RequestId="ca435123492c41b891f7841cf4d0e81d" xmlns="http://www.intuit.com/sb/cdm/v2">
    <OfferingId>ipp</OfferingId>
    <ExternalRealmId>65123456</ExternalRealmId>
    <SalesReceipt>
        <Header>
            ---
        </Header>
        <Line>
            <Id idDomain="QB">66</Id>
            <Desc>Description</Desc>
            <ItemId idDomain="QB">4</ItemId>
            <ItemName>Dusting</ItemName>
            <ItemType>Subtotal</ItemType>
            <UnitPrice>1231</UnitPrice>
        </Line>
    </SalesReceipt>
</Add>

使用Java,我编写了这样的代码。我认为,.Net 中也应该有一些类似的枚举/类。你能看看.Net docs吗

链接 - http://developer-static.intuit.com/SDKDocs/QBV2Doc/IntuitDataServicesSDK/

而不是“小计”,您应该使用“小计”。在服务后台,允许的值为[装配、固定资产、组、库存、其他费用、付款、产品、服务、小计]。

您可以在 ApiExplorer 中尝试此用例。

链接 - https://developer.intuit.com/apiexplorer?apiname=V2QBD#SalesReceipt

Java 代码

QBSalesReceipt entityPojo = QBObjectFactory.getQBObject(context, QBSalesReceipt.class);

SalesReceiptLine receiptLine = QBObjectFactory.getQBObject(context, SalesReceiptLine.class);
receiptLine.setItemType(ItemTypeEnum.SUBTOTAL);

ArrayList receiptLines = new ArrayList();
receiptLines.add(receiptLine);
entityPojo.setLine(receiptLines);

QBSalesReceiptService service = QBServiceFactory.getService(context, QBSalesReceiptService.class);
service.addSalesReceipt(context, entityPojo);

请让我知道情况如何。

谢谢

于 2013-07-27T14:41:59.907 回答