-
Notifications
You must be signed in to change notification settings - Fork 67
Way to handle quickbooks exceptions? #101
Comments
You can call > c = Quickeebooks::Windows::Model::Customer.new
> c.valid?
=> false
> c.errors
=> #<ActiveModel::Errors:0x007fed283dc710 @base=#<Quickeebooks::Windows::Model::Customer:0x007fed283e4460 @validation_context=nil, @errors=#<ActiveModel::Errors:0x007fed283dc710 ...>>, @messages={:name=>["is too short (minimum is 1 characters)"], :addresses=>["Must provide at least one address for this Customer."]}> But in the case of your 2nd error you might want to do your own URL format validation. As for your 3rd error, I have no idea where that is coming from. Can you please give me more information on the source of that error? Nonetheless its definitely coming from Intuit as they are on the JVM. |
Actually third exception is comming whenever I am trying to push sub-customer to quickbooks. Here, jobsites is used for indicating sub-customer My code looks like: #push jobsite into quickbook as job
def push_jobsite_to_quickbook(jobsites)
#push data to quickbook
oauth_client = OAuth::AccessToken.new($qb_oauth_consumer, current_company.access_token, current_company.access_secret)
jobsite_service = Quickeebooks::Online::Service::Job.new
jobsite_service.access_token = oauth_client
jobsite_service.realm_id = current_company.realm_id
jobsite = Quickeebooks::Online::Model::Job.new
# find quickbook_customer_id
# this is parent customer id
@parent_customer = current_company.customers.find(@jobsite.customer_id)
# parent customer information
sub_customer = Quickeebooks::Online::Model::Id.new
sub_customer.value = @parent_customer.quickbook_customer_id #push parent customer_id
jobsite.customer_name = @parent_customer.company_name # parent customer name
jobsite.customer_id = sub_customer
# end of parent customer information
# push sub-customer information
jobsite.name = @jobsite.name
address = Quickeebooks::Online::Model::Address.new
address.city = @jobsite.city
address.country_sub_division_code = @jobsite.state
address.postal_code = @jobsite.zip
jobsite.addresses = [address]
jobsite_service.create(jobsite)
end Now I am calling this action in create action and getting : java.lang.NumberFormatException: For input string: "" It was pushing sub-customer data properly in the quickbook but suddenly It is generating above exceptions from 5/6 days. |
I'd like to see the XML this generates - here is how to do that: right before your create() call at the very end do something like this: Rails.logger.info(jobsite.to_xml.to_s) And reply back with the XML output. On Sep 21, 2013, at 4:15 AM, Pushpa Raj Badu [email protected] wrote:
|
Hello, I have tried a lot but now third problem is working fine. c = Quickeebooks::Windows::Model::Customer.new
> c.valid?
=> false
> c.errors
=> #<ActiveModel::Errors:0x007fed283dc710 @base=#<Quickeebooks::Windows::Model::Customer:0x007fed283e4460 @validation_context=nil, @errors=#<ActiveModel::Errors:0x007fed283dc710 ...>>, @messages={:name=>["is too short (minimum is 1 characters)"], :addresses=>["Must provide at least one address for this Customer."]}> you have suggest me this for responding with error message, but first thing, I am using Quickbook Online version and it is generating NoMethodError: NoMethodError: undefined method `valid?' for #<Quickeebooks::Online::Service::Customer:0xa426148> |
Hello, I have tried a lot but now third problem i.e.
not generating. But, c = Quickeebooks::Windows::Model::Customer.new
> c.valid?
=> false
> c.errors
=> #<ActiveModel::Errors:0x007fed283dc710 @base=#<Quickeebooks::Windows::Model::Customer:0x007fed283e4460 @validation_context=nil, @errors=#<ActiveModel::Errors:0x007fed283dc710 ...>>, @messages={:name=>["is too short (minimum is 1 characters)"], :addresses=>["Must provide at least one address for this Customer."]}> you have suggest me aboce code for responding with error message [if any], but first thing, I am using Quickbook Online version and it is generating NoMethodError: NoMethodError: undefined method `valid?' for #<Quickeebooks::Online::Service::Customer:0xa426148> I think valid? function is defined in desktop version only. |
If you're using QB Online then why are you instantiating a QB Windows object?
You should be generating a QB Online Customer object? c = Quickeebooks::Online::Model::Customer.new
valid? is an instance method on an an instance of a Customer model object - not a Service object. E.g.
On Sep 30, 2013, at 10:31 PM, Pushpa Raj Badu [email protected] wrote:
|
Hello there,
Can you tell me the way to handle quickbooks exceptions in rails. I am getting strange errors and exceptions some times and sometime same code is working perfectly.
First error rise up because I am pushing customer which is already exists in quickbooks online. Yes, there is another way to track this error, that is checking customer before pushing to the quickbooks.
I think, second error rise up because user have passed only "http://" in website field. Instead of checking these error seperately, Can I add the quickbook error message in my error message and display the current page instead of going to the error page?
Third one is an exception itself. So, I need a way to handle these exceptions and other unknown exceptions that may arise in near future. How can I fix that?
Thanks in advance
The text was updated successfully, but these errors were encountered: