Sha256: 02fc1c1f94c9bfe3db54965343789c2000cee93d4c8c50605aa0ee574e056196

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

module Toolhound

  # Class to parse GitHub repository owner and name from
  # URLs and to generate URLs
  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

2 entries across 2 versions & 1 rubygems

Version Path
toolhound-ruby-1.0.7 lib/toolhound-ruby/rental_item.rb
toolhound-ruby-1.0.6 lib/toolhound-ruby/rental_item.rb