renewal-window-report 1.0.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 +22 -0
- data/README.md +40 -0
- data/bin/renewal-window-report +29 -0
- data/lib/renewal_window_report.rb +93 -0
- metadata +64 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e93b27e402c6b7d6c3b9bc40b20f4154e99b0a74ed07b376f2395993f6df7019
|
|
4
|
+
data.tar.gz: ab509c24c49829cf272289cf3006e5cbd8ba6a5e2441e1008f4c48db220fe189
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bb3a65ef2c50f28602647d170d42f642b0c417b33d30d917c6226febd384faa0eb2d924e50cb35b9f2735542c8e5f99ba5f09ffe7d701c2a969ba14ddcca6462
|
|
7
|
+
data.tar.gz: 2edfa45c27c32adf5a0380627e68f20d4c43c760711cddf3be7c1af0ec03bdec5c81ce0dcb16fef85c45a9011688bb1e74d306dd476efa221a79a5fa6b730cf3
|
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OneGTMLab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# renewal-window-report
|
|
2
|
+
|
|
3
|
+
Ruby command line tool and library. Give it a CSV of accounts with ARR and renewal date and it sorts them into windows by days until renewal: overdue (date already passed), 0-30, 31-60, 61-90 and 91 or more. For each window it shows the number of accounts, the ARR and the share of total ARR, then lists the accounts renewing within 30 days, soonest first.
|
|
4
|
+
|
|
5
|
+
Part of the [OneGTMLab](https://www.onegtmlab.dev) free GTM tools. Background on the idea: [B2B SaaS](https://www.onegtmlab.dev/glossary/b2b-saas).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem install renewal-window-report
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Use
|
|
14
|
+
|
|
15
|
+
CSV columns: account, arr, renewal_date (yyyy-mm-dd). Days are counted from today, or from the date you pass with --today (the example below passes a fixed date so the output is repeatable). A renewal dated today is 0 days and sits in 0-30. A bad date or a negative ARR stops the run with an error and a non-zero exit code.
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
$ ruby bin/renewal-window-report sample.csv --today 2026-11-28
|
|
19
|
+
window accounts ARR share
|
|
20
|
+
overdue 1 120,000 17.4%
|
|
21
|
+
0-30 3 150,000 21.7%
|
|
22
|
+
31-60 3 130,000 18.8%
|
|
23
|
+
61-90 1 50,000 7.2%
|
|
24
|
+
91+ 2 240,000 34.8%
|
|
25
|
+
total 10 690,000
|
|
26
|
+
|
|
27
|
+
Renewing within 30 days, soonest first:
|
|
28
|
+
account days ARR
|
|
29
|
+
Pied Piper 5 25,000
|
|
30
|
+
Acme Robotics 12 45,000
|
|
31
|
+
Globex 30 80,000
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Test
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
ruby test/run.rb
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative '../lib/renewal_window_report'
|
|
5
|
+
|
|
6
|
+
args = ARGV.dup
|
|
7
|
+
if args.empty? || args.include?('-h') || args.include?('--help')
|
|
8
|
+
warn "usage: renewal-window-report renewals.csv [--today 2026-11-28]\n" \
|
|
9
|
+
"CSV columns: account, arr, renewal_date (YYYY-MM-DD). More: https://www.onegtmlab.dev/glossary/b2b-saas"
|
|
10
|
+
exit 2
|
|
11
|
+
end
|
|
12
|
+
file = args.shift
|
|
13
|
+
today = Date.today
|
|
14
|
+
begin
|
|
15
|
+
until args.empty?
|
|
16
|
+
flag = args.shift
|
|
17
|
+
val = args.shift or abort "error: #{flag} needs a value"
|
|
18
|
+
case flag
|
|
19
|
+
when '--today'
|
|
20
|
+
raise ArgumentError, "bad --today #{val.inspect}, expected yyyy-mm-dd" unless val.match?(/\A\d{4}-\d{2}-\d{2}\z/)
|
|
21
|
+
|
|
22
|
+
today = Date.strptime(val, '%Y-%m-%d')
|
|
23
|
+
else abort "error: unknown option #{flag}"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
print RenewalWindowReport.render(RenewalWindowReport.from_csv(File.read(file), today))
|
|
27
|
+
rescue ArgumentError, Date::Error, Errno::ENOENT, CSV::MalformedCSVError => e
|
|
28
|
+
abort "error: #{e.message}"
|
|
29
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'csv'
|
|
4
|
+
require 'date'
|
|
5
|
+
|
|
6
|
+
# Group accounts by how many days remain until renewal and show the ARR in each window.
|
|
7
|
+
module RenewalWindowReport
|
|
8
|
+
BUCKETS = ['overdue', '0-30', '31-60', '61-90', '91+'].freeze
|
|
9
|
+
Account = Struct.new(:account, :arr, :renewal, :days, keyword_init: true)
|
|
10
|
+
|
|
11
|
+
def self.bucket(days)
|
|
12
|
+
return 'overdue' if days.negative?
|
|
13
|
+
return '0-30' if days <= 30
|
|
14
|
+
return '31-60' if days <= 60
|
|
15
|
+
return '61-90' if days <= 90
|
|
16
|
+
|
|
17
|
+
'91+'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.parse_date(text, line)
|
|
21
|
+
s = text.to_s.strip
|
|
22
|
+
raise ArgumentError, "line #{line}: bad renewal_date #{s.inspect}, expected yyyy-mm-dd" unless s.match?(/\A\d{4}-\d{2}-\d{2}\z/)
|
|
23
|
+
|
|
24
|
+
Date.strptime(s, '%Y-%m-%d')
|
|
25
|
+
rescue Date::Error
|
|
26
|
+
raise ArgumentError, "line #{line}: bad renewal_date #{s.inspect}, not a real date"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.parse_arr(text, line)
|
|
30
|
+
s = text.to_s.strip
|
|
31
|
+
raise ArgumentError, "line #{line}: negative ARR #{s.inspect}" if s.match?(/\A-\d/)
|
|
32
|
+
raise ArgumentError, "line #{line}: bad ARR #{s.inspect}, expected a number" unless s.match?(/\A\d+(\.\d+)?\z/)
|
|
33
|
+
|
|
34
|
+
Rational(s)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.from_csv(text, today)
|
|
38
|
+
table = CSV.parse(text, headers: true)
|
|
39
|
+
missing = %w[account arr renewal_date] - (table.headers.compact.map(&:strip))
|
|
40
|
+
raise ArgumentError, "missing column(s): #{missing.join(', ')}" unless missing.empty?
|
|
41
|
+
raise ArgumentError, 'no rows in the CSV' if table.empty?
|
|
42
|
+
|
|
43
|
+
table.each_with_index.map do |r, i|
|
|
44
|
+
line = i + 2
|
|
45
|
+
name = r['account'].to_s.strip
|
|
46
|
+
raise ArgumentError, "line #{line}: empty account" if name.empty?
|
|
47
|
+
|
|
48
|
+
renewal = parse_date(r['renewal_date'], line)
|
|
49
|
+
Account.new(account: name, arr: parse_arr(r['arr'], line), renewal: renewal, days: (renewal - today).to_i)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Returns { bucket => { accounts:, arr:, share: } } in bucket order; share is a percentage of total ARR.
|
|
54
|
+
def self.summarize(accounts)
|
|
55
|
+
total = accounts.sum(Rational(0), &:arr)
|
|
56
|
+
BUCKETS.to_h do |b|
|
|
57
|
+
list = accounts.select { |a| bucket(a.days) == b }
|
|
58
|
+
arr = list.sum(Rational(0), &:arr)
|
|
59
|
+
share = total.zero? ? 0.0 : (arr / total * 100).to_f
|
|
60
|
+
[b, { accounts: list.size, arr: arr, share: share }]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.soon(accounts)
|
|
65
|
+
accounts.select { |a| a.days >= 0 && a.days <= 30 }.sort_by { |a| [a.days, a.account] }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.money(value)
|
|
69
|
+
whole = value.denominator == 1
|
|
70
|
+
s = whole ? value.to_i.to_s : format('%.2f', value.to_f)
|
|
71
|
+
int, frac = s.split('.')
|
|
72
|
+
int = int.reverse.scan(/\d{1,3}/).join(',').reverse
|
|
73
|
+
frac ? "#{int}.#{frac}" : int
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def self.render(accounts)
|
|
77
|
+
out = +format("%-9s %8s %13s %10s\n", 'window', 'accounts', 'ARR', 'share')
|
|
78
|
+
summarize(accounts).each do |b, s|
|
|
79
|
+
out << format("%-9s %8d %13s %9.1f%%\n", b, s[:accounts], money(s[:arr]), s[:share])
|
|
80
|
+
end
|
|
81
|
+
total = accounts.sum(Rational(0), &:arr)
|
|
82
|
+
out << format("%-9s %8d %13s\n", 'total', accounts.size, money(total))
|
|
83
|
+
out << "\nRenewing within 30 days, soonest first:\n"
|
|
84
|
+
list = soon(accounts)
|
|
85
|
+
if list.empty?
|
|
86
|
+
out << "none\n"
|
|
87
|
+
else
|
|
88
|
+
out << format("%-18s %5s %10s\n", 'account', 'days', 'ARR')
|
|
89
|
+
list.each { |a| out << format("%-18s %5d %10s\n", a.account, a.days, money(a.arr)) }
|
|
90
|
+
end
|
|
91
|
+
out
|
|
92
|
+
end
|
|
93
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: renewal-window-report
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- OneGTMLab
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: csv
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "0"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "0"
|
|
28
|
+
description: "Ruby CLI and library: from a CSV of accounts with ARR and renewal date, bucket them as overdue, 0-30, 31-60, 61-90 or 91+ days to renewal, show accounts, ARR and share of total ARR per bucket, and list what renews within 30 days. Offline."
|
|
29
|
+
executables:
|
|
30
|
+
- renewal-window-report
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- LICENSE
|
|
35
|
+
- README.md
|
|
36
|
+
- bin/renewal-window-report
|
|
37
|
+
- lib/renewal_window_report.rb
|
|
38
|
+
homepage: "https://www.onegtmlab.dev/glossary/b2b-saas"
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
41
|
+
metadata:
|
|
42
|
+
homepage_uri: "https://www.onegtmlab.dev/glossary/b2b-saas"
|
|
43
|
+
source_code_uri: "https://github.com/jaizendra-netizen/renewal-window-report"
|
|
44
|
+
documentation_uri: "https://www.onegtmlab.dev/glossary/b2b-saas"
|
|
45
|
+
rdoc_options: []
|
|
46
|
+
require_paths:
|
|
47
|
+
- lib
|
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
-
|
|
51
|
+
- ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: "2.7"
|
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
-
|
|
57
|
+
- ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: "0"
|
|
60
|
+
requirements: []
|
|
61
|
+
rubygems_version: 4.1.0
|
|
62
|
+
specification_version: 4
|
|
63
|
+
summary: Group accounts by days until renewal and show the ARR in each window
|
|
64
|
+
test_files: []
|