简体   繁体   English

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

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

using .NET IPP QBOV3 SDK 使用.NET IPP QBOV3 SDK

I have been working (struggling) on a small integration project all week. 我整个星期都在从事(小型)集成项目的工作。 The purpose of the project is to be able to have some accounts integration between a windows desktop client application, to quickbooks online. 该项目的目的是能够在Windows桌面客户端应用程序和在线快速簿之间进行一些帐户集成。

I want to be able to - 我希望能够-

  1. Create new customers/suppliers (can do this) 创建新的客户/供应商(可以这样做)
  2. Add sales invoices (cannot do this) 添加销售发票(无法执行此操作)
  3. Return credit balances (not even tried this yet) 退还贷项余​​额(甚至还没有尝试过)

After reading a few forums, and articles to come to the understanding the QBOV3 .NET SDK was the one to use, for two reasons. 在阅读了一些论坛和文章后,可以理解使用QBOV3 .NET SDK是出于两个原因。

  1. I'm going to use C# .net, as a winforms application to code the functionality I need (this allows me to have the functionality integrated in the current system, a this is also written in c# .net winforms) 我将使用C#.net作为winforms应用程序来编码所需的功能(这使我可以将功能集成到当前系统中,这也用c#.net winforms编写)

  2. It seems intuit say this is the way to go, as all over APIs are going to be depreciated. 似乎很直觉地说这是要走的路,因为所有API都会被贬值。

So, my first hurdle was the OAuth - which eventually I managed to figure out. 因此,我的第一个障碍是OAuth-最终我设法弄清楚了。 I can now authorise and connect to my QBO sandbox account - great! 我现在可以授权并连接到我的QBO沙箱帐户-太好了!

I can also create customers from the winforms application, and they appear in QBO - also great! 我还可以从winforms应用程序中创建客户,这些客户会出现在QBO中-也很棒!

The next step, which has stumped me for the last 2 or so, is to be able to create an invoice for a customer - I just cant seem to figure out what to do. 下一步,使我在最后2个左右的时间里受挫,是要能够为客户创建发票-我似乎无法弄清楚该怎么做。 I am constantly getting a 'Bad request' error. 我经常收到“错误请求”错误。

I have found next to no examples online on how to do this from ac# winforms application. 在网上几乎没有找到关于如何从ac#winforms应用程序执行此操作的示例。 It cant be that hard - so I'm really kicking myself at the moment. 没那么难-所以我现在真的在踢自己。

Any help, or sample to set me in the right direction would be appreciated. 任何帮助,或为我设定正确方向的样品,我们将不胜感激。 I cant believe no simple examples exist of this already - I guess not many are doing this via a desktop winforms application, or I am just looking in the wrong places - or have missed something obvious! 我不敢相信已经没有简单的例子了-我想没有很多人通过桌面winforms应用程序来做到这一点,或者我只是在错误的地方找东西-或错过了明显的东西!

Reading through the API documentation is confusing, and doesn't really offer any sample code. 仔细阅读API文档会造成混乱,并且实际上并没有提供任何示例代码。 I would of thought adding a sales invoice would be a pretty big thing to cover. 我认为添加销售发票将是一件相当大的事情。

Here is the code I am currently using to gain some simple functionality - creating the customer works fine (if the customer doesn't exist in qbo - this is something I need to check before adding - so any steer on that would be great also) 这是我当前用于获得一些简单功能的代码-创建客户可以正常工作(如果qbo中不存在该客户-这是我在添加之前需要检查的内容-因此对此的任何控制都将非常有用)

Here is the code I cobbled together so far.. 到目前为止,这是我拼凑的代码。

 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, after a few days of not finding anything - Just now I find a code sample that has helped. 在几天没找到任何东西之后,Sods Law-刚才我找到了一个有用的代码示例。

I have now managed to get an invoice posted into QBO. 现在,我设法将发票过帐到QBO。

Here is the linked that helped - http://developer.qbapi.com/Create-Invoice-Error---Bad-Request.aspx 这是帮助的链接-http: //developer.qbapi.com/Create-Invoice-Error---Bad-Request.aspx

ill just leave it here, so that others may benefit if struggling. 病就把它留在这里,以便其他人在挣扎中受益。

Thanks for reading. 谢谢阅读。

暂无
暂无

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

相关问题 使用.NET IPP QBOV3 SDK从c#在线通过QuickBooks API添加采购订单 - Adding a Purchase Order via QuickBooks API from c# online using .NET IPP QBOV3 SDK QuickBooks Online(QBO)通过C#中的v2 IPP .NET SDK写入发票上的自定义字段 - QuickBooks Online (QBO) write to Custom Fields on Invoice via v2 IPP .NET SDK in C# 用于QuickBooks v3.0的IPP .NET SDK创建发票错误 - 错误请求 - IPP .NET SDK for QuickBooks v3.0 Create Invoice Error - Bad Request 使用IPP .NET SDK for QuickBooks v3.0的SalesItemLineDetail上没有单价吗? - No UnitPrice available on SalesItemLineDetail using IPP .NET SDK for QuickBooks v3.0? QBO / .NET SDK [Quickbooks Online] - 如何删除空发票行项目? - QBO/.NET SDK [Quickbooks Online] - How to remove empty invoice line item? 使用.NET c#IPP数据服务SDK创建新的QuickBooks Bill时所需的属性 - Required Properties when using .NET c# IPP Data Service SDK to create new QuickBooks Bill 使用QuickBooks Online(QBO)Intuit合作伙伴平台(IPP)DevKit查询所有未结余额发票 - Query for All Invoices With Open Balances using QuickBooks Online (QBO) Intuit Partner Platform (IPP) DevKit 为什么使用QuickBooks IPP.NET SDK检索类代码失败并显示ValidationError? - Why does retrieving Class codes with QuickBooks IPP.NET SDK fail with a ValidationError? 如何为QBO IPP .NET SDK V3的发票行项目指定产品/服务? - How can I specify Product/Service for an Invoice Line Item for QBO IPP .NET SDK V3? 使用SDK将员工记录添加到Quickbooks系统中 - Adding Employee record into Quickbooks system using SDK
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM