ruckus / quickbooks-ruby

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

Invalid Number : <?xml version="1.0" encoding="UTF-8"?> when creating an item #528

Closed PetrosKalafatidis closed 4 years ago

PetrosKalafatidis commented 4 years ago

I am trying to create an item with no luck

quick_books_item = Quickbooks::Model::Item.new(item.slice(:name,
                                                              :sku,
                                                              :description,
                                                              :taxable,
                                                              :quantity_on_hand,
                                                              :purchase_desc).merge!(type: item.item_type))
quick_books_item.income_account_ref = { name: 'Cost of Goods Sold',
                                            value: '80' }
service.create(quick_books_item)

*** Quickbooks::IntuitRequestException Exception: Invalid Number: Invalid Number : <?xml version="1.0" encoding="UTF-8"?>

Screen Shot 2020-08-02 at 7 53 23 AM

Here is what to_xml_ns produces

quick_books_item.to_xml_ns

<IncomeAccountRef>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;hash&gt;\n  &lt;name&gt;Visa&lt;/name&gt;\n  &lt;value&gt;42&lt;/value&gt;\n&lt;/hash&gt;\n</IncomeAccountRef>`
ruckus commented 4 years ago

For setting a reference to another object you just assign the numeric id. Check out this section in the docs:

https://github.com/ruckus/quickbooks-ruby#reference-setters