Class: Toolhound::RentalItem
- Defined in:
- lib/toolhound-ruby/rental_item.rb
Constant Summary
Constants inherited from Base
Base::DATE_TIME_FORMAT, Base::DB_TYPE_REGEX
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #default_joins ⇒ Object
-
#default_selects ⇒ Object
self.table_name = :rental self.primary_key = :int_rental_id.
- #find_by_entity_id(id) ⇒ Object
- #find_by_rental_id(id) ⇒ Object
- #total_charges_for_entity(id) ⇒ Object
Methods inherited from Base
#_build_joins, #_build_selects, #_build_where, #all, #build_and_query, #build_group, #build_joins, #build_selects, #build_sql, #build_update_attributes, #build_update_sql, #build_where, #default_wheres, #find, #formatted_table_and_column, #formatted_table_name, #formmatted_column_name, #get_operator, #initialize, #insert, #locale, #merge_options, #parse_time, primary_key, #primary_key, primary_key=, #procedure, #query, rename_attributes, renamed_attributes, #table_name, table_name, table_name=, #transform_attribute_key, #transform_attributes, #transform_procedure_key, #transform_procedure_value, #transform_procedure_variables, #update, #update_query
Methods included from Util
#acronym_regex, #acronyms, #camelize, #demodulize, #underscore
Constructor Details
This class inherits a constructor from Toolhound::Base
Instance Method Details
#default_joins ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/toolhound-ruby/rental_item.rb', line 23 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 |
#default_selects ⇒ Object
self.table_name = :rental self.primary_key = :int_rental_id
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/toolhound-ruby/rental_item.rb', line 10 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 |
#find_by_entity_id(id) ⇒ Object
34 35 36 |
# File 'lib/toolhound-ruby/rental_item.rb', line 34 def find_by_entity_id(id) all(limit: 1, where: [{int_entity_id: id}]).first end |
#find_by_rental_id(id) ⇒ Object
38 39 40 |
# File 'lib/toolhound-ruby/rental_item.rb', line 38 def find_by_rental_id(id) all(where: [{"rental_detail.int_rental_id" => id}]) end |
#total_charges_for_entity(id) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/toolhound-ruby/rental_item.rb', line 42 def total_charges_for_entity(id) build_and_query(selects: selects, where: wheres, joins: joins) end |