toolhound-ruby 1.0.5 → 1.0.6
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/inventory_item.rb +98 -0
- data/lib/toolhound-ruby/manufacturer.rb +29 -0
- data/lib/toolhound-ruby/purchase_order.rb +33 -0
- data/lib/toolhound-ruby/purchase_order_item.rb +44 -0
- data/lib/toolhound-ruby/rental.rb +37 -0
- data/lib/toolhound-ruby/rental_charge.rb +89 -0
- data/lib/toolhound-ruby/rental_item.rb +53 -0
- data/lib/toolhound-ruby/util.rb +46 -0
- data/lib/toolhound-ruby/vendor.rb +34 -0
- data/lib/toolhound-ruby/version.rb +1 -1
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d99994aabb935cb231712edbb673521c8fdd9e57
|
4
|
+
data.tar.gz: 9535dffb590da767e2da186519546924431b01a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 406fe1846d7896d6470234fbffba4884eb1ee9052da30394bcacfd1ed6d888f7617295e8a46539dff896ac045a385a6410dba59ba1f45cf395c7e42e37a321da
|
7
|
+
data.tar.gz: cec3818bd1226c6d55912c87b2e6205a7f2a9ea4e48bd4ac4faca053a22c335e72e3bd4ea7cc1a54a1585fbc0771c123231c23c12b7cb5cf7056c24720acdb30
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# INNER JOIN tblInventoryID AS iid ON iid.intInventoryIdID = rc.intInventoryIDID
|
2
|
+
# INNER JOIN tblInventory AS iv ON iid.intInventoryID = iv.intInventoryID
|
3
|
+
# INNER JOIN tblInventoryText AS ivt ON iv.intInventoryID = ivt.intInventoryID
|
4
|
+
module Toolhound
|
5
|
+
|
6
|
+
# Class to parse GitHub repository owner and name from
|
7
|
+
# URLs and to generate URLs
|
8
|
+
class InventoryItem < Base
|
9
|
+
# attr_accessor :owner, :name, :id
|
10
|
+
|
11
|
+
# self.table_name = "tblInventoryItem"
|
12
|
+
# self.primary_key = "intInventoryItemID"
|
13
|
+
|
14
|
+
#
|
15
|
+
# def default_selects
|
16
|
+
# selects = {
|
17
|
+
# inventory: ["intInventoryID", "intCategoryID", "intSubCategoryID", "intManufacturerID", "intVendorID", "dteCreatedDate", "dteModifiedDate"],
|
18
|
+
# inventory_text: ["varPartNo", "varDescription", "txtNotes", {varUserField1: "varGlRevenue"}, {varUserField2: "varGlCOGSCode"}, {varUserField3: "varPhaseCode"}],
|
19
|
+
# unit_of_measure_text: ["varUnitOfMeasure"],
|
20
|
+
# category: ["varCategory"],
|
21
|
+
# sub_category: ["varCategory"]
|
22
|
+
# }
|
23
|
+
# end
|
24
|
+
# def default_joins
|
25
|
+
# arr = []
|
26
|
+
# arr << "INNER JOIN tblInventoryType ON tblInventory.intInventoryTypeID = tblInventoryType.intInventoryTypeID"
|
27
|
+
# arr << "INNER JOIN tblInventoryText ON (tblInventoryText.intInventoryID = tblInventory.intInventoryID AND tblInventoryText.varLocaleID = '#{locale}')"
|
28
|
+
# arr << "LEFT OUTER JOIN tblUnitOfMeasureText ON (tblUnitOfMeasureText.intUofMID = tblInventory.intUofMID )"
|
29
|
+
# arr << "LEFT OUTER JOIN tblCategoryText AS tblCategory ON (tblCategory.intCategoryID = tblInventory.intCategoryID AND tblCategory.varLocaleID = '#{locale}')"
|
30
|
+
# arr << "LEFT OUTER JOIN tblCategoryText AS tblSubCategory ON (tblSubCategory.intCategoryID = tblInventory.intSubCategoryID AND tblSubCategory.varLocaleID = '#{locale}')"
|
31
|
+
# end
|
32
|
+
def default_selects
|
33
|
+
# decCost = purchase amount
|
34
|
+
{
|
35
|
+
inventory_item: [
|
36
|
+
:int_inventory_item_id, "intQOH", :int_inventory_id, :int_inventory_type_id, :dec_cost, :dte_created_date, :dte_modified_date,
|
37
|
+
{int_curr_location_id: :entity_id}
|
38
|
+
],
|
39
|
+
inventory_item_text: [:var_serial_number, :var_user_field1, :var_user_field2, :var_user_field3, :var_bin],
|
40
|
+
inventory: [:int_category_id, :int_sub_category_id],
|
41
|
+
inventory_text: [:var_description, :var_part_no],
|
42
|
+
inventory_id: ["intInventoryIdID", {varInventoryID: "inventory_idid"}]
|
43
|
+
}
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def default_wheres
|
48
|
+
[{bolActive: 1 }, {bolDeleted: 0}]
|
49
|
+
end
|
50
|
+
|
51
|
+
def default_joins
|
52
|
+
arr = []
|
53
|
+
arr << "INNER JOIN tblInventory ON (tblInventory.intInventoryID = tblInventoryItem.intInventoryID AND tblInventory.bolDeleted = 0)"
|
54
|
+
arr << "INNER JOIN tblInventoryText ON (tblInventoryText.intInventoryID = tblInventory.intInventoryID and tblInventoryText.varLocaleID ='#{locale}')"
|
55
|
+
arr << "INNER JOIN tblInventoryItemText ON (tblInventoryItem.intInventoryItemID = tblInventoryItemText.intInventoryItemID and tblInventoryItemText.varLocaleID = '#{locale}')"
|
56
|
+
arr << "INNER JOIN tblInventoryID ON tblInventoryID.intInventoryItemID = tblInventoryItem.intInventoryItemID"
|
57
|
+
|
58
|
+
arr
|
59
|
+
end
|
60
|
+
|
61
|
+
def for_entity(entity_id)
|
62
|
+
all(where: [{int_curr_location_id: entity_id}])
|
63
|
+
end
|
64
|
+
|
65
|
+
def charges_for_entity(entity_id)
|
66
|
+
joins = default_joins
|
67
|
+
joins << "INNER JOIN tblInventoryType ON tblInventoryType.intInventoryTypeID = tblInventoryItem.intInventoryTypeID AND tblInventoryType.bolSerialized = 1"
|
68
|
+
joins << "INNER JOIN(
|
69
|
+
SELECT tblRentalItem.intInventoryIDID, SUM(tblRentalItem.decTotalRent) AS decTotalRent
|
70
|
+
FROM tblRentalItem
|
71
|
+
INNER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID
|
72
|
+
INNER JOIN tblRental ON tblRental.intRentalID = tblRentalDetail.intRentalID AND tblRental.intEntityID = '#{entity_id}'
|
73
|
+
GROUP BY tblRentalItem.intInventoryIDID
|
74
|
+
) AS tblRentalQuery ON tblRentalQuery.intInventoryIDID = tblInventoryID.intInventoryIdID"
|
75
|
+
|
76
|
+
selects = default_selects
|
77
|
+
selects[:rental_query] = [:dec_total_rent]
|
78
|
+
|
79
|
+
build_and_query(selects: selects, where: [], joins: joins, order: "tblInventoryText.varPartNo")
|
80
|
+
|
81
|
+
# SELECT tblInventoryItem.*, subquery1.total_rent FROM tblInventoryItem
|
82
|
+
# INNER JOIN tblInventoryID ON tblInventoryItem.intInventoryItemID = tblInventoryID.intInventoryItemID
|
83
|
+
# INNER JOIN tblInventoryItemText ON tblInventoryItemText.intInventoryItemID = tblInventoryItem.intInventoryItemID
|
84
|
+
# INNER JOIN tblInventoryType ON tblInventoryType.intInventoryTypeID = tblInventoryItem.intInventoryTypeID AND tblInventoryType.bolSerialized = 1
|
85
|
+
# INNER JOIN(
|
86
|
+
# SELECT tblRentalItem.intInventoryIDID, SUM(tblRentalItem.decTotalRent) AS total_rent
|
87
|
+
# FROM tblRentalItem
|
88
|
+
# INNER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID
|
89
|
+
# INNER JOIN tblRental ON tblRental.intRentalID = tblRentalDetail.intRentalID AND tblRental.intEntityID = 100002
|
90
|
+
#
|
91
|
+
# GROUP BY tblRentalItem.intInventoryIDID
|
92
|
+
# ) AS subquery1 ON subquery1.intInventoryIDID = tblInventoryID.intInventoryIdID
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class Manufacturer < Base
|
6
|
+
|
7
|
+
|
8
|
+
# self.table_name = :rental
|
9
|
+
# self.primary_key = :int_rental_id
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
{
|
13
|
+
manufacturer: [:int_manufacturer_id ],
|
14
|
+
manufacturer_text: [:var_manufacturer, :var_phone, :var_fax, :var_url]
|
15
|
+
# rental_item_detail: [:var_status, :status_date, ],
|
16
|
+
# rental_detail: [:int_rental_id, :int_inventory_id, :int_quantity, :dec_daily, :dec_weekly, :dec_monthly, :dec_selling_price],
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_joins
|
21
|
+
arr = []
|
22
|
+
arr << "INNER JOIN tblManufacturerText ON (tblManufacturerText.intManufacturerID = tblManufacturer.intManufacturerID AND varLocaleID = '#{locale}')"
|
23
|
+
# arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"
|
24
|
+
|
25
|
+
arr
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class PurchaseOrder < Base
|
6
|
+
|
7
|
+
|
8
|
+
# self.table_name = :rental
|
9
|
+
self.primary_key = "intPOID"
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
{
|
13
|
+
purchase_order: [
|
14
|
+
"intPOID", {"varPONO" => :po_no}, :int_vendor_id, :int_location_id, :int_payment_term_id, :bol_closed, :bol_approved,
|
15
|
+
:dte_created_date, :dte_modified_date, :dte_cancelled_date, :bol_cancelled, :var_revision_no
|
16
|
+
],
|
17
|
+
purchase_order_text: [:txt_notes]
|
18
|
+
|
19
|
+
# rental_item_detail: [:var_status, :status_date, ],
|
20
|
+
# rental_detail: [:int_rental_id, :int_inventory_id, :int_quantity, :dec_daily, :dec_weekly, :dec_monthly, :dec_selling_price],
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_joins
|
25
|
+
arr = []
|
26
|
+
arr << "INNER JOIN tblPurchaseOrderText ON (tblPurchaseOrderText.intPOID = tblPurchaseOrder.intPOID AND varLocaleID = '#{locale}')"
|
27
|
+
# arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"
|
28
|
+
|
29
|
+
arr
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class PurchaseOrderItem < Base
|
6
|
+
|
7
|
+
|
8
|
+
self.table_name = :purchase_order_detail
|
9
|
+
self.primary_key = "intPODetailID"
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
{
|
13
|
+
purchase_order_detail: [
|
14
|
+
"intPOID", :int_inventory_id, :dec_cost, :int_qty_ordered, :int_qty_received, :int_qty_rejected,
|
15
|
+
:int_manufacturer_id, :bol_rent, :int_purchase_uof_m, :int_qty_required, :int_qty_returned,
|
16
|
+
:dte_expected
|
17
|
+
]
|
18
|
+
}
|
19
|
+
# {
|
20
|
+
# purchase_order: [
|
21
|
+
# "intPOID", "varPONO", :int_vendor_id, :int_location_id, :int_payment_term_id, :bol_closed, :bol_approved,
|
22
|
+
# :dte_created_date, :dte_modified_date, :dte_cancelled_date, :bol_cancelled, :var_revision_no
|
23
|
+
# ],
|
24
|
+
# purchase_order_text: [:txt_notes]
|
25
|
+
|
26
|
+
# rental_item_detail: [:var_status, :status_date, ],
|
27
|
+
# rental_detail: [:int_rental_id, :int_inventory_id, :int_quantity, :dec_daily, :dec_weekly, :dec_monthly, :dec_selling_price],
|
28
|
+
# }
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_joins
|
32
|
+
arr = []
|
33
|
+
arr << "INNER JOIN tblPurchaseOrderText ON (tblPurchaseOrderText.intPOID = tblPurchaseOrder.intPOID AND varLocaleID = '#{locale}')"
|
34
|
+
# arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"
|
35
|
+
|
36
|
+
arr
|
37
|
+
end
|
38
|
+
|
39
|
+
def for_po(po_id)
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class Rental < Base
|
6
|
+
|
7
|
+
|
8
|
+
# self.table_name = :rental
|
9
|
+
# self.primary_key = :int_rental_id
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
#{ }"SELECT tblEntity.intEntityID, tblEntity.varEntityID AS job_no, tblLocation.intLocationID, tblLocationText.varLocationName FROM tblEntity INNER JOIN tblLocation ON tblLocation.intEntityID = tblEntity.intEntityID INNER JOIN tblLocationText ON tblLocationText.intLocationID = tblLocation.intLocationID WHERE varEntityID LIKE '%10526.00%'"
|
13
|
+
{
|
14
|
+
rental: [
|
15
|
+
:int_rental_id, :var_rental_number, :int_from_location_id, :int_entity_id, :dte_required_date, :int_rate_sheet_id,
|
16
|
+
:int_job_id, :dte_created_date, :dte_modified_date
|
17
|
+
],
|
18
|
+
job_text: [{var_job: :contact_name}]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def default_joins
|
23
|
+
arr = []
|
24
|
+
arr << "LEFT OUTER JOIN tblJobText ON (tblJobText.intJobID = tblRental.intJobID AND varLocaleID = '#{locale}')"
|
25
|
+
# arr << "INNER JOIN tblLocationText ON (tblLocationText.intLocationID = tblLocation.intLocationID)"
|
26
|
+
|
27
|
+
arr
|
28
|
+
end
|
29
|
+
|
30
|
+
def for_entity(id)
|
31
|
+
all(where: [{int_entity_id: id}])
|
32
|
+
end
|
33
|
+
|
34
|
+
# rename_attributes intLocationID: 'location_id'
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class RentalCharge < Base
|
6
|
+
|
7
|
+
|
8
|
+
# self.table_name = :rental
|
9
|
+
# self.primary_key = :int_rental_id
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
#{ }"SELECT tblEntity.intEntityID, tblEntity.varEntityID AS job_no, tblLocation.intLocationID, tblLocationText.varLocationName FROM tblEntity INNER JOIN tblLocation ON tblLocation.intEntityID = tblEntity.intEntityID INNER JOIN tblLocationText ON tblLocationText.intLocationID = tblLocation.intLocationID WHERE varEntityID LIKE '%10526.00%'"
|
13
|
+
{
|
14
|
+
rental_charge: [:int_rental_charge_id ]
|
15
|
+
# rental_item_detail: [:var_status, :status_date, ],
|
16
|
+
# rental_detail: [:int_rental_id, :int_inventory_id, :int_quantity, :dec_daily, :dec_weekly, :dec_monthly, :dec_selling_price],
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_joins
|
21
|
+
arr = []
|
22
|
+
# arr << "INNER JOIN tblRentalItemDetail ON (tblRentalItemDetail.intRentalItemID = tblRentalItem.intRentalItemID)"
|
23
|
+
# arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"
|
24
|
+
|
25
|
+
# arr << "INNER JOIN tblRental ON (tblRental.intRentalID = tblRentalDetail.intRentalID)"
|
26
|
+
# arr << "INNER JOIN tblLocationText ON (tblLocationText.intLocationID = tblLocation.intLocationID)"
|
27
|
+
|
28
|
+
arr
|
29
|
+
end
|
30
|
+
|
31
|
+
def find_by_entity_id(id)
|
32
|
+
all(limit: 1, where: [{int_entity_id: id}]).first
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_first_and_last_charge_for_entity(id)
|
36
|
+
selects = {
|
37
|
+
rental_charge: [
|
38
|
+
{dte_start_date: {as: :max_date, agg: :max} },
|
39
|
+
{dte_start_date: {as: :min_date, agg: :min} }
|
40
|
+
]
|
41
|
+
}
|
42
|
+
|
43
|
+
build_and_query(selects: selects, where: [{int_entity_id: id}])
|
44
|
+
end
|
45
|
+
|
46
|
+
def find_by_rental_id(id)
|
47
|
+
all(where: [{"rental_detail.int_rental_id" => id}])
|
48
|
+
end
|
49
|
+
|
50
|
+
def for_entity_over_period(id, from, to)
|
51
|
+
joins = []
|
52
|
+
joins << "LEFT OUTER JOIN tblRentalItem ON tblRentalItem.intRentalItemID = tblRentalCharge.intRentalItemID"
|
53
|
+
joins << "LEFT OUTER JOIN tblRentalDetail ON tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID"
|
54
|
+
joins << "LEFT OUTER JOIN tblRental ON tblRental.intRentalID = tblRentalDetail.intRentalID"
|
55
|
+
joins << "INNER JOIN tblInventoryID ON tblInventoryID.intInventoryIdID = tblRentalCharge.intInventoryIDID"
|
56
|
+
joins << "INNER JOIN tblInventory ON tblInventoryID.intInventoryID = tblInventory.intInventoryID"
|
57
|
+
joins << "INNER JOIN tblInventoryText ON tblInventory.intInventoryID = tblInventoryText.intInventoryID"
|
58
|
+
|
59
|
+
wheres = [
|
60
|
+
{"rental_charge.int_entity_id" => id},
|
61
|
+
{"inventory.bol_deleted" => 0},
|
62
|
+
{"inventory.bol_is_active" => 1},
|
63
|
+
{"inventory_text.var_locale_id" => locale},
|
64
|
+
{dte_end_date: {value: [from, to], op: :between} }
|
65
|
+
]
|
66
|
+
selects = {
|
67
|
+
rental_charge: [
|
68
|
+
:int_rental_charge_id, :int_entity_id, :int_qty, :dec_total, :var_type, :int_inventory_id_id,
|
69
|
+
:dec_days, :dec_daily, :dec_weeks, :dec_weekly, :dec_months, :dec_monthly
|
70
|
+
],
|
71
|
+
inventory_id: [{var_inventory_id: :inventory_id_no}, :int_inventory_id],
|
72
|
+
inventory: [:int_category_id, :int_sub_category_id, :int_inventory_type_id],
|
73
|
+
inventory_text: [
|
74
|
+
:var_part_no, :var_description, {var_user_field1: :gl_revenue}, {var_user_field2: :gl_cogs_code},
|
75
|
+
{var_user_field3: :phase_code}
|
76
|
+
],
|
77
|
+
rental: [:var_rental_number]
|
78
|
+
}
|
79
|
+
|
80
|
+
build_and_query(selects: selects, where: wheres, joins: joins, order: "tblInventoryText.varPartNo")
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
# rename_attributes intLocationID: 'location_id'
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class RentalItem < Base
|
6
|
+
|
7
|
+
|
8
|
+
# self.table_name = :rental
|
9
|
+
# self.primary_key = :int_rental_id
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
#{ }"SELECT tblEntity.intEntityID, tblEntity.varEntityID AS job_no, tblLocation.intLocationID, tblLocationText.varLocationName FROM tblEntity INNER JOIN tblLocation ON tblLocation.intEntityID = tblEntity.intEntityID INNER JOIN tblLocationText ON tblLocationText.intLocationID = tblLocation.intLocationID WHERE varEntityID LIKE '%10526.00%'"
|
13
|
+
{
|
14
|
+
rental_item: [:int_rental_detail_id, :int_inventory_id_id ],
|
15
|
+
# rental_item_detail: [:var_status, :status_date, ],
|
16
|
+
rental_detail: [:int_rental_id, :int_inventory_id, :int_quantity, :dec_daily, :dec_weekly, :dec_monthly, :dec_selling_price],
|
17
|
+
# rental: [
|
18
|
+
# :int_rental_id, :var_rental_number, :int_from_location_id, :int_entity_id, :dte_required_date, :int_rate_sheet_id,
|
19
|
+
# :int_job_id, :dte_created_date, :dte_modified_date
|
20
|
+
# ],
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_joins
|
25
|
+
arr = []
|
26
|
+
# arr << "INNER JOIN tblRentalItemDetail ON (tblRentalItemDetail.intRentalItemID = tblRentalItem.intRentalItemID)"
|
27
|
+
arr << "INNER JOIN tblRentalDetail ON (tblRentalDetail.intRentalDetailID = tblRentalItem.intRentalDetailID)"
|
28
|
+
|
29
|
+
# arr << "INNER JOIN tblRental ON (tblRental.intRentalID = tblRentalDetail.intRentalID)"
|
30
|
+
# arr << "INNER JOIN tblLocationText ON (tblLocationText.intLocationID = tblLocation.intLocationID)"
|
31
|
+
|
32
|
+
arr
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_by_entity_id(id)
|
36
|
+
all(limit: 1, where: [{int_entity_id: id}]).first
|
37
|
+
end
|
38
|
+
|
39
|
+
def find_by_rental_id(id)
|
40
|
+
all(where: [{"rental_detail.int_rental_id" => id}])
|
41
|
+
end
|
42
|
+
|
43
|
+
def total_charges_for_entity(id)
|
44
|
+
|
45
|
+
|
46
|
+
build_and_query(selects: selects, where: wheres, joins: joins)
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
# rename_attributes intLocationID: 'location_id'
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Toolhound
|
2
|
+
module Util
|
3
|
+
|
4
|
+
# class << self
|
5
|
+
def acronyms
|
6
|
+
{"rest" => "REST", "html" =>"HTML", "id" => "ID", "url" => "URL"}
|
7
|
+
end
|
8
|
+
def acronym_regex
|
9
|
+
/#{acronyms.values.join("|")}/
|
10
|
+
end
|
11
|
+
|
12
|
+
def demodulize(path)
|
13
|
+
path = path.to_s
|
14
|
+
if i = path.rindex('::')
|
15
|
+
path[(i+2)..-1]
|
16
|
+
else
|
17
|
+
path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def underscore(camel_cased_word)
|
22
|
+
return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
|
23
|
+
word = camel_cased_word.to_s.gsub('::'.freeze, '/'.freeze)
|
24
|
+
word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_'.freeze }#{$2.downcase}" }
|
25
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
|
26
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
|
27
|
+
word.tr!("-".freeze, "_".freeze)
|
28
|
+
word.downcase!
|
29
|
+
word
|
30
|
+
end
|
31
|
+
|
32
|
+
def camelize(term, uppercase_first_letter = true)
|
33
|
+
string = term.to_s
|
34
|
+
if uppercase_first_letter
|
35
|
+
string = string.sub(/^[a-z\d]*/) { |match| match.capitalize }
|
36
|
+
else
|
37
|
+
string = string.sub(/^(?:#{acronym_regex}(?=\b|[A-Z_])|\w)/) { |match| match.downcase }
|
38
|
+
end
|
39
|
+
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{acronyms[$2] || $2.capitalize}" }
|
40
|
+
string.gsub!('/'.freeze, '::'.freeze)
|
41
|
+
string
|
42
|
+
end
|
43
|
+
# end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Toolhound
|
2
|
+
|
3
|
+
# Class to parse GitHub repository owner and name from
|
4
|
+
# URLs and to generate URLs
|
5
|
+
class Vendor < Base
|
6
|
+
|
7
|
+
|
8
|
+
# self.table_name = :rental
|
9
|
+
# self.primary_key = :int_rental_id
|
10
|
+
|
11
|
+
def default_selects
|
12
|
+
#{ }"SELECT tblEntity.intEntityID, tblEntity.varEntityID AS job_no, tblLocation.intLocationID, tblLocationText.varLocationName FROM tblEntity INNER JOIN tblLocation ON tblLocation.intEntityID = tblEntity.intEntityID INNER JOIN tblLocationText ON tblLocationText.intLocationID = tblLocation.intLocationID WHERE varEntityID LIKE '%10526.00%'"
|
13
|
+
{
|
14
|
+
vendor: [:int_vendor_id, {var_vendor_id: :vendor_no}, :dte_created_date, :dte_modified_date, :bol_active, :int_payment_term_id, :int_state_id, :int_country_id],
|
15
|
+
vendor_text: [:var_organization, :var_address, :var_city, :var_state, :var_postal_code, :var_contact, :var_title, :var_email, :var_telephone, :var_home_phone]
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_joins
|
20
|
+
arr = []
|
21
|
+
arr << "INNER JOIN tblVendorText ON (tblVendorText.intvendorID = tblVendor.intvendorID) AND varLocaleID = '#{locale}'"
|
22
|
+
# arr << "INNER JOIN tblLocationText ON (tblLocationText.intLocationID = tblLocation.intLocationID)"
|
23
|
+
|
24
|
+
arr
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_by_entity_id(id)
|
28
|
+
all(limit: 1, where: [{int_entity_id: id}]).first
|
29
|
+
end
|
30
|
+
|
31
|
+
# rename_attributes intLocationID: 'location_id'
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Klooth
|
@@ -72,7 +72,16 @@ files:
|
|
72
72
|
- lib/toolhound-ruby/error.rb
|
73
73
|
- lib/toolhound-ruby/incident.rb
|
74
74
|
- lib/toolhound-ruby/inventory.rb
|
75
|
+
- lib/toolhound-ruby/inventory_item.rb
|
76
|
+
- lib/toolhound-ruby/manufacturer.rb
|
75
77
|
- lib/toolhound-ruby/project.rb
|
78
|
+
- lib/toolhound-ruby/purchase_order.rb
|
79
|
+
- lib/toolhound-ruby/purchase_order_item.rb
|
80
|
+
- lib/toolhound-ruby/rental.rb
|
81
|
+
- lib/toolhound-ruby/rental_charge.rb
|
82
|
+
- lib/toolhound-ruby/rental_item.rb
|
83
|
+
- lib/toolhound-ruby/util.rb
|
84
|
+
- lib/toolhound-ruby/vendor.rb
|
76
85
|
- lib/toolhound-ruby/version.rb
|
77
86
|
- script/bootstrap
|
78
87
|
- script/cibuild
|