Class Quickbooks::Base
In: lib/quickbooks/base.rb
Parent: Model

Base is just base for ListItem and Transaction. It inherits from Model, just as Ref does.

Some Qbxml specifications require certain finder-options to be placed inside a containing entity, such as:

    <FromDeletedDate>#{( - 5*60*60).xmlschema}</FromDeletedDate>
    <ToDeletedDate>#{( - 3*60*60).xmlschema}</ToDeletedDate>

The Quickbooks Models define aliases to these "inside" options. The equivalent to the above [partial] request:

  Quickbooks::Deleted.all(:deleted_after => ( - 5*60*60).xmlschema, :deleted_before => ( - 3*60*60).xmlschema)

(Type-casting hasn‘t made it in yet.)

Qbxml makes a special allowance for Deleted items. Much of the time, we‘d rather access a model‘s deleted items through that model class instead of through the deleted class. So Qbxml allows any class to ask for its deleted items through a call like this:

  Quickbooks::Customer.deleted(:deleted_after => - 3*60*60)



response_log  [RW]  Stores a log of Qbxml::Response objects that were a result of methods performed on this object.

Public Class methods

Queries Quickbooks for all of the objects of the current class‘s type. For example, Quickbooks::Customer.all will return an array of Quickbooks::Customer objects representing all customers.

Returns the current Connection

Sets the current Connection.

This is normally not needed, but in the case that you may want to connect a separate connection to Quickbooks, you can use this method to explicitly set the connection in a class that inherits from Quickbooks::Base.

  Quickbooks::Models::Base.connection ='My Test App', 'C:\\Some File.QBW', 'user', 'pass')

Creates a new object of the current class‘s type. For example, Quickbooks::Customer.create(:name => ‘Tommy’) will create a customer object with a Name of Tommy.

Still in testing… these should be equivalent:

  Quickbooks::Customer.deleted(:deleted_before => == Quickbooks::Deleted.all(:type => 'Customer', :deleted_before =>

Establishes a connection to the Quickbooks RDS Server for all Model Classes

Queries Quickbooks for the first object of the current class‘s type. For example, Quickbooks::Customer.first will return a Quickbooks::Customer object representing the first customer.

Instantiate a new object with just attributes, or an existing object replacing the attributes

Generates a new object that can be saved into Quickbooks once the required attributes are set.

Generates a request by sending *args to, sends the request over the current connection, and interprets the response using Qbxml::ResponseSet. The response is then instantiated into an object or an array of objects.

This method is used mostly internally, but it is the yoke of this library - use it to perform custom requests.

Generates a request using Qbxml::Request, sends it, and returns a Qbxml::ResponseSet object containing the response(s).

Public Instance methods

Usual comparison (super), but add in false if either is a new record.

Destroys a record in Quickbooks. Note that even though Quickbooks will destroy the record, the record‘s ListID and DeletedTime can be accessed by doing a query for deleted objects of the appropriate type.

Returns true if the object is a new object (that doesn‘t represent an existing object in Quickbooks).

Reloads the record from Quickbooks, discarding any changes that have been made to it.

Saves the attributes that have changed.

If the EditSequence is out of date but none of the changes conflict, the object will be saved to Quickbooks. But if there are conflicts, the updated values from Quickbooks will be written to the original_values, and false is returned. This way you can deal with the differences (conflicts), if you so desire, and simply call save again to commit your changes.

Returns success (true/false) status of the last quickbooks communication called from this object.