ruckus / quickbooks-ruby

Quickbooks Online REST API V3 - Ruby
MIT License
374 stars 302 forks source link

Error Creating SalesReceipt #428

Closed c-moyer closed 5 years ago

c-moyer commented 6 years ago

I'm getting an error when I create a sales receipt with this code:


salesreceipt = Quickbooks::Model::SalesReceipt.new({
      customer_id: 99,
      txn_date: Date.civil(2013, 11, 20),
      payment_ref_number: "111", #optional payment reference number/string - e.g. stripe token
      deposit_to_account_id: 222, #The ID of the Account entity you want the SalesReceipt to be deposited to
      payment_method_id: 333 #The ID of the PaymentMethod entity you want to be used for this transaction
    })
    salesreceipt.auto_doc_number! #allows Intuit to auto-generate the transaction number

    line_item = Quickbooks::Model::Line.new
    line_item.amount = 50
    line_item.description = "Plush Baby Doll"
    line_item.sales_item! do |detail|
      detail.unit_price = 50
      detail.quantity = 1
      detail.item_id = 500 # Item (Product/Service) ID here
    end

    salesreceipt.line_items << line_item

        oauth_client = OAuth::AccessToken.new(QB_OAUTH_CONSUMER, 
    current_account.quickbooks_token, 
    current_account.quickbooks_secret)
      service = Quickbooks::Service::Invoice.new
      service.access_token = oauth_client
      service.company_id = current_account.quickbooks_realm_id
    created_receipt = service.create(salesreceipt)

Here is the error I am getting:

Quickbooks::IntuitRequestException (Unsupported Operation:
    Operation Bad arguments passed to public com.intuit.schema.finance.v3.IntuitResponse com.intuit.qbo.bl.txns.servicev3.rest.Invoice.doAllOperations(java.lang.String,com.intuit.schema.finance.v3.Invoice,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,javax.servlet.http.HttpServletRequest,java.lang.String) throws com.intuit.qbo.v3.common_lib.FdmException  ( java.lang.String 409454416, com.intuit.schema.finance.v3.SalesReceipt com.intuit.schema.finance.v3.SalesReceipt@1c1ace37, null, null, null, null, null, com.sun.proxy.$Proxy107 org.apache.catalina.connector.RequestFacade@31809b41, null ) is not supported.):

Here is the request:

METHOD = post
    RESOURCE = https://sandbox-quickbooks.api.intuit.com/v3/company/409454416/invoice
    REQUEST BODY:
    <?xml version="1.0" encoding="utf-8"?>
    <SalesReceipt xmlns="http://schema.intuit.com/finance/v3" sparse="false">
    <AutoDocNumber/>
    <TxnDate>2013-11-20</TxnDate>
    <Line>
    <Description>Plush Baby Doll</Description>
    <Amount>50.0</Amount>
    <DetailType>SalesItemLineDetail</DetailType>
    <SalesItemLineDetail>
    <ItemRef>500</ItemRef>
    <UnitPrice>50.0</UnitPrice>
    <Qty>1.0</Qty>
    </SalesItemLineDetail>
    </Line>
    <CustomerRef>1</CustomerRef>
   <PaymentMethodRef>1</PaymentMethodRef>
    <PaymentRefNum>111</PaymentRefNum>
    <DepositToAccountRef>1</DepositToAccountRef>
    </SalesReceipt>
ruckus commented 6 years ago

Try removing the auto doc number line:

salesreceipt.auto_doc_number!