【问题标题】:QuickBooks update item qty doesn't workQuickBooks 更新项目数量不起作用
【发布时间】:2014-10-09 19:59:34
【问题描述】:

我正在尝试通过适用于 QuickBooks v3.0 的 IPP .NET SDK 更新 Item.QtyOnHand。 我选择了

我跟踪此产品的现有数量

复选框,用于我要更新的产品。但我总是得到一个错误:

Detail=业务验证错误:库存商品销售成本 如果您为此跟踪库存数量,则需要帐户 产品。

如何更新手头数量? 我的代码:

    var oauthValidator = new OAuthRequestValidator(RestProfile.OAuthAccessToken, RestProfile.OAuthAccessTokenSecret, this.ConsumerProfile.ConsumerKey, this.ConsumerProfile.ConsumerSecret);
    var serviceContext = new ServiceContext(this.RestProfile.AppToken, this.RestProfile.CompanyId, IntuitServicesType.QBO, oauthValidator);
    var dataService = new DataService( serviceContext );
    var queryService = new QueryService<Item>( serviceContext );
    var items = queryService.Where(x=>x.Type == ItemTypeEnum.Inventory).ToList();
    var batch = dataService.CreateNewBatch();

    foreach( var item in items )
    {
        batch.Add(new Item()
        {
            Name = item.Name,
            Id = item.Id,
            QtyOnHand = item.QtyOnHand+1,
            QtyOnHandSpecified = true
        }, item.Id, OperationEnum.update);
    }

    batch.Execute();

我总是收到这个错误:

{
    "BatchItemResponse" : [{
            "Fault" : {
                "Error" : [{
                        "Message" : "A business validation error has occurred while processing your request",
                        "Detail" : "Business Validation Error: An inventory cost-of-goods-sold account is required if you are tracking inventory quantities for this product.",
                        "code" : "6000",
                        "element" : ""
                    }
                ],
                "type" : "ValidationFault"
            },
            "bId" : "20"
        }, {
            "Fault" : {
                "Error" : [{
                        "Message" : "A business validation error has occurred while processing your request",
                        "Detail" : "Business Validation Error: An inventory cost-of-goods-sold account is required if you are tracking inventory quantities for this product.",
                        "code" : "6000",
                        "element" : ""
                    }
                ],
                "type" : "ValidationFault"
            },
            "bId" : "23"
        }, {
            "Fault" : {
                "Error" : [{
                        "Message" : "A business validation error has occurred while processing your request",
                        "Detail" : "Business Validation Error: An inventory cost-of-goods-sold account is required if you are tracking inventory quantities for this product.",
                        "code" : "6000",
                        "element" : ""
                    }
                ],
                "type" : "ValidationFault"
            },
            "bId" : "21"
        }, {
            "Fault" : {
                "Error" : [{
                        "Message" : "A business validation error has occurred while processing your request",
                        "Detail" : "Business Validation Error: An inventory cost-of-goods-sold account is required if you are tracking inventory quantities for this product.",
                        "code" : "6000",
                        "element" : ""
                    }
                ],
                "type" : "ValidationFault"
            },
            "bId" : "22"
        }
    ],
    "time" : "2014-10-09T12:42:48.715-07:00"
}

【问题讨论】:

    标签: quickbooks updating quickbooks-online inventory


    【解决方案1】:

    问题是请求错误。为了避免这类错误,我在请求中添加了 AccountRef。示例:

    var accReference = accounts["Cost of Goods Sold"];
                var expenseAccountRef = new ReferenceType { type = accReference.AccountType.ToString(), name = accReference.Name, Value = accReference.Id };
                foreach( var item in items )
                {
                    batch.Add( new Item()
                    {
                        Name = item.Name,
                        Id = item.Id,
                        SyncToken = item.SyncToken,
                        QtyOnHand = item.QtyOnHand + 1,
                        QtyOnHandSpecified = true,
                        ExpenseAccountRef = expenseAccountRef,
    
                    }, item.Id, OperationEnum.update );
                }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      • 2014-08-24
      相关资源
      最近更新 更多