Sha256: 69ee97ec5a87dd4552481c77aff0f41285dd585371ff45fbca62b7205bc6c680

Contents?: true

Size: 1.84 KB

Versions: 30

Compression:

Stored size: 1.84 KB

Contents

module Toolhound

  
  class RentalItem < Base


    # self.table_name   = :rental
    # self.primary_key  = :int_rental_id

    def default_selects
      #{ }"SELECT tblEntity.intEntityID, tblEntity.varEntityID AS job_no, tblLocation.intLocationID, tblLocationText.varLocationName  FROM tblEntity INNER JOIN tblLocation ON tblLocation.intEntityID = tblEntity.intEntityID INNER JOIN tblLocationText ON tblLocationText.intLocationID = tblLocation.intLocationID WHERE varEntityID LIKE '%10526.00%'"
      {
        rental_item:   [:int_rental_detail_id, :int_inventory_id_id ],
        # rental_item_detail: [:var_status, :status_date, ],
        rental_detail: [:int_rental_id, :int_inventory_id, :int_quantity, :dec_daily, :dec_weekly, :dec_monthly, :dec_selling_price],
        # rental: [
        #   :int_rental_id, :var_rental_number, :int_from_location_id, :int_entity_id, :dte_required_date, :int_rate_sheet_id,
        #   :int_job_id, :dte_created_date, :dte_modified_date
        # ],
      }
    end

    def default_joins
      arr = []
      # arr << "INNER JOIN tblRentalItemDetail ON (tblRentalItemDetail.intRentalItemID = tblRentalItem.intRentalItemID)"
      arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"

      # arr << "INNER JOIN tblRental ON (tblRental.intRentalID = tblRentalDetail.intRentalID)"
      # arr << "INNER JOIN tblLocationText ON (tblLocationText.intLocationID = tblLocation.intLocationID)"

      arr
    end

    def find_by_entity_id(id)
      all(limit: 1, where: [{int_entity_id: id}]).first
    end

    def find_by_rental_id(id)
      all(where: [{"rental_detail.int_rental_id" => id}])
    end

    def total_charges_for_entity(id)


      build_and_query(selects: selects, where: wheres, joins: joins)

    end

    # rename_attributes intLocationID: 'location_id'

  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
toolhound-ruby-1.0.37 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.36 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.35 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.34 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.33 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.32 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.31 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.30 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.29 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.28 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.27 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.26 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.25 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.24 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.23 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.22 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.21 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.20 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.19 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.18 lib/toolhound-ruby/rental_item.rb