繁体   English   中英

使用.NET IPP QBOV3 SDK在线将发票添加到快速簿

[英]Adding invoice to quickbooks online using .NET IPP QBOV3 SDK

使用.NET IPP QBOV3 SDK

我整个星期都在从事(小型)集成项目的工作。 该项目的目的是能够在Windows桌面客户端应用程序和在线快速簿之间进行一些帐户集成。

我希望能够-

  1. 创建新的客户/供应商(可以这样做)
  2. 添加销售发票(无法执行此操作)
  3. 退还贷项余​​额(甚至还没有尝试过)

在阅读了一些论坛和文章后,可以理解使用QBOV3 .NET SDK是出于两个原因。

  1. 我将使用C#.net作为winforms应用程序来编码所需的功能(这使我可以将功能集成到当前系统中,这也用c#.net winforms编写)

  2. 似乎很直觉地说这是要走的路,因为所有API都会被贬值。

因此,我的第一个障碍是OAuth-最终我设法弄清楚了。 我现在可以授权并连接到我的QBO沙箱帐户-太好了!

我还可以从winforms应用程序中创建客户,这些客户会出现在QBO中-也很棒!

下一步,使我在最后2个左右的时间里受挫,是要能够为客户创建发票-我似乎无法弄清楚该怎么做。 我经常收到“错误请求”错误。

在网上几乎没有找到关于如何从ac#winforms应用程序执行此操作的示例。 没那么难-所以我现在真的在踢自己。

任何帮助,或为我设定正确方向的样品,我们将不胜感激。 我不敢相信已经没有简单的例子了-我想没有很多人通过桌面winforms应用程序来做到这一点,或者我只是在错误的地方找东西-或错过了明显的东西!

仔细阅读API文档会造成混乱,并且实际上并没有提供任何示例代码。 我认为添加销售发票将是一件相当大的事情。

这是我当前用于获得一些简单功能的代码-创建客户可以正常工作(如果qbo中不存在该客户-这是我在添加之前需要检查的内容-因此对此的任何控制都将非常有用)

到目前为止,这是我拼凑的代码。

 private void button2_Click(object sender, EventArgs e)
    {
        string consumerKey = "consumerKey";
        string consumerSecret = "consumerSecret";

        string accessToken = "accessToken"; 
        string accessTokenSecret = "accessTokenSecret";

        string appToken = "appToken"; 
        string companyID = "companyID"; //realmID

        OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);

        ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBO, oauthValidator);
        //uses production as default, which is https://quickbooks.api.intuit.com
        context.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
        //If not set, the default base URL, https://quickbooks.api.intuit.com, is used



        DataService service = new DataService(context);

        //add customer
        Customer customer = new Customer();

        customer.CompanyName = "Jims Junk";
        customer.GivenName = "Jim";
        customer.FamilyName = "Little";
        customer.PrimaryEmailAddr = new EmailAddress() { Address = "test@test.com", Default = true };
        customer.DisplayName = "Jims Junk Ltd"

        Customer resultCustomer = service.Add(customer) as Customer;


        //invoice

        //-An invoice must have at least one Line that describes an item.
        //- An invoice must have CustomerRef populated.
        //- The DocNumber attribute is populated automatically by the data service if not supplied.
        //- If ShipAddr, BillAddr, or both are not provided, the appropriate customer address from Customer is used to fill those values.
        //-DocNumber, if supplied, must be unique.

        Invoice invoice = new Invoice();

        invoice.DocNumber = "uniqueNumber";
        invoice.TxnDate = DateTime.Today.Date;
        invoice.TxnDateSpecified = true;
        invoice.CustomerRef = new ReferenceType()
        {
            name = customer.DisplayName,
            Value = resultCustomer.Id
        };

        Line invLine = new Line();

        invLine.Amount = 10000;
        invLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
        invLine.Description = "Test Product";

        invoice.Line = new Line[] { invLine };


        Invoice resultInvoice = service.Add(invoice) as Invoice;


    }

在几天没找到任何东西之后,Sods Law-刚才我找到了一个有用的代码示例。

现在,我设法将发票过帐到QBO。

这是帮助的链接-http: //developer.qbapi.com/Create-Invoice-Error---Bad-Request.aspx

病就把它留在这里,以便其他人在挣扎中受益。

谢谢阅读。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM