Closed chrismarkpd closed 5 years ago
Yes, but this Json missing lots of data. Take a look at the documentation for the invoice object and you will see the required fields.
I abbreviated it on purpose. But here's the object i sent:
{:CustomField=> [{:DefinitionId=>"1", :StringValue=>"pochris", :Name=>"P.O. Number", :Type=>"StringType"}, {:DefinitionId=>"2", :StringValue=>"chris", :Name=>"Sales Rep", :Type=>"StringType"}, {:DefinitionId=>"3", :Name=>"Notes", :Type=>"StringType"}], :DocNumber=>"PDWS-41020.1", :Line=> [{:Id=>55, :Amount=>249.75, :DetailType=>"SalesItemLineDetail", :Description=>"Camera Cube - Small / Black", :SalesItemLineDetail=>{:Qty=>10, :ItemRef=>{:value=>55, :name=>"Camera Cube - Small / Black"}}}, {:Id=>199, :Amount=>32.47, :Description=>"HST 0.13", :DetailType=>"SalesItemLineDetail", :SalesItemLineDetail=>{:Qty=>1, :ItemRef=>{:value=>199, :name=>"HST 0.13"}}}, {:Id=>139, :Amount=>139.9, :DetailType=>"SalesItemLineDetail", :Description=>"Capture - Black", :SalesItemLineDetail=>{:Qty=>5, :ItemRef=>{:value=>139, :name=>"Capture - Black"}}}, {:Id=>199, :Amount=>18.19, :Description=>"HST 0.13", :DetailType=>"SalesItemLineDetail", :SalesItemLineDetail=>{:Qty=>1, :ItemRef=>{:value=>199, :name=>"HST 0.13"}}}], :CustomerRef=>{:value=>"58"}, :SalesTermRef=>{:value=>"4"}, :BillEmail=>{:Address=>"chris.mark@peakdesign.com"}, :BillAddr=>{:Line1=>"1321 Sheppard Ave", :Line2=>"", :City=>"Tornto", :CountrySubDivisionCode=>"Canada", :PostalCode=>"M1S 1T4"}, :EmailStatus=>"EmailSent"}
Here's the response I get:
{"Deposit"=>0, "AllowIPNPayment"=>false, "AllowOnlinePayment"=>false, "AllowOnlineCreditCardPayment"=>false, "AllowOnlineACHPayment"=>false, "domain"=>"QBO", "sparse"=>false, "Id"=>"316", "SyncToken"=>"0", "MetaData"=>{"CreateTime"=>"2019-05-16T14:47:33-07:00", "LastUpdatedTime"=>"2019-05-16T14:47:33-07:00"}, "CustomField"=> [{"DefinitionId"=>"1", "Name"=>"P.O. Number", "Type"=>"StringType", "StringValue"=>"pochris"}, {"DefinitionId"=>"2", "Name"=>"Sales Rep", "Type"=>"StringType", "StringValue"=>"chris"}, {"DefinitionId"=>"3", "Name"=>"Notes", "Type"=>"StringType"}], "DocNumber"=>"PDWS-41020.1", "TxnDate"=>"2019-05-16", "CurrencyRef"=>{"value"=>"USD", "name"=>"United States Dollar"}, "LinkedTxn"=>[], "Line"=> [{"Id"=>"1", "LineNum"=>1, "Description"=>"Camera Cube - Small / Black", "Amount"=>249.75, "DetailType"=>"SalesItemLineDetail", "SalesItemLineDetail"=>{"ItemRef"=>{"value"=>"55", "name"=>"BCC-S-BK-1"}, "Qty"=>10, "TaxCodeRef"=>{"value"=>"NON"}}}, {"Id"=>"2", "LineNum"=>2, "Description"=>"HST 0.13", "Amount"=>32.47, "DetailType"=>"SalesItemLineDetail", "SalesItemLineDetail"=>{"ItemRef"=>{"value"=>"199", "name"=>"Sales Tax:HST"}, "Qty"=>1, "TaxCodeRef"=>{"value"=>"NON"}}}, {"Id"=>"3", "LineNum"=>3, "Description"=>"Capture - Black", "Amount"=>139.9, "DetailType"=>"SalesItemLineDetail", "SalesItemLineDetail"=>{"ItemRef"=>{"value"=>"139", "name"=>"CP-BK-3"}, "Qty"=>5, "TaxCodeRef"=>{"value"=>"NON"}}}, {"Id"=>"4", "LineNum"=>4, "Description"=>"HST 0.13", "Amount"=>18.19, "DetailType"=>"SalesItemLineDetail", "SalesItemLineDetail"=>{"ItemRef"=>{"value"=>"199", "name"=>"Sales Tax:HST"}, "Qty"=>1, "TaxCodeRef"=>{"value"=>"NON"}}}, {"Amount"=>440.31, "DetailType"=>"SubTotalLineDetail", "SubTotalLineDetail"=>{}}], "TxnTaxDetail"=>{"TotalTax"=>0}, "CustomerRef"=>{"value"=>"58", "name"=>"Peak Design"}, "BillAddr"=>{"Id"=>"104", "Line1"=>"1321 Sheppard Ave", "City"=>"Tornto", "CountrySubDivisionCode"=>"Canada", "PostalCode"=>"M1S 1T4"}, "ShipAddr"=>{"Id"=>"99", "Line1"=>"1321 Sheppard Ave", "City"=>"Tornto", "CountrySubDivisionCode"=>"Canada", "PostalCode"=>"M1S 1T4"}, "SalesTermRef"=>{"value"=>"4"}, "DueDate"=>"2019-07-15", "TotalAmt"=>440.31, "ApplyTaxAfterDiscount"=>false, "PrintStatus"=>"NeedToPrint", "EmailStatus"=>"EmailSent", "BillEmail"=>{"Address"=>"chris.mark@peakdesign.com"}, "Balance"=>440.31, "DeliveryInfo"=>{"DeliveryType"=>"Email"}}
I tried attaching a datetime converted to a string but it got rid of it.
This request is for creating invoice right? You need to get the invoice I'd after and use the "send" method (with minor version 8 worked for me)
yes, creating invoice. ah i can just call the send method with the invoice id?
Yes. Same as in the documentation call: /invoice/{invoice Id}/send?minorVersion=8 (or something similar)
i was able to pull some things from an open pull request and the solution worked. thanks for your help
Hi, maybe this can help others developers who try to send invoice or payment with this gem. It works well for me.
path_send = "#{qbo_api.entity_path(:payment)}/#{payment_qb_id}/send"
path = qbo_api.add_params_to_path(path: path_send, params: { sendTo: email })
response = qbo_api.request(:post, path: path, payload: {})
Thanks @nickdemers
A PR around this would be very welcome if you have the time.
I just have added a working PR https://github.com/minimul/qbo_api/pull/112 for this
I believe I've looked through all of the documentation. Is there a way to send an invoice using this gem? I have tried sending an invoice on the create method with this payload:
BillEmail: { Address: "test@test.com" }, EmailStatus: "EmailSent", DeliveryInfo: { DeliveryType: "Email", DeliveryTime: DateTime.now.to_s },