ruckus / quickbooks-ruby

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

Adding dedicated shipping item to the invoice #504

Closed designscience closed 3 years ago

designscience commented 4 years ago

Loving this gem but I'm having trouble figuring out how to fill in the dedicated Shipping field in an invoice using quickbooks-ruby. Of course, a basic line-item could be added but I'm most interested in filling the dedicated shipping field provided by QBO (please see attached image). I was not successful finding an example for this in the API explorer.

Screen Shot 2020-01-31 at 1 26 38 PM

One hint that this is possible was a PHP example forwarded by a colleague (source unknown).

// And a shipping charge
$ShippingLine = new QuickBooks_Object_Invoice_ShippingLine();
$ShippingLine->setAmount($data['shipping_amount']);
$Invoice->addShippingLine($ShippingLine);

Any thoughts or hints on how to do this with this gem would be most helpful. Thank you!

ruckus commented 4 years ago

Huh, interesting. This is the first time I've seen a shipping cost field. I'm looking at the docs for the Invoice object and nothing is jumping out:

https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice

By looking at the source code to the Quickbooks PHP library at:

https://github.com/consolibyte/quickbooks-php

It appears that PHP line is for QB Desktop integration and not for QB Online.

I would open a Support Ticket with QBO support and ask them if this field is available via the API (perhaps its undocumented?). If it is available let us know and we can add support for it.

gbkane commented 4 years ago

It's not super well documented by Intuit (I've only seen it in the examples), but you need to send 'SHIPPING_ITEM_ID' as the ItemRef to apply shipping to that field on an invoice.

You can do something like this

shipping_line = Quickbooks::Model::InvoiceLineItem.new
shipping_line.sales_item! do |detail|
  detail.item_ref = Quickbooks::Model::BaseReference.new('SHIPPING_ITEM_ID')
  ...
end 
ruckus commented 3 years ago

Thanks @gbkane it sounds like your solution can solve the OPs issue.