0

IPP.Net を使用して、単一の CreditMemo を Quickbooks Online に挿入しようとしています。同様のコードで請求書を挿入することに成功しました。CreditMemo を挿入するための私のコードは次のとおりです。

Try
                        Dim qboCreditMemo As New Intuit.Ipp.Data.Qbo.CreditMemo
                        Dim qboCreditMemoHdr As New Intuit.Ipp.Data.Qbo.CreditMemoHeader
                        Dim qboCreditMemoLine As Intuit.Ipp.Data.Qbo.CreditMemoLine
                        Dim CreditMemoLines As New List(Of Intuit.Ipp.Data.Qbo.CreditMemoLine)
                        Dim CreditMemoItemAttributes As Qbo.ItemChoiceType2()
                        Dim CreditMemoItemValues As Object()

                        For Each row In tblTrans.Rows
                            If bFirstRow Then
                                'Set CreditMemo header
                                qboCreditMemoHdr.DocNumber = "SMA" & CStr(row("batch_id"))
                                qboCreditMemoHdr.TxnDate = Format(row("acct_date"), "yyyy-MM-dd")
                                qboCreditMemoHdr.Msg = row("batch_descr")
                                qboCreditMemoHdr.CustomerId = New Intuit.Ipp.Data.Qbo.IdType
                                qboCreditMemoHdr.CustomerId.Value = row("iface_owner_id")
                                qboCreditMemo.Header = qboCreditMemoHdr

                                bFirstRow = False 'only do this once
                            End If

                            'Lines
                            qboCreditMemoLine = New Qbo.CreditMemoLine
                            qboCreditMemoLine.Desc = row("descr")
                            qboCreditMemoLine.Amount = row("amount_owner")
                            qboCreditMemoLine.AmountSpecified = True
                            CreditMemoItemAttributes = {Qbo.ItemsChoiceType2.ItemId, Qbo.ItemsChoiceType2.UnitPrice, Qbo.ItemsChoiceType2.Qty}
                            CreditMemoItemValues = {New Qbo.IdType With {.idDomain = Qbo.idDomainEnum.QBO, .Value = row("iface_item_id")}, row("unitPrice"), row("quantity")}
                            qboCreditMemoLine.ItemsElementName = CreditMemoItemAttributes
                            qboCreditMemoLine.Items = CreditMemoItemValues
                            qboCreditMemoLine.ClassId = New Intuit.Ipp.Data.Qbo.IdType
                            qboCreditMemoLine.ClassId.Value = row("iface_class_id")
                            CreditMemoLines.Add(qboCreditMemoLine) 'Add line to list of lines
                        Next row

                        qboCreditMemo.Line = CreditMemoLines.ToArray  'Add CreditMemo lines to CreditMemo lines property
                        resultCreditMemo = commonService.Add(qboCreditMemo)           'Add CreditMemo to request
                        Return "OK"

                        'Catch exID As Intuit.Ipp.Exception.IdsException
                        'Return exID.Message
                    Catch ex As Exception
                        Return ex.Message

                    End Try

「Internal Server Error」というメッセージでエラーが発生しました。IdsException のようです。別の記事で示したように、Fault オブジェクトと Error オブジェクトを介して BatchRequest の詳細情報を取得できました。ただし、Dataservices を使用して単一の請求書についてこのエラーの詳細を取得する方法がわかりません。

このエラーについて利用可能な情報がもっとあると仮定すると、より良いエラー処理が必要になると思います。また、請求書に設定した同じプロパティが CreditMemo では機能しない理由を理解するのに助けが必要です。残念ながら、必要なプロパティがリストされている Intuit Web サイトのドキュメントには、CreditMemo が含まれていません (Invoice は含まれています)。

4

3 に答える 3

4

CreditMemo は QBO ではサポートされていません:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0400_QuickBooks_Online/0500_Supported_Entities_and_Operations

于 2013-02-28T18:44:26.237 に答える
-1

qbo v3 を使用している場合は、以下のコード サンプルのように実行できます。

