toolhound-ruby 1.0.30 → 1.0.31
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/base.rb +13 -5
- data/lib/toolhound-ruby/client.rb +2 -3
- data/lib/toolhound-ruby/job.rb +32 -1
- data/lib/toolhound-ruby/rental_charge.rb +5 -1
- data/lib/toolhound-ruby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88d1eafcdd7dee322458ac1af56517b52b361aef
|
4
|
+
data.tar.gz: 95f1b337472c23821da5c9e04cb896618e67c3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2a8fce6598ea148533c9785d9849024ab8abf386fc3134e7c5478aee2c24b7c2ed2a1ca15ac1f076490c56e6bc2bb38b95816de9edb3c90172c6f661807f8d7
|
7
|
+
data.tar.gz: dbdfb8cc992c7cf85b956eb8d2525915ca8acb095bea1c9f9e86034f1c6041ac4741d269ca896d7910c6bd9140b017810b0705d46b0992dfb18dcecb8634c01a
|
data/lib/toolhound-ruby/base.rb
CHANGED
@@ -6,7 +6,7 @@ module Toolhound
|
|
6
6
|
DATE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S".freeze
|
7
7
|
|
8
8
|
include Toolhound::Util
|
9
|
-
attr_accessor :connection
|
9
|
+
attr_accessor :connection, :client
|
10
10
|
|
11
11
|
def self.table_name
|
12
12
|
@@table_name[self.name]
|
@@ -297,11 +297,17 @@ module Toolhound
|
|
297
297
|
|
298
298
|
def query(query, options = {})
|
299
299
|
data = []
|
300
|
-
|
301
|
-
|
302
|
-
|
300
|
+
begin
|
301
|
+
results = connection.execute(query)
|
302
|
+
|
303
|
+
results.each(:cache_rows => false) do |row|
|
304
|
+
data << transform_attributes(row)
|
305
|
+
end
|
306
|
+
data
|
307
|
+
rescue TinyTds::Error
|
308
|
+
client.reset_connection
|
309
|
+
retry
|
303
310
|
end
|
304
|
-
data
|
305
311
|
ensure
|
306
312
|
finish_statement_handle(results)
|
307
313
|
end
|
@@ -320,6 +326,8 @@ module Toolhound
|
|
320
326
|
where = obj[:where] ? build_where(obj[:where]) : nil
|
321
327
|
order = obj[:order]
|
322
328
|
|
329
|
+
selects = "*" if selects.strip.length == 0
|
330
|
+
|
323
331
|
limit_str = limit ? "TOP(#{limit})" : ""
|
324
332
|
where_str = where.length > 0 ? "WHERE #{where}" : ""
|
325
333
|
order_str = order ? "ORDER BY #{order}" : ""
|
data/lib/toolhound-ruby/job.rb
CHANGED
@@ -20,12 +20,43 @@ module Toolhound
|
|
20
20
|
|
21
21
|
def default_joins
|
22
22
|
arr = []
|
23
|
-
|
23
|
+
arr << "INNER JOIN tblJobText ON (tblJobText.intJobID = tblJob.intJobID AND varLocaleID = '#{locale}')"
|
24
24
|
# arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"
|
25
25
|
|
26
26
|
arr
|
27
27
|
end
|
28
28
|
|
29
|
+
def default_wheres
|
30
|
+
[
|
31
|
+
{"job.bol_active" => true}
|
32
|
+
]
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def all(options = {})
|
37
|
+
entity_id = options[:entity_id]
|
38
|
+
|
39
|
+
wheres = default_wheres
|
40
|
+
selects = default_selects
|
41
|
+
joins = default_joins
|
42
|
+
|
43
|
+
joins << "
|
44
|
+
INNER JOIN (
|
45
|
+
SELECT DISTINCT intJobID FROM tblRentalCharge WHERE tblRentalCharge.intEntityID = '#{entity_id}' AND tblRentalCharge.intJobID is NOT NULL
|
46
|
+
) AS tblAssignees ON tblAssignees.intJobID = tblJob.intJobID" if entity_id
|
47
|
+
|
48
|
+
|
49
|
+
build_and_query(
|
50
|
+
joins: joins,
|
51
|
+
selects: selects,
|
52
|
+
where: wheres
|
53
|
+
)
|
54
|
+
|
55
|
+
# joins << "INNER JOIN tblRentalCharge ON tblRentalCharge.intEntityID = '#{entity_id}' AND tblRentalCharge.intJobID is NOT NULL" if entity_id
|
56
|
+
# SELECT DISTINCT intJobID FROM tblRentalCharge WHERE tblRentalCharge.intEntityID = '100044' AND tblRentalCharge.intJobID is NOT NULL;
|
57
|
+
|
58
|
+
end
|
59
|
+
|
29
60
|
def insert(variables = {})
|
30
61
|
vars = {created_user_id: 1, modified_user_id: 1, active: true, job: nil, created_date: nil, modified_date: nil}
|
31
62
|
# procedure("Job_Insert", vars)
|
@@ -52,6 +52,7 @@ module Toolhound
|
|
52
52
|
entity_id = options.delete :entity_id
|
53
53
|
from = options.delete :from
|
54
54
|
to = options.delete :to
|
55
|
+
job_id = options.delete :job_id
|
55
56
|
|
56
57
|
joins = []
|
57
58
|
joins << "LEFT OUTER JOIN tblRentalItem ON tblRentalItem.intRentalItemID = tblRentalCharge.intRentalItemID"
|
@@ -68,12 +69,14 @@ module Toolhound
|
|
68
69
|
) as taxQuery ON taxQuery.intLocationID = tblLocation.intLocationID"
|
69
70
|
joins << "LEFT OUTER JOIN tblTax ON tblTax.intLocationID = taxQuery.intLocationID AND tblTax.dteCreatedDate = taxQuery.max_date"
|
70
71
|
joins << "LEFT OUTER JOIN tblTaxText ON tblTaxText.intTaxID = tblTax.intTaxID AND tblTaxText.varLocaleID = '#{locale}'"
|
72
|
+
joins << "LEFT OUTER JOIN tblJobText ON tblJobText.intJobID = tblRentalCharge.intJobID AND tblJobText.varLocaleID = '#{locale}'"
|
71
73
|
wheres = [
|
72
74
|
{"inventory.bol_deleted" => 0},
|
73
75
|
{"inventory.bol_is_active" => 1},
|
74
76
|
{"inventory_text.var_locale_id" => locale},
|
75
77
|
]
|
76
78
|
|
79
|
+
wheres << {"rental_charge.int_job_id" => job_id} if job_id
|
77
80
|
wheres << {"rental_charge.int_entity_id" => entity_id} if entity_id
|
78
81
|
wheres << {dte_end_date: {value: [parse_time(from), parse_time(to)], op: :between} } if from && to
|
79
82
|
|
@@ -83,7 +86,7 @@ module Toolhound
|
|
83
86
|
:int_rental_charge_id, :int_entity_id, :int_qty, :dec_total, :var_type, :int_inventory_id_id,
|
84
87
|
:dec_days, :dec_daily, :dec_weeks, :dec_weekly, :dec_months, :dec_monthly,
|
85
88
|
# {var_work_order: :var_work_order_no},
|
86
|
-
:dte_start_date, :dte_end_date
|
89
|
+
:dte_start_date, :dte_end_date, :int_job_id
|
87
90
|
],
|
88
91
|
inventory_id: [{var_inventory_id: :inventory_id_no}, :int_inventory_id],
|
89
92
|
inventory: [:int_category_id, :int_sub_category_id, :int_inventory_type_id],
|
@@ -91,6 +94,7 @@ module Toolhound
|
|
91
94
|
:var_part_no, :var_description, {var_user_field1: :gl_revenue}, {var_user_field2: :gl_cogs_code},
|
92
95
|
{var_user_field3: :phase_code}
|
93
96
|
],
|
97
|
+
job_text: [:var_job, :var_job_number],
|
94
98
|
transaction: [{var_work_order: :var_work_order_no}, :var_transaction_no],
|
95
99
|
tax: [{dec_tax1_rate: :tax_rate}],
|
96
100
|
tax_text: [{var_tax1_description: :tax_label}],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toolhound-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Klooth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_tds
|