简体   繁体   English

如何添加发票或销售收据quickbooks rest api v3.0

[英]how to add invoice or sales receipt quickbooks rest api v3.0

How can I add an invoice or sales receipt using the QuickBooks API Rest v3? 如何使用QuickBooks API Rest v3添加发票或销售收据? Preferably in .NET. 最好是在.NET中。 I was interested previously in v2 but apparently that is going to be replaced soon. 我之前对v2感兴趣,但显然很快就会被替换。 I can't seem to find any sample code in .NET to add a sales receipt or invoice for version 3. A simple example with minimum data supplied would be appreciated. 我似乎无法在.NET中找到任何示例代码来为版本3添加销售收据或发票。提供最少数据的简单示例将不胜感激。

You can try the following code snippet. 您可以尝试以下代码段。

   public void AddInvoice()
   {
       OAuthRequestValidator reqValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerKeySecret);
       ServiceContext context = new ServiceContext(realmId, IntuitServicesType.QBO, reqValidator);

       Invoice added = Helper.Add<Invoice>(qboContextoAuth, CreateInvoice(qboContextoAuth));

   }

   internal Invoice CreateInvoice(ServiceContext context)
    {
        Customer customer = FindorAdd<Customer>(context, new Customer());
        TaxCode taxCode = FindorAdd<TaxCode>(context, new TaxCode());
        Account account = FindOrADDAccount(context, AccountTypeEnum.AccountsReceivable, AccountClassificationEnum.Liability);

        Invoice invoice = new Invoice();
        invoice.Deposit = new Decimal(0.00);
        invoice.DepositSpecified = true;
        invoice.AllowIPNPayment = false;
        invoice.AllowIPNPaymentSpecified = true;

        invoice.CustomerRef = new ReferenceType()
        {
            name = customer.DisplayName,
            Value = customer.Id
        };
        invoice.DueDate = DateTime.UtcNow.Date;
        invoice.DueDateSpecified = true;
        invoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.TaxExcluded;
        invoice.GlobalTaxCalculationSpecified = true;
        invoice.TotalAmt = new Decimal(0.00);
        invoice.TotalAmtSpecified = true;
        invoice.ApplyTaxAfterDiscount = false;
        invoice.ApplyTaxAfterDiscountSpecified = true;

        invoice.PrintStatus = PrintStatusEnum.NotSet;
        invoice.PrintStatusSpecified = true;
        invoice.EmailStatus = EmailStatusEnum.NotSet;
        invoice.EmailStatusSpecified = true;
        invoice.ARAccountRef = new ReferenceType()
        {
            type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
            name = "Account Receivable",
            Value = "QB:37"
        };
        invoice.Balance = new Decimal(0.00);
        invoice.BalanceSpecified = true;

        List<Line> lineList = new List<Line>();
        Line line = new Line();
        line.Description = "Description";
        line.Amount = new Decimal(100.00);
        line.AmountSpecified = true;

        line.DetailType = LineDetailTypeEnum.DescriptionOnly;
        line.DetailTypeSpecified = true;

        lineList.Add(line);
        invoice.Line = lineList.ToArray();
        TxnTaxDetail txnTaxDetail = new TxnTaxDetail();
        txnTaxDetail.DefaultTaxCodeRef = new ReferenceType()
        {
            Value = taxCode.Id,
            type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Customer),
            name = taxCode.Name
        };

        txnTaxDetail.TotalTax = new Decimal(0.00);
        txnTaxDetail.TotalTaxSpecified = true;


        return invoice;
    }

V3 Invoice Doc Ref - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v3/030_entity_services_reference/invoice Hope, it will be useful to you. V3发票文档参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v3/030_entity_services_reference/invoice希望,它对您有用。

Thanks 谢谢

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

相关问题 如何使用Rest API v2 with .NET将销售收据添加到QuickBooks Online中 - How can I add a sales receipt using the Rest API v2 with .NET into QuickBooks Online 如何使用QBO Rest API V3.0添加采购订单 - how to add purchase order with QBO rest api v3.0 将服务帐户与Google Analytics .Net API v3.0一起使用 - Using a Service Account with Google Analytics .Net API v3.0 .net Google Analytics v3.0和oauth 2.0 - .net google analytics v3.0 and oauth 2.0 SagePay Forms v3.0 不需要账单和交付字段 - SagePay Forms v3.0 Billing and Delivery fields not required 使用自定义标记的Google Map V3.0 - Google Map V3.0 Using Custom Marker 从旧版(v3.0)Facebook .Net SDK迁移到最新版本(v5.0) - Migrating from old (v3.0) Facebook .Net SDK to the latest (v5.0) 当我使用V3 SDK for .Net更新QuickBooks Online中的Invoice时,它无效 - It has no effect when I update Invoice in QuickBooks Online with The V3 SDK for .Net 调试时,托管旧版(v3.5,v3.0,v2.0)和托管旧版(v4.5,v4.0)的默认设置在哪里? - Where is the default setting for Managed Legacy (v3.5, v3.0, v2.0) vs Managed Legacy (v4.5, v4.0) when debugging? Intuit Quickbooks在线API-如何购买 - Intuit Quickbooks Online API - How to get purchases
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM