minimul / qbo_api

Ruby JSON-only client for QuickBooks Online API v3. Built on top of the Faraday gem.
MIT License
85 stars 45 forks source link

Journal updating creates a new entry #134

Closed map7 closed 5 months ago

map7 commented 5 months ago

I'm trying to update a journal and when I do instead of updating it creates a new entry

Here are my methods to get and update a journal which call the qbo_api methods

def journal_edit(id)
    @qbo_api.get(:journal_entry, id)
end

def journal_update(journal,params)
    @qbo_api.update(:journalentry, id: params[:tran_no].to_i, payload: journal)
end

Here is how I re-enact the problem

  1. Create a "test" transaction through the development web interface

  2. Create report object passing in realm_id

       require_relative "lib/report"
       require 'sqlite3'
       realm_id = "<my realm_id>" # Sandbox_ACME_US realm_id
       db = SQLite3::Database.new("#{File.dirname(__FILE__)}/report_craft.db")
       company = db.execute('select * from companies where realm_id = ?', realm_id).first
      access_token = company[2]
       @report=Report.new(access_token,realm_id)
  3. Get journal

       journal = @report.journal_edit(352)
  4. Call update

    
       params = {tran_no: 352}
       @report.journal_update(journal,params)

5. Check in journal report = fail, still get two results
map7 commented 5 months ago

It's happened again, I forgot the underscore.

@qbo_api.update(:journal_entry, id: params[:tran_no].to_i, payload: journal)
minimul commented 5 months ago

OK, thanks for reporting. These issues are great documentation as well.