0

我在进行检查时收到此错误:

您必须为每个拆分行选择一个产品/服务或一个帐户,其中包含金额或可计费的 $$customer$$。

这是我的代码:

 public void BuildCheckAddRq(Order order)
    {
        if (_qboSettings.MerchantPercent > 0 || _qboSettings.MerchantFee > 0)
        {
            Check newCheck = new Check(); // TODO: Initialize to an appropriate value

            var total = (order.OrderTotal * _qboSettings.MerchantPercent) + _qboSettings.MerchantFee;

            newCheck.Header = new CheckHeader();
            newCheck.Header.TotalAmt = total;
            newCheck.Header.TotalAmtSpecified = true;
            newCheck.Header.TxnDate = System.DateTime.Now;
            newCheck.Header.Note = "Merchant Account Fees";
            newCheck.Header.BankAccountName = _qboSettings.DefaultAccount;
            newCheck.Header.DocNumber = order.Id.ToString();


            newCheck.Header.BankAccountId = new IdType { idDomain = idDomainEnum.QBO, Value = GetAccountId(_qboSettings.DefaultAccount) };
            newCheck.Header.EntityName = _qboSettings.MerchantVendorAcct;
            newCheck.Header.EntityType = EntityTypeEnum.Vendor;
            //newCheck.Header.PayeeAddr = headerEntity.Address[0];
            newCheck.Header.ToBePrinted = _qboSettings.ToBePrinted;

            //ItemService ItemServ = new ItemService();
            //List<Item> findItems = ItemServ.FindAll(Initializer.sessionContext, Initializer.realmId);

            CheckLine checkedLine = new CheckLine();
            checkedLine.Amount = total;
            checkedLine.AmountSpecified = true;
            checkedLine.Desc = "Merchant Account Fees";
            decimal qty = 1;
            checkedLine.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.ItemId, ItemsChoiceType1.Qty};
            checkedLine.Items = new object[] { new IdType() { idDomain = idDomainEnum.QBO, Value = GetAccountId("Merchant Account Fees")}, qty };
            newCheck.Line = new CheckLine[] { checkedLine };
            try
            {
                Check actualCheck = dataServices.Add<Check>(newCheck);
                ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Info, "QBO", "Check # " + actualCheck.Header.DocNumber + " synced successfully!"));
            }
            catch (Exception ex)
            {
                ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Error, "QBO", ex.ToString()));
            }


        }
    }
4

1 回答 1

0

在我看来,您提供了一些无效数据。就像在 QuickBooks GUI 中一样,支票上的每个行项目都需要一个 ACCOUNT 参考或一个 ITEM 参考。因此,错误:

您必须为每个拆分行选择一个产品/服务或一个帐户,其中包含金额或可计费的 $$customer$$。

看起来您正在尝试指定对 ITEM 的引用:

checkedLine.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.ItemId, ItemsChoiceType1.Qty};
checkedLine.Items = ...

但是看起来您正在指定一个 ACCOUNT Id 值:

new object[] { new IdType() { idDomain = idDomainEnum.QBO, Value = GetAccountId("Merchant Account Fees")}, qty };

您是否尝试指定对 ITEM 或 ACCOUNT 的引用?

您是否检查了最终生成的 XML?它是什么样子的?它是否符合文档中显示的内容

于 2013-01-18T12:41:16.337 回答