toolhound-ruby 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/toolhound-ruby/authentication.rb +4 -0
- data/lib/toolhound-ruby/base.rb +8 -2
- data/lib/toolhound-ruby/client.rb +15 -9
- data/lib/toolhound-ruby/inventory_item.rb +4 -0
- data/lib/toolhound-ruby/rental_charge.rb +8 -9
- data/lib/toolhound-ruby/rental_item.rb +1 -2
- data/lib/toolhound-ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9bb19365bad8211a21cb1236ab9dd44ec5b567e
|
4
|
+
data.tar.gz: 916ecdf9c5d21387356a34ff121fe61acef0f4f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1e885e703b4cef7a1f0a883371bb44aa19f8287f8c3930cf0f6d69d0089f5b40a796056acdc5c62ab2d519ddb7decf0316146f9d78993eb0fb50ee96fcb5d6e
|
7
|
+
data.tar.gz: cd6fc6df1e56709ddc7f75ab40e7c932f53070c7f4dbbab6ea00f9ae545f2d552f6d3e5f4617dc01cd16c648b3481e77eb9c1ee80947b3e017b736a11c2e255d
|
data/lib/toolhound-ruby/base.rb
CHANGED
@@ -38,11 +38,17 @@ module Toolhound
|
|
38
38
|
# @connection ||= Toolhound.connection
|
39
39
|
# end
|
40
40
|
#
|
41
|
-
def initialize(
|
42
|
-
@
|
41
|
+
def initialize(client, options = {})
|
42
|
+
@client = client
|
43
43
|
# @original = attrs
|
44
44
|
# self.attributes = transform_attributes(attrs)
|
45
45
|
end
|
46
|
+
|
47
|
+
def connection
|
48
|
+
@client.connection
|
49
|
+
end
|
50
|
+
|
51
|
+
|
46
52
|
def table_name
|
47
53
|
name = self.class.table_name || demodulize(self.class.name)
|
48
54
|
formatted_table_name(name)
|
@@ -73,6 +73,12 @@ module Toolhound
|
|
73
73
|
inspected
|
74
74
|
end
|
75
75
|
|
76
|
+
def connection
|
77
|
+
if @connection && @connection.dead?
|
78
|
+
sign_in
|
79
|
+
end
|
80
|
+
@connection
|
81
|
+
end
|
76
82
|
|
77
83
|
|
78
84
|
# Set username for authentication
|
@@ -96,36 +102,36 @@ module Toolhound
|
|
96
102
|
end
|
97
103
|
|
98
104
|
def inventory
|
99
|
-
@inventory ||= Toolhound::Inventory.new(
|
105
|
+
@inventory ||= Toolhound::Inventory.new(self)
|
100
106
|
end
|
101
107
|
|
102
108
|
def inventory_item
|
103
|
-
@inventory_item ||= Toolhound::InventoryItem.new(
|
109
|
+
@inventory_item ||= Toolhound::InventoryItem.new(self)
|
104
110
|
end
|
105
111
|
|
106
112
|
def project
|
107
|
-
@project ||= Toolhound::Project.new(
|
113
|
+
@project ||= Toolhound::Project.new(self)
|
108
114
|
end
|
109
115
|
|
110
116
|
def rental
|
111
|
-
@rental ||= Toolhound::Rental.new(
|
117
|
+
@rental ||= Toolhound::Rental.new(self)
|
112
118
|
end
|
113
119
|
|
114
120
|
def rental_item
|
115
|
-
@rental_item ||= Toolhound::RentalItem.new(
|
121
|
+
@rental_item ||= Toolhound::RentalItem.new(self)
|
116
122
|
end
|
117
123
|
def rental_charge
|
118
|
-
@rental_charge ||= Toolhound::RentalCharge.new(
|
124
|
+
@rental_charge ||= Toolhound::RentalCharge.new(self)
|
119
125
|
end
|
120
126
|
|
121
127
|
def vendor
|
122
|
-
@vendor ||= Toolhound::Vendor.new(
|
128
|
+
@vendor ||= Toolhound::Vendor.new(self)
|
123
129
|
end
|
124
130
|
def manufacturer
|
125
|
-
@vendor ||= Toolhound::Manufacturer.new(
|
131
|
+
@vendor ||= Toolhound::Manufacturer.new(self)
|
126
132
|
end
|
127
133
|
def purchase_order
|
128
|
-
@vendor ||= Toolhound::PurchaseOrder.new(
|
134
|
+
@vendor ||= Toolhound::PurchaseOrder.new(self)
|
129
135
|
end
|
130
136
|
|
131
137
|
|
@@ -62,6 +62,10 @@ module Toolhound
|
|
62
62
|
all(where: [{int_curr_location_id: entity_id}])
|
63
63
|
end
|
64
64
|
|
65
|
+
def for_inventory(inventory_id)
|
66
|
+
|
67
|
+
end
|
68
|
+
|
65
69
|
def charges_for_entity(entity_id)
|
66
70
|
joins = default_joins
|
67
71
|
joins << "INNER JOIN tblInventoryType ON tblInventoryType.intInventoryTypeID = tblInventoryItem.intInventoryTypeID AND tblInventoryType.bolSerialized = 1"
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Toolhound
|
2
2
|
|
3
|
-
#
|
4
|
-
# URLs and to generate URLs
|
3
|
+
# A single charge for a rental item
|
5
4
|
class RentalCharge < Base
|
6
5
|
|
7
6
|
|
@@ -28,11 +27,11 @@ module Toolhound
|
|
28
27
|
arr
|
29
28
|
end
|
30
29
|
|
31
|
-
def find_by_entity_id(id)
|
32
|
-
|
33
|
-
end
|
30
|
+
# def find_by_entity_id(id)
|
31
|
+
# all(limit: 1, where: [{int_entity_id: id}]).first
|
32
|
+
# end
|
34
33
|
|
35
|
-
def find_first_and_last_charge_for_entity(
|
34
|
+
def find_first_and_last_charge_for_entity(entity_id)
|
36
35
|
selects = {
|
37
36
|
rental_charge: [
|
38
37
|
{dte_start_date: {as: :max_date, agg: :max} },
|
@@ -40,14 +39,14 @@ module Toolhound
|
|
40
39
|
]
|
41
40
|
}
|
42
41
|
|
43
|
-
build_and_query(selects: selects, where: [{int_entity_id:
|
42
|
+
build_and_query(selects: selects, where: [{int_entity_id: entity_id}])
|
44
43
|
end
|
45
44
|
|
46
45
|
def find_by_rental_id(id)
|
47
46
|
all(where: [{"rental_detail.int_rental_id" => id}])
|
48
47
|
end
|
49
48
|
|
50
|
-
def for_entity_over_period(
|
49
|
+
def for_entity_over_period(entity_id, from, to)
|
51
50
|
joins = []
|
52
51
|
joins << "LEFT OUTER JOIN tblRentalItem ON tblRentalItem.intRentalItemID = tblRentalCharge.intRentalItemID"
|
53
52
|
joins << "LEFT OUTER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID"
|
@@ -57,7 +56,7 @@ module Toolhound
|
|
57
56
|
joins << "INNER JOIN tblInventoryText ON tblInventory.intInventoryID = tblInventoryText.intInventoryID"
|
58
57
|
|
59
58
|
wheres = [
|
60
|
-
{"rental_charge.int_entity_id" =>
|
59
|
+
{"rental_charge.int_entity_id" => entity_id},
|
61
60
|
{"inventory.bol_deleted" => 0},
|
62
61
|
{"inventory.bol_is_active" => 1},
|
63
62
|
{"inventory_text.var_locale_id" => locale},
|