CreditMemo objInvoice = new CreditMemo();
            if (qbLog.OperationID != (int)MyEnums.QBOperations.Create)
            {
                var qboId = _iQBLogRepository.GetFromNewContext(x => (x.ReferenceID == qbLog.ReferenceID && x.ActionID == qbLog.ActionID && x.QboId != null)).QboId;
                QueryService<CreditMemo> invoiceQueryService = new QueryService<CreditMemo>(context); 
                objInvoice = invoiceQueryService.ExecuteIdsQuery("Select * From CreditMemo Where Id='" + qboId + "'", QueryOperationType.query).FirstOrDefault();
                if (qbLog.OperationID == (int)MyEnums.QBOperations.Deleted)
                {
                    commonService.Delete<CreditMemo>(objInvoice);
                    return objInvoice.Id;
                }
            }

            objInvoice.CustomerRef = new ReferenceType()
            {
                name = objCustomer.DisplayName,
                Value = objCustomer.Id
            };

            #region Account in transaction


            objInvoice.ARAccountRef = new ReferenceType()
            {
                type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
                name = objAccount.Name,
                Value = objAccount.Id
            };
            #endregion

            #region Items in transaction
            QueryService<Item> itemQueryService = new QueryService<Item>(context);
            Item objItem = itemQueryService.ExecuteIdsQuery("Select * From Item  Where Name = '" + myname + "'", QueryOperationType.query).FirstOrDefault();

            if (objItem == null)
            {
                objItem = new Item();
                objItem.IncomeAccountRef = new ReferenceType()
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
                    name = objAccount.Name,
                    Value = objAccount.Id
                };
                objItem.Name = "name";
                objItem.Description = "description";
                objItem = commonService.Add<Item>(objItem);
            }
            #endregion

            Class objClass = new Class();
            QueryService<Class> classQueryService = new QueryService<Class>(context);
            objClass = classQueryService.ExecuteIdsQuery("Select * From Class  Where Id='" + properties.QboId + "'", QueryOperationType.query).FirstOrDefault();




            #region Sales Line items
            List<Line> lineList = new List<Line>();
            Line line = new Line();
            line.Description = "description";
            line.Amount = "amount";
            line.AmountSpecified = true;
            line.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
            line.AnyIntuitObject = new SalesItemLineDetail
            {
                AnyIntuitObject = _objReceivables.Amount,
                ClassRef = (objClass != null && objClass.Id != null) ? new ReferenceType
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Class),
                    name = objClass.Name,
                    Value = objClass.Id
                } : null,
                InventorySiteRef = null,
                ItemAccountRef = null,
                ItemElementName = ItemChoiceType.UnitPrice,
                ItemRef = new ReferenceType
                {
                    type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Item),
                    name = objItem.Name,
                    Value = objItem.Id
                },
                MarkupInfo = null,
                Qty = 1,
                QtySpecified = true,
            };
            line.Id = "1";
            line.LineEx = null;
            line.LineNum = "1";
            line.LinkedTxn = null;
            line.DetailTypeSpecified = true;
            lineList.Add(line);
            objInvoice.Line = lineList.ToArray();
            #endregion

            #region Cash Account in transaction
            QueryService<Account> accountsQueryService = new QueryService<Account>(context);
            objCashQbAccount = accountsQueryService.ExecuteIdsQuery("Select * From Account   Where Id='" + MyAccountQboId + "'", QueryOperationType.query).FirstOrDefault();
            objInvoice.DepositToAccountRef = new ReferenceType()
            {
                type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
                name = objCashQbAccount.Name,
                Value = objCashQbAccount.Id
            };
            #endregion

            objInvoice.DueDate = DateTime.Now;
            objInvoice.DueDateSpecified = true;

            objInvoice.TxnDate =DateTime.Now;
            objInvoice.TxnDateSpecified = true;

            objInvoice.PrivateNote ="Description";

            objInvoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.TaxExcluded;
            objInvoice.GlobalTaxCalculationSpecified = true;

            objInvoice.TotalAmt = _objReceivables.Amount;
            objInvoice.TotalAmtSpecified = true;

            objInvoice.ApplyTaxAfterDiscount = false;
            objInvoice.ApplyTaxAfterDiscountSpecified = true;

            objInvoice.PrintStatus = PrintStatusEnum.NotSet;
            objInvoice.PrintStatusSpecified = true;
            objInvoice.EmailStatus = EmailStatusEnum.NotSet;
            objInvoice.EmailStatusSpecified = true;

            objInvoice.Balance = "Balance amount if any"
            objInvoice.BalanceSpecified = true;

            objInvoice.Line = lineList.ToArray();

            if (qbLog.OperationID ==  (int)MyEnums.QBOperations.Create)
                objInvoice = commonService.Add<CreditMemo>(objInvoice);
            else if (qbLog.OperationID ==  (int)MyEnums.QBOperations.Update)
                commonService.Update<CreditMemo>(objInvoice);
            return objInvoice.Id;
于 2014-11-17T10:06:05.583 に答える