如何添加采购订单QBO REST API V3.0 [英] how to add purchase order with QBO rest api v3.0

查看:198
本文介绍了如何添加采购订单QBO REST API V3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图发送带有.NET忒SDK V3创造了一个采购订单。我发现发票合适的例子:如何添加发票或销售收据QuickBooks的REST API V3.0

I am trying to send a PurchaseOrder created with Intuit .NET SDK v3. I found a suitable example with Invoice: how to add invoice or sales receipt quickbooks rest api v3.0

但我不知道是什么,我需要做,使之工作了采购订单。 。我收到错误请求不管做什么属性我设置

But I cannot work out what I need to do to make it working for Purchase Order. I am getting BadRequest no matter what properties do I set.

        DataService commonService = new DataService(context);

        QueryService<Vendor> accountQueryService = new QueryService<Vendor>(context);
        Vendor customer = accountQueryService.Where(x => x.Id == "9").FirstOrDefault<Vendor>();
        QueryService<Item> itemQueryService = new QueryService<Item>(context);
        Item item = itemQueryService.Where(x => x.Id == "1").FirstOrDefault<Item>();

        PurchaseOrder invoice = new PurchaseOrder();

        invoice.VendorRef = new ReferenceType()
        {
            name = customer.DisplayName,
            Value = customer.Id
        };

        /*invoice.APAccountRef = new ReferenceType()
        {
            type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
            name = "Account Receivable",
            Value = "QB:37"
        };*/

        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;

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

        PurchaseOrderItemLineDetail det = new PurchaseOrderItemLineDetail();
        det.Qty = 10;
        det.QtySpecified = true;
        det.ItemRef = new ReferenceType()
        {
            name = item.Name,
            Value = item.Id
        };
        line.AnyIntuitObject = det;

        lineList.Add(line);
        invoice.Line = lineList.ToArray();



我试着设置帐户,并在该行只使用说明都没有成功。如果我添加与上面的代码我得到与验证异常的内部错误请求错误创建PurchaseOrder的。

I've tried to set account and use just description in the line without success. If I add PurchaseOrder created with the above code I am getting BadRequest error with Validation exception inside.

可以请别人指出我朝着正确的方向。我可能错过了一些PurchaseOrder的属性。

Can please somebody point me in the right direction here. I am probably missing some PurchaseOrder property.

我使用使用的NuGet加载八月V3 SDK。

I am using the August V3 SDK loaded using NuGet.

更新

这是低于

        DataService commonService = new DataService(context);

        QueryService<Vendor> accountQueryService = new QueryService<Vendor>(context);
        Vendor customer = accountQueryService.Where(x => x.Id == "9").FirstOrDefault<Vendor>();
        QueryService<Item> itemQueryService = new QueryService<Item>(context);
        Item item = itemQueryService.Where(x => x.Id == "1").FirstOrDefault<Item>();

        PurchaseOrder invoice = new PurchaseOrder();
        invoice.TxnDate = DateTime.Now;
        invoice.TxnDateSpecified = true;
        invoice.Memo = "For Internal usage";
        invoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.TaxInclusive;
        invoice.GlobalTaxCalculationSpecified = true;

        invoice.ReplyEmail = new EmailAddress();
        invoice.ReplyEmail.Address = "testing@testing.com";
        invoice.ReplyEmail.Default = false;
        invoice.ReplyEmail.DefaultSpecified = true;
        invoice.ReplyEmail.Tag = "Home";

        invoice.ShipAddr = new PhysicalAddress();
        invoice.ShipAddr.Line1 = "shippingToAddr1Sat Oct 19 09:48:52 IST 2013";
        invoice.ShipAddr.Line2 = "shippingToAddr2Sat Oct 19 09:48:52 IST 2013";
        invoice.ShipAddr.Line3 = "shippingToAddr3Sat Oct 19 09:48:52 IST 2013";
        invoice.ShipAddr.City = "Bangalore";
        invoice.ShipAddr.Country = "India";
        invoice.ShipAddr.CountrySubDivisionCode = "KA";
        invoice.ShipAddr.PostalCode = "560045";

        invoice.POEmail = new EmailAddress();
        invoice.POEmail.Address = "testing@testing.com";
        invoice.POEmail.Default = true;
        invoice.POEmail.DefaultSpecified = true;
        invoice.POEmail.Tag = "Business";

        invoice.VendorRef = new ReferenceType()
        {
            name = customer.DisplayName,
            Value = customer.Id
        };
        invoice.TotalAmt = new Decimal(100.00);
        invoice.TotalAmtSpecified = true;

        invoice.APAccountRef = new ReferenceType()
        {
            //type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
            name = "Accounts Payable (A/P)",
            Value = "32"
        };

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

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

        AccountBasedExpenseLineDetail det = new AccountBasedExpenseLineDetail();
        det.AccountRef = new ReferenceType()
        {
            name = "Accounts Payable (A/P)",
            Value = "32"
        };
        line.AnyIntuitObject = det;

        /*PurchaseOrderItemLineDetail det = new PurchaseOrderItemLineDetail();
        det.Qty = 10;
        det.QtySpecified = true;
        det.ItemRef = new ReferenceType()
        {
            name = item.Name,
            Value = item.Id
        };
        line.AnyIntuitObject = det;*/

        lineList.Add(line);
        invoice.Line = lineList.ToArray();

        return invoice;



不幸的是我仍然得到错误请求的错误。

Unfortunately I am still getting BadRequest error.

更新2

