detention_clock 0.1.0
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 +7 -0
- data/LICENSE +9 -0
- data/README.md +23 -0
- data/lib/detention_clock.rb +29 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 06ee8203f54d95fe0dd23cac1fca31032c3359490c5a9a72980fe5547bc85117
|
|
4
|
+
data.tar.gz: 5ebe74cc0aadaedc2aa00fed1d741fe46cd408b081f094b3f79b6674e73bcf50
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7cf14e8fa68a42bdf8904989616899945ad8f8e1b707c33d66d0472e94837cd1c0a2a87e458af67d3ef6d47f73453365f083a111c2ec18d68b77299fd1acac83
|
|
7
|
+
data.tar.gz: adc74a985ec3ed07379e5773740ff1cd0427e073f4b790f86174ab2c9658d08877ac10894d355f1f68f3056d7e83ec3a1af63c5f06402cf410cfdb17b4d4fc86
|
data/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TruckLeap
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# detention_clock
|
|
2
|
+
|
|
3
|
+
A tiny Ruby helper for one annoying question at every dock: how much detention do I bill?
|
|
4
|
+
|
|
5
|
+
Most rate confirmations give two free hours at the shipper or receiver, then pay an hourly rate, often billed in quarter hours. This gem turns check-in and check-out times into billable hours and dollars.
|
|
6
|
+
|
|
7
|
+
```ruby
|
|
8
|
+
require "detention_clock"
|
|
9
|
+
|
|
10
|
+
arrived = Time.new(2026, 10, 20, 7, 0)
|
|
11
|
+
departed = Time.new(2026, 10, 20, 10, 40)
|
|
12
|
+
|
|
13
|
+
minutes = DetentionClock.dwell_minutes(arrived, departed) # => 220
|
|
14
|
+
DetentionClock.billable_hours(minutes) # => 1.75
|
|
15
|
+
DetentionClock.pay(minutes, hourly_rate: 50) # => 87.5
|
|
16
|
+
DetentionClock.pay(minutes, hourly_rate: 50, cap_hours: 1) # => 50
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Keep your in and out times on the bill of lading signed. The math only helps if the times are on paper.
|
|
20
|
+
|
|
21
|
+
There is also a [detention and lumper calculator you can use in the browser](https://truckleap.com/detention-lumper-calculator), and the gem is maintained by the dispatch team at [TruckLeap](https://truckleap.com/).
|
|
22
|
+
|
|
23
|
+
MIT licensed.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# DetentionClock works out billable detention time and pay for a truck stop,
|
|
4
|
+
# using the common "two hours free, then hourly" arrangement.
|
|
5
|
+
module DetentionClock
|
|
6
|
+
VERSION = "0.1.0"
|
|
7
|
+
|
|
8
|
+
module_function
|
|
9
|
+
|
|
10
|
+
# Minutes between arrival and departure, never negative.
|
|
11
|
+
def dwell_minutes(arrived_at, departed_at)
|
|
12
|
+
[((departed_at - arrived_at) / 60.0).round, 0].max
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Billable hours after the free window, rounded up to the next quarter hour.
|
|
16
|
+
def billable_hours(dwell_minutes, free_minutes: 120)
|
|
17
|
+
extra = dwell_minutes - free_minutes
|
|
18
|
+
return 0.0 if extra <= 0
|
|
19
|
+
|
|
20
|
+
(extra / 15.0).ceil * 0.25
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Detention pay owed for the stop.
|
|
24
|
+
def pay(dwell_minutes, hourly_rate:, free_minutes: 120, cap_hours: nil)
|
|
25
|
+
hours = billable_hours(dwell_minutes, free_minutes: free_minutes)
|
|
26
|
+
hours = [hours, cap_hours].min if cap_hours
|
|
27
|
+
(hours * hourly_rate).round(2)
|
|
28
|
+
end
|
|
29
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: detention_clock
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- George Green
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: Turns dock check-in and check-out times into billable detention hours
|
|
13
|
+
and pay, with a free window, quarter-hour rounding and an optional cap.
|
|
14
|
+
email: truckleap@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- LICENSE
|
|
20
|
+
- README.md
|
|
21
|
+
- lib/detention_clock.rb
|
|
22
|
+
homepage: https://truckleap.com/detention-lumper-calculator
|
|
23
|
+
licenses:
|
|
24
|
+
- MIT
|
|
25
|
+
metadata:
|
|
26
|
+
source_code_uri: https://truckleap.com/
|
|
27
|
+
documentation_uri: https://truckleap.com/detention-lumper-calculator
|
|
28
|
+
rdoc_options: []
|
|
29
|
+
require_paths:
|
|
30
|
+
- lib
|
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '2.7'
|
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
requirements: []
|
|
42
|
+
rubygems_version: 3.6.7
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: Billable detention hours and pay for truck stops
|
|
45
|
+
test_files: []
|