toolhound-ruby 1.0.12 → 1.0.13
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/transaction.rb +69 -8
- 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: 2066d770abb531ef783f2453f8df79e09f4cf3f8
|
4
|
+
data.tar.gz: e344e681caf7bb9e4ffd3255e89261ab57e4ca5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e02ea1af8bda11dd2e7ebbc500a5e2329b3bf3fe76c6cdbf17a4629488c86a2117c8753da74722810a248cef0b0eb4b3e77beb9aaaf5a768a2c655703500e364
|
7
|
+
data.tar.gz: 3f7277d8f6a8935a7b11f527b3310a6e0b93a2859eca1a6d07a1dae2e52f0f85d8c6d44f4483e1d4389c9afe4c593b812632226a06a79b154fb9ab633e5b51fe
|
@@ -10,24 +10,85 @@ module Toolhound
|
|
10
10
|
# self.primary_key = :int_rental_id
|
11
11
|
|
12
12
|
def default_selects
|
13
|
+
# tblWorkOrder.varWorkOrderNo,
|
14
|
+
# tblInventoryID.varInventoryID,
|
13
15
|
{
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
transaction_detail: ['intInventoryIdID', :int_transaction_detail_id, :int_qty, :int_qty_return, :dec_unit_cost],
|
17
|
+
transaction: [:int_transaction_id, :dte_transaction_date, :var_transaction_no, :int_location_id, :int_entity_id, :int_job_id],
|
18
|
+
transaction_type: [:bol_return],
|
19
|
+
job_text: [:var_job_number, :var_job],
|
20
|
+
return_status: [:int_return_status_id],
|
21
|
+
return_status_text: [:var_return_status],
|
22
|
+
inventory_status_text: [:var_inventory_status],
|
23
|
+
entity: [{var_entity_id: "varJobNo"}],
|
24
|
+
entity_location_text: [:var_location_name],
|
25
|
+
|
26
|
+
inventory_id: [{var_inventory_id: "varInventoryIdNo"}],
|
27
|
+
inventory: [:int_inventory_id, :int_category_id, :int_sub_category_id],
|
28
|
+
inventory_text: [:var_description, :var_part_no, {varUserField1: "varGlRevenue"}, {varUserField2: "varGlCOGSCode"}, {varUserField3: "varPhaseCode"}],
|
29
|
+
inventory_item_text: [:var_serial_number]
|
18
30
|
}
|
19
31
|
end
|
20
32
|
|
21
33
|
def default_joins
|
22
34
|
arr = []
|
23
|
-
|
24
|
-
|
35
|
+
arr << "INNER JOIN tblTransaction ON tblTransaction.intTransactionID = tblTransactionDetail.intTransactionID"
|
36
|
+
arr << "INNER JOIN tblTransactionType ON tblTransactionType.intTransactionTypeID = tblTransactionDetail.intTransactionTypeID"
|
37
|
+
arr << "INNER JOIN tblReturnStatus ON tblReturnStatus.intReturnStatusID = tblTransactionDetail.intReturnStatusID"
|
38
|
+
arr << "INNER JOIN tblReturnStatusText ON tblReturnStatusText.intReturnStatusID = tblReturnStatus.intReturnStatusID AND tblReturnStatusText.varLocaleID = '#{locale}'"
|
39
|
+
arr << "INNER JOIN tblInventoryStatusText ON tblInventoryStatusText.intInventoryStatusID = tblTransactionType.intInventoryStatusID AND tblInventoryStatusText.varLocaleID = '#{locale}'"
|
40
|
+
arr << "INNER JOIN tblInventoryID ON tblInventoryID.intInventoryIdID = tblTransactionDetail.intInventoryIdID"
|
41
|
+
arr << "INNER JOIN tblInventory ON tblInventory.intInventoryID = tblInventoryID.intInventoryID"
|
42
|
+
arr << "INNER JOIN tblInventoryText ON tblInventoryText.intInventoryID = tblInventory.intInventoryID AND tblInventoryText.varLocaleID = '#{locale}'"
|
43
|
+
arr << "LEFT OUTER JOIN tblInventoryItem ON tblInventoryItem.intInventoryItemID = tblInventoryID.intInventoryItemID"
|
44
|
+
arr << "LEFT OUTER JOIN tblInventoryItemText ON tblInventoryItemText.intInventoryItemID = tblInventoryItem.intInventoryItemID AND tblInventoryItemText.varLocaleID = '#{locale}'"
|
45
|
+
arr << "INNER JOIN tblEntity ON tblTransaction.intEntityID = tblEntity.intEntityID"
|
46
|
+
arr << "INNER JOIN tblLocation AS tblEntityLocation ON tblEntityLocation.intEntityID = tblEntity.intEntityID"
|
47
|
+
arr << "INNER JOIN tblLocationText AS tblEntityLocationText ON tblEntityLocationText.intLocationID = tblEntityLocation.intLocationID AND tblEntityLocationText.varLocaleID = '#{locale}'"
|
48
|
+
arr << "LEFT OUTER JOIN tblJobText ON tblJobText.intJobID = tblTransaction.intJobID AND tblJobText.varLocaleID = '#{locale}'"
|
49
|
+
|
25
50
|
|
51
|
+
# AND tblTransactionType.bolReturn = 'true'
|
26
52
|
arr
|
27
53
|
end
|
28
54
|
|
29
|
-
|
30
|
-
|
55
|
+
|
56
|
+
def return_periods_for_entity(entity_id)
|
57
|
+
selects = {
|
58
|
+
transaction: [
|
59
|
+
{dte_transaction_date: {as: :min_date, agg: :min} },
|
60
|
+
{dte_transaction_date: {as: :max_date, agg: :max} }
|
61
|
+
]
|
62
|
+
}
|
63
|
+
joins = []
|
64
|
+
joins << "INNER JOIN tblTransaction ON tblTransaction.intTransactionID = tblTransactionDetail.intTransactionID"
|
65
|
+
joins << "INNER JOIN tblTransactionType ON
|
66
|
+
tblTransactionType.intTransactionTypeID = tblTransactionDetail.intTransactionTypeID
|
67
|
+
AND tblTransactionType.bolReturn = 'true'
|
68
|
+
"
|
69
|
+
|
70
|
+
|
71
|
+
build_and_query(joins: joins, selects: selects, where: [{'transaction.int_entity_id' => entity_id}], from: 'tblTransactionDetail').first
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def returns(options)
|
76
|
+
entity_id = options.delete :entity_id
|
77
|
+
from_date = options.delete :from_date
|
78
|
+
to_date = options.delete :to_date
|
79
|
+
damaged_only = options.delete :damaged_only
|
80
|
+
|
81
|
+
selects = default_selects
|
82
|
+
joins = default_joins
|
83
|
+
wheres = []
|
84
|
+
wheres << {"transaction_type.bol_return" => 'true'}
|
85
|
+
|
86
|
+
wheres << {"transaction.int_entity_id" => entity_id} if entity_id
|
87
|
+
wheres << "tblTransaction.dteTransactionDate BETWEEN '#{from_date}' AND '#{to_date}'" if from_date && to_date
|
88
|
+
wheres << "(tblReturnStatus.bolCreateWO = 1 OR tblReturnStatus.bolRetire = 1)" if damaged_only == true
|
89
|
+
|
90
|
+
build_and_query(joins: joins, selects: selects, where: wheres, from: 'tblTransactionDetail', order: "tblEntityLocationText.varLocationName")
|
91
|
+
|
31
92
|
end
|
32
93
|
# def insert(variables = {})
|
33
94
|
# vars = {created_user_id: 1, modified_user_id: 1, active: true, job: nil, created_date: nil, modified_date: nil}
|
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.13
|
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-02-
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tiny_tds
|