在一些更多的测试,我发现它给因为APAccountRef财产的错误。这是没有设置该属性确定。

After some more testing I found out that it gives error because of APAccountRef property. It's OK without setting up this property.

另一个问题来了,当我试图在线条中使用PurchaseOrderItemLineDetail。不知道这类型是正确的(根据名称,它看起来像一个),但使用这种类型的详细信息,导致错误请求错误。使用ItemBasedExpenseLineDetail是一种解决方法。

The other issue came when I tried to use PurchaseOrderItemLineDetail in lines. Not sure if this type is correct (based on the name it looks like one) but using this details type is causing BadRequest error. Using ItemBasedExpenseLineDetail is a workaround.

我将马纳斯答案正确的,因为它给了我一个方向进一步调查。但是非常感谢Nimisha Shrivastava与记录的帮助。

I will set Manas answer as correct since it gave me a direction to investigate further. But big thanks to Nimisha Shrivastava for the help with logging.

推荐答案

下面是一个工作的PurchaseOrder创建请求XML。

Here is one working PurchaseOrder create request XML.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PurchaseOrder domain="QBO" xmlns="http://schema.intuit.com/finance/v3">
    <TxnDate>2013-10-19</TxnDate>
    <Line>
        <Amount>3.00</Amount>
        <DetailType>AccountBasedExpenseLineDetail</DetailType>
        <AccountBasedExpenseLineDetail>
            <AccountRef name="Accounts Payable (A/P)">32</AccountRef>
        </AccountBasedExpenseLineDetail>
    </Line>
    <VendorRef name="TestDataVendor926e8Sample1">1386</VendorRef>
    <TotalAmt>3.00</TotalAmt>
    <ReplyEmail>
        <Address>testing@testing.com</Address>
        <Default>false</Default>
        <Tag>Home</Tag>
    </ReplyEmail>
    <Memo>For Internal usage</Memo>
    <GlobalTaxCalculation>TaxInclusive</GlobalTaxCalculation>
    <ShipAddr>
        <Line1>shippingToAddr1Sat Oct 19 09:48:52 IST 2013</Line1>
        <Line2>shippingToAddr2Sat Oct 19 09:48:52 IST 2013</Line2>
        <Line3>shippingToAddr3Sat Oct 19 09:48:52 IST 2013</Line3>
        <City>Bangalore</City>
        <Country>India</Country>
        <CountrySubDivisionCode>KA</CountrySubDivisionCode>
        <PostalCode>560045</PostalCode>
    </ShipAddr>
    <POEmail>
        <Address>test@testing.com</Address>
        <Default>true</Default>
        <Tag>Business</Tag>
    </POEmail>
</PurchaseOrder>



我用java的devkit(PFB代码)。希望你会发现在.NET的devkit相似的属性。

I've used java devkit(PFB code). Hope you'll find similar properties in .net devkit.

公开的PurchaseOrder purchaseOrderWithAllProperties()抛出FMSException,ParseException的{

public PurchaseOrder purchaseOrderWithAllProperties() throws FMSException, ParseException {

PurchaseOrder purchaseOrder = new PurchaseOrder();
purchaseOrder.setVendorRef(this.vendorRef);
purchaseOrder.setMemo("For Internal usage");

Line line1 = new Line();
line1.setAmount(new BigDecimal("3.00"));
line1.setDetailType(LineDetailTypeEnum.ACCOUNT_BASED_EXPENSE_LINE_DETAIL);
AccountBasedExpenseLineDetail detail = new AccountBasedExpenseLineDetail();
ReferenceType expenseAccountRef = this.accountRef;
detail.setAccountRef(expenseAccountRef);
line1.setAccountBasedExpenseLineDetail(detail);

List<Line> lines1 = new ArrayList<Line>();
lines1.add(line1);
purchaseOrder.setLine(lines1);

EmailAddress emailAddr = new EmailAddress();
emailAddr.setAddress("test@testing.com");
emailAddr.setDefault(true);
emailAddr.setTag("Business");

purchaseOrder.setPOEmail(emailAddr);
//purchaseOrder.setDueDate(DateUtils.getDateWithNextDays(45));
purchaseOrder.setDomain("QBO");
//purchaseOrder.setExchangeRate(new BigDecimal("20.00")); 
purchaseOrder.setGlobalTaxCalculation(GlobalTaxCalculationEnum.TAX_INCLUSIVE);

EmailAddress replyEmail = new EmailAddress();
replyEmail.setAddress("testing@testing.com");
replyEmail.setDefault(false);
replyEmail.setTag("Home");
purchaseOrder.setReplyEmail(replyEmail);

PhysicalAddress shipAddr = new PhysicalAddress();
shipAddr.setLine1("shippingToAddr1" + DateUtils.getCurrentDateTime());
shipAddr.setLine2("shippingToAddr2" + DateUtils.getCurrentDateTime());
shipAddr.setLine3("shippingToAddr3" + DateUtils.getCurrentDateTime());
shipAddr.setCity("Bangalore");
shipAddr.setCountry("India");
shipAddr.setCountrySubDivisionCode("KA");
shipAddr.setPostalCode("560045");
purchaseOrder.setShipAddr(shipAddr);

//purchaseOrder.setStatus(EntityStatusEnum.IN_TRANSIT);
purchaseOrder.setTotalAmt(new BigDecimal("3.00"));
purchaseOrder.setTxnDate(DateUtils.getCurrentDateTime());

return purchaseOrder;



}

}

感谢

这篇关于如何添加采购订单QBO REST API V3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