rubyzoho icon indicating copy to clipboard operation
rubyzoho copied to clipboard

Not getting the product details when making call to Invoice API

Open siddhant-mohan opened this issue 9 years ago • 7 comments

I am making request to invoice api RubyZoho::Crm::Invoice.find_by_id('1496038000000856087')

I am getting all the data related to invoice but not the product_details.

I have checked the data of the direct api call to zoho crm and it's returning me product details also.

siddhant-mohan avatar Dec 03 '15 10:12 siddhant-mohan

I debugged it little more and found out that in gems/rubyzoho-0.5.0/lib/zoho_api_field_utils.rb:73

    70:   def create_and_add_field_value_pair(field_name, module_name, n, record)
    71:     debugger if module_name == "Invoices"
    72:     k = ApiUtils.string_to_symbol(field_name)
    73:     v = n.text == 'null' ? nil : n.text
    74:     r = record.merge({ k => v })
    75:     r = r.merge({ :id => v }) if primary_key?(module_name, k)

In create_and_add_field_value_pair method, its just assigning the n.text to v if its not null. But in my case n is

<FL val='Product Details'><product no='1'><FL val='Product Id'>1496038000000671051</FL><FL val='Product Name'><![CDATA[AWS Core Service]]></FL><FL val='Unit Price'>1.0</FL><FL val='Quantity'>22.0</FL><FL val='Quantity in Stock'>-269.0</FL><FL val='Total'>22.0</FL><FL val='Discount'>0.0</FL><FL val='Total After Discount'>22.0</FL><FL val='List Price'>1.0</FL><FL val='Net Total'>22.0</FL><FL val='Tax'>0.0</FL></product></FL>

which gives n.text = nil and thus product_details value comes out to be nil everytimes.

siddhant-mohan avatar Dec 03 '15 13:12 siddhant-mohan

That’s very helpful. Did you want to send in a PR? 

amalc avatar Dec 03 '15 15:12 amalc

Yeah will send the PR in some time.

siddhant-mohan avatar Dec 12 '15 15:12 siddhant-mohan

The same issue exists trying to get product_details from a Quote, which I just ran into.

jheth avatar Jan 03 '16 22:01 jheth

PR was integrated. Can you point to the master branch and try it?

amalc avatar Jan 04 '16 00:01 amalc

@amalc I tried on master and still not seeing Quote#product_detail records. RubyZoho::Crm::Quote.first.product_details => nil ZohoApi::Crm#related_records('Quotes', '{id}', 'Products') => 200

jheth avatar Jan 04 '16 04:01 jheth

@jheth Hmm. OK. Let take a look.I had this problem on our instance a couple of year ago and fixed it but I don't think it was in the Gem. Something, if I remember correctly, with permissions.

amalc avatar Jan 04 '16 15:01 amalc