toolhound-ruby 1.0.30 → 1.0.31

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d9ecf8fff9bb7cfebea4141a5592d9ede9a8f4f
4
- data.tar.gz: 4cc0a0cfb46b5381405b148ad51be853a86a1eab
3
+ metadata.gz: 88d1eafcdd7dee322458ac1af56517b52b361aef
4
+ data.tar.gz: 95f1b337472c23821da5c9e04cb896618e67c3d0
5
5
  SHA512:
6
- metadata.gz: 26925ecc1c1b2fb6dab87fab8f1d6e1248fb98ce68c2e51c139de89bf35a15053cfb3be8d23eb516973c614d75a2de4fc553d1b8645f0f041394f34d9eedfc84
7
- data.tar.gz: f9e415d8d005e4efcfec7953df3881f49ac78a5ffd654863cefe9bf9f4d63d475d16d66d875c2e18863b88406f2dc4162f3460c2fd215c0aa52e5667c1c69ba3
6
+ metadata.gz: d2a8fce6598ea148533c9785d9849024ab8abf386fc3134e7c5478aee2c24b7c2ed2a1ca15ac1f076490c56e6bc2bb38b95816de9edb3c90172c6f661807f8d7
7
+ data.tar.gz: dbdfb8cc992c7cf85b956eb8d2525915ca8acb095bea1c9f9e86034f1c6041ac4741d269ca896d7910c6bd9140b017810b0705d46b0992dfb18dcecb8634c01a
@@ -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
- results = connection.execute(query)
301
- results.each(:cache_rows => false) do |row|
302
- data << transform_attributes(row)
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}" : ""
@@ -74,9 +74,8 @@ module Toolhound
74
74
  end
75
75
 
76
76
  def connection
77
- if @connection && @connection.dead?
78
- sign_in
79
- end
77
+ sign_in if !@connection || @connection.dead?
78
+
80
79
  @connection
81
80
  end
82
81
 
@@ -20,12 +20,43 @@ module Toolhound
20
20
 
21
21
  def default_joins
22
22
  arr = []
23
- # arr << "INNER JOIN tblManufacturerText ON (tblManufacturerText.intManufacturerID = tblManufacturer.intManufacturerID AND varLocaleID = '#{locale}')"
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}],
@@ -1,3 +1,3 @@
1
1
  module Toolhound
2
- VERSION = "1.0.30"
2
+ VERSION = "1.0.31"
3
3
  end
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.30
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-08 00:00:00.000000000 Z
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tiny_tds