toolhound-ruby 1.0.22 → 1.0.23

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: 3ac12c439640a4d377f3e99d31eea0d39565008b
4
- data.tar.gz: 44328718e7c6552d5963cfbd28bb4e281907d2f1
3
+ metadata.gz: e3355cab98a26569ba55d4bdf0fa290707f3a2aa
4
+ data.tar.gz: 93e124b2bca52e00418d0b3d4e961629c0a014c9
5
5
  SHA512:
6
- metadata.gz: 5ffd9081ce59942944a1adf51cabbabf12bb09e312cb1f0f391001fc5b8f8a6ed775ac7f77db371562db2a04a57f2b53037d53fbc63203ee85df5213640c057e
7
- data.tar.gz: 528b7821fc1a2c360d99ccb02640432940716a28c716dfcca7d70ad67fa7bd862aff906c8f8bcc911e7f6d2d98538f1860f7d9db6effee31b32eec095584a705
6
+ metadata.gz: a28e80e89a5e5bea9b54afe1ef51d745c177a2625853eba2f329eba6a9c725184a09873a88c76a9f1de7f6ec4973b2eea49e8e5badc07232869a4651c3fdb128
7
+ data.tar.gz: c494e807cf7ceb4bac23188ad14be9aa63b2bb48ce67047f49bb4e3d4543603c1660bdb0d5bbafc0ee8f70cce4898f2bb18d9f21289f917438dd020ef5e249ca
@@ -66,34 +66,52 @@ module Toolhound
66
66
 
67
67
  end
68
68
 
69
- def charges_for_entity(entity_id, job_id=nil)
70
- joins = default_joins
69
+ def charges(options = {})
70
+ options = (options || {}).dup
71
+
72
+ job_id = options[:job_id]
73
+ entity_id = options[:entity_id]
74
+ order = options[:order] || "tblInventoryText.varPartNo"
75
+
76
+
77
+ joins = default_joins
78
+ entity_query = ""
79
+ charge_entity_query = ""
80
+ charge_entity_query1 = ""
81
+ if entity_id
82
+ entity_query = "AND tblRental.intEntityID = '#{entity_id}'"
83
+ charge_entity_query = "WHERE rc.intEntityID = '#{entity_id}'"
84
+ charge_entity_query1 = "WHERE intEntityID = '#{entity_id}'"
85
+ end
86
+
71
87
  joins << "INNER JOIN tblInventoryType ON tblInventoryType.intInventoryTypeID = tblInventoryItem.intInventoryTypeID AND tblInventoryType.bolSerialized = 1"
72
88
  joins << "INNER JOIN(
73
89
  SELECT tblRentalItem.intInventoryIDID, SUM(tblRentalItem.decTotalRent) AS decTotalRent
74
90
  FROM tblRentalItem
75
91
  INNER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID
76
- INNER JOIN tblRental ON tblRental.intRentalID = tblRentalDetail.intRentalID AND tblRental.intEntityID = '#{entity_id}'
92
+ INNER JOIN tblRental ON tblRental.intRentalID = tblRentalDetail.intRentalID #{entity_query}
77
93
  GROUP BY tblRentalItem.intInventoryIDID
78
94
  ) AS tblRentalQuery ON tblRentalQuery.intInventoryIDID = tblInventoryID.intInventoryIdID"
95
+
79
96
  joins << "LEFT OUTER JOIN (
80
97
  SELECT rc.intInventoryIDID, MAX(rc.intRentalChargeID) AS latest_id
81
98
  FROM tblRentalCharge as rc
82
- WHERE rc.intEntityID = '#{entity_id}'
99
+ #{charge_entity_query}
83
100
  GROUP BY rc.intInventoryIDID
84
101
  ) AS tblLatestCharge ON tblLatestCharge.intInventoryIDID = tblInventoryID.intInventoryIdID"
102
+
85
103
  joins << "LEFT OUTER JOIN (
86
104
  SELECT tblRentalCharge.intJobID, tblRentalCharge.intRentalChargeID
87
105
  FROM tblRentalCharge
88
- WHERE intEntityID = '#{entity_id}'
106
+ #{charge_entity_query1}
89
107
  ) AS tblJobCharge ON tblJobCharge.intRentalChargeID = tblLatestCharge.latest_id"
108
+
90
109
  joins << "LEFT OUTER JOIN tblJobText on tblJobText.intJobID = tblJobCharge.intJobID AND tblJobText.varLocaleID = '#{locale}'"
91
110
 
92
- selects = default_selects
111
+ selects = default_selects
93
112
  selects[:job_text] = [:int_job_id, :int_job_text_id, :var_job_number, :var_job]
94
113
  selects[:rental_query] = [:dec_total_rent]
95
114
 
96
- # (tblInventoryItem.intQOH=@p_QOH OR @p_QOH IS NULL)
97
115
  wheres = []
98
116
  if job_id
99
117
  if job_id == :null
@@ -102,20 +120,9 @@ module Toolhound
102
120
  wheres << "(tblJobText.intJobID = #{job_id})"
103
121
  end
104
122
  end
105
- build_and_query(selects: selects, where: wheres, joins: joins, order: "tblInventoryText.varPartNo")
106
-
107
- # SELECT tblInventoryItem.*, subquery1.total_rent FROM tblInventoryItem
108
- # INNER JOIN tblInventoryID ON tblInventoryItem.intInventoryItemID = tblInventoryID.intInventoryItemID
109
- # INNER JOIN tblInventoryItemText ON tblInventoryItemText.intInventoryItemID = tblInventoryItem.intInventoryItemID
110
- # INNER JOIN tblInventoryType ON tblInventoryType.intInventoryTypeID = tblInventoryItem.intInventoryTypeID AND tblInventoryType.bolSerialized = 1
111
- # INNER JOIN(
112
- # SELECT tblRentalItem.intInventoryIDID, SUM(tblRentalItem.decTotalRent) AS total_rent
113
- # FROM tblRentalItem
114
- # INNER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID
115
- # INNER JOIN tblRental ON tblRental.intRentalID = tblRentalDetail.intRentalID AND tblRental.intEntityID = 100002
116
- #
117
- # GROUP BY tblRentalItem.intInventoryIDID
118
- # ) AS subquery1 ON subquery1.intInventoryIDID = tblInventoryID.intInventoryIdID
123
+
124
+ build_and_query(selects: selects, where: wheres, joins: joins, order: order)
125
+
119
126
  end
120
127
 
121
128
 
@@ -1,3 +1,3 @@
1
1
  module Toolhound
2
- VERSION = "1.0.22"
2
+ VERSION = "1.0.23"
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.22
4
+ version: 1.0.23
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-03 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tiny_tds