Coder Social home page Coder Social logo

Error Creating Invoice about quickeebooks HOT 3 CLOSED

ruckus avatar ruckus commented on July 24, 2024
Error Creating Invoice

from quickeebooks.

Comments (3)

cwoolum avatar cwoolum commented on July 24, 2024

Here is my code

  def export_invoices(account, oauth_client)
    sync = QuickbooksSync.new(account.quickbooks_token, account.quickbooks_secret)
    account.customers.each do |c|
      c.orders.has_line_items.each do |o|
        invoice_service = Quickeebooks::Online::Service::Invoice.new
        invoice_service.access_token = sync.oauth_client
        invoice_service.realm_id = account.quickbooks_realm_id

        invoice = Quickeebooks::Online::Model::Invoice.new
        header = Quickeebooks::Online::Model::InvoiceHeader.new
        header.customer_id=c.quickbooks_id
        header.tax_rate=o.sales_tax
        header.total_amount=o.order_total
        header.sub_total_amount=o.order_subtotal

        invoice.header= header
        o.lineitems.each do |li|
          lineitem = Quickeebooks::Online::Model::InvoiceLineItem.new
          lineitem.desc=li.description2
          lineitem.amount=li.price_per
          lineitem.unit_price=li.unit_cost2
          lineitem.taxable=li.taxable
          lineitem.quantity=li.amount2
          invoice.line_items << lineitem
        end
        puts invoice.inspect
        invoice_service.create(invoice)
      end
    end
  end

from quickeebooks.

cwoolum avatar cwoolum commented on July 24, 2024

I dug a little deeper and the actual error seems to be when it tries to set customer Id = 2

from quickeebooks.

cwoolum avatar cwoolum commented on July 24, 2024

Nevermind, this is my own fault. I was making customer id an integer and not the type of Quickeebooks::Online::Model::Id

from quickeebooks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.