Closed kborrow closed 3 years ago
Hi @kborrow good question. Are you seeing the nil DocNumber on the return result of the service#create
call - or where are you seeing that?
Also, if you could post the request/response log for a create operation that could be useful:
Hi Cody, Below is the code used to generate the sales receipt. Everything works exactly as it should with the exception that the 'doc_number' is nil upon return. Are there any settings on the QBO side of things that would block the 'salesreceipt.auto_doc_number!' from auto-generating the transaction number that you know of?
salesreceipt = Quickbooks::Model::SalesReceipt.new({
customer_id: @customer.entries[0].id,
payment_ref_number: "#{user.lastname}_#{user.firstname}_#{user.id}_#{ssession.id}",
billing_email_address: email,
deposit_to_account_id: 34
})
salesreceipt.auto_doc_number! # auto-generate the transaction number
line_item1 = Quickbooks::Model::Line.new
line_item1.amount = amt
line_item1.description = "Subscription Fee"
line_item1.sales_item! do |detail|
detail.quantity = 1
detail.unit_price = amt
detail.item_id = @service_ids[0]
end
salesreceipt.line_items << line_item1
line_item2 = Quickbooks::Model::Line.new
line_item2.amount = bc
line_item2.description = "Bank Charge"
line_item2.sales_item! do |detail|
detail.quantity = 1
detail.unit_price = bc
detail.item_id = @service_ids[1]
end
salesreceipt.line_items << line_item2
service = Quickbooks::Service::SalesReceipt.new({access_token: token, company_id: qcreds.realm_id })
return service.create(salesreceipt)
This is an automated process on the 'live' side, and I don't have access to the response logs, or anything else within QBO. During the testing phase I was outputting the returned receipt json, which looked good except for that missing doc_number. Interestingly enough the doc_number was populating correctly in my development test company.
Thanks
Hi @kborrow is the SalesReceipt itself created in QBO with the auto-generated doc number? Meaning that just the return result of the #create
call is not surfacing it?
No, it is missing in QBO as well. They are manually adding one after the fact.
@kborrow The API docs at:
https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/salesreceipt
Has this point about DocNumber
DocNumber
Optional
max character: Maximum of 21 chars
String , filterable , sortable
Reference number for the transaction. If not explicitly provided at create time, this field is populated based on the setting of Preferences:CustomTxnNumber as follows:
If Preferences:CustomTxnNumber is true a custom value can be provided. If no value is supplied, the resulting DocNumber is null.
If Preferences:CustomTxnNumber is false, resulting DocNumber is system generated by incrementing the last number by 1.
If Preferences:CustomTxnNumber is false then do not send a value as it can lead to unwanted duplicates. If a DocNumber value is sent for an Update operation, then it just updates that particular invoice and does not alter the internal system DocNumber.
Note: DocNumber is an optional field for all locales except France. For France locale if Preferences:CustomTxnNumber is enabled it will not be automatically generated and is a required field.
The first point:
If Preferences:CustomTxnNumber is true a custom value can be provided. If no value is supplied, the resulting DocNumber is null.
Sounds like it could be a factor here?
The call to auto_doc_number!
in the library only sets the request payload attribute <DocNumber></DocNumber>
to the empty string thereby meaning " ... If no value is supplied..." possibly resulting in your behavior.
Could that be it?
I didn't even notice until now but at the bottom of the Sales Receipt section in the README there is Note about that:
https://github.com/ruckus/quickbooks-ruby#generating-a-salesreceipt
I did see that, and they did try to find that preference setting, but did not see anything that correlated. I didn't see anything within my test company either, but the dynamic doc number worked in testing and not in production, so I am thinking it has to be that setting within QBO.
Are you familiar enough with QBO to know what that option refers to or where to find it?
@kborrow if you are logged into QBO; look for the gear icon in the top-right, then click on Your Company > Account and Settings
In the resulting screen; in the left nav click on Sales then in the Sales form content is the setting for Custom Transaction Numbers
Cody, thank you so much! I've forwarded that information to him. That sounds like it should solve the issue. Thank you for the gem as well....much appreciated!
👍
Hi, I'm generating Sales Receipts in QBO and am using the 'salesreceipt.auto_doc_number!' to force an auto generated document number, but the document number is nil. The rest of the receipt is correct. Is there something that needs to be set on the QBO side of things to allow auto generated document numbers?
Thanks, Kathy