weighted-pipeline-forecast 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 +34 -0
- data/bin/weighted-pipeline-forecast +23 -0
- data/lib/weighted_pipeline_forecast.rb +66 -0
- metadata +50 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 205ba872f723c659d1c3abf35570794f77044eea2c88224a83567a2c9be5669e
|
|
4
|
+
data.tar.gz: 13058c3b8b9c879368c3ea85cd3f0621b5777ed2a120f138f388ffed58d870e7
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d0d963c50a77df306ee56989eab9faf53d8887e99faaa7fc6d664d70466fd3a4b251d4b4aee4a4748bcede7f90a9af59eda57f3d4717a93dc6bbdcfe579289ab
|
|
7
|
+
data.tar.gz: 5904ff3fa6d8bc9064ec3efce16cecee15c799c00c8f5a6e4ad6ea9078862d979a6c8acff728f4e81603dea85c85d1295ae36e427e0f990155ac54d466a52a60
|
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,34 @@
|
|
|
1
|
+
# weighted-pipeline-forecast
|
|
2
|
+
|
|
3
|
+
A small Ruby library and command-line tool for a [sales forecast](https://www.onegtmlab.dev/glossary/sales-forecast) from your open deals:
|
|
4
|
+
each deal counts at the probability of its stage, and with a quota it also reports pipeline coverage and the gap. The stage
|
|
5
|
+
probabilities are a table you set. Offline, no dependencies. Built by [OneGTMLab](https://www.onegtmlab.dev/glossary/sales-forecast) (GTM engineering for B2B teams).
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
gem install weighted-pipeline-forecast
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```csv
|
|
12
|
+
deal,amount,stage
|
|
13
|
+
a,10000,discovery
|
|
14
|
+
b,20000,proposal
|
|
15
|
+
c,50000,commit
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
weighted-pipeline-forecast deals.csv --quota 100000
|
|
20
|
+
# discovery 1 deals 10000 open x 10% = 1000
|
|
21
|
+
# proposal 1 deals 20000 open x 40% = 8000
|
|
22
|
+
# commit 1 deals 50000 open x 90% = 45000
|
|
23
|
+
# open pipeline 80000, weighted forecast 54000
|
|
24
|
+
# pipeline coverage 0.8x, forecast gap to quota 46000
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Default stages are discovery 10%, proposal 40%, negotiation 70%, commit 90%; pass `--stages name=0.2,name=0.6` to use your own.
|
|
28
|
+
Stages not in the table are listed and not counted. See the [sales forecast glossary entry](https://www.onegtmlab.dev/glossary/sales-forecast).
|
|
29
|
+
|
|
30
|
+
## Test
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
ruby test/run.rb
|
|
34
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require_relative '../lib/weighted_pipeline_forecast'
|
|
5
|
+
|
|
6
|
+
args = ARGV.dup
|
|
7
|
+
stages = WeightedPipelineForecast::DEFAULT_STAGES
|
|
8
|
+
quota = nil
|
|
9
|
+
if args.include?('-h') || args.include?('--help') || args.empty?
|
|
10
|
+
warn "usage: weighted-pipeline-forecast deals.csv [--quota 500000] [--stages discovery=0.1,proposal=0.4,commit=0.9]\nCSV columns: amount, stage. More: https://www.onegtmlab.dev/glossary/sales-forecast"
|
|
11
|
+
exit 2
|
|
12
|
+
end
|
|
13
|
+
while (i = args.index { |a| a.start_with?('--') })
|
|
14
|
+
flag = args.delete_at(i)
|
|
15
|
+
val = args.delete_at(i)
|
|
16
|
+
case flag
|
|
17
|
+
when '--quota' then quota = Float(val)
|
|
18
|
+
when '--stages' then stages = WeightedPipelineForecast.parse_stages(val)
|
|
19
|
+
else abort "unknown option #{flag}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
r = WeightedPipelineForecast.from_csv(File.read(args[0]), stages, quota: quota)
|
|
23
|
+
print WeightedPipelineForecast.render(r, stages)
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'csv'
|
|
4
|
+
|
|
5
|
+
# Weighted pipeline forecast: each open deal counts at the probability of its stage.
|
|
6
|
+
# Also reports pipeline coverage (open pipeline / quota) when a quota is given.
|
|
7
|
+
module WeightedPipelineForecast
|
|
8
|
+
VERSION = '1.0.0'
|
|
9
|
+
DEFAULT_STAGES = { 'discovery' => 0.10, 'proposal' => 0.40, 'negotiation' => 0.70, 'commit' => 0.90 }.freeze
|
|
10
|
+
Result = Struct.new(:open_total, :weighted, :by_stage, :unknown, :coverage, :gap, keyword_init: true)
|
|
11
|
+
|
|
12
|
+
module_function
|
|
13
|
+
|
|
14
|
+
# "discovery=0.1,proposal=0.4" -> { 'discovery' => 0.1, 'proposal' => 0.4 }
|
|
15
|
+
def parse_stages(text)
|
|
16
|
+
text.split(',').to_h do |pair|
|
|
17
|
+
name, p = pair.split('=', 2)
|
|
18
|
+
raise ArgumentError, "stage needs name=probability: #{pair.inspect}" if p.nil?
|
|
19
|
+
prob = Float(p)
|
|
20
|
+
raise ArgumentError, "probability must be between 0 and 1: #{pair.inspect}" unless prob.between?(0, 1)
|
|
21
|
+
[name.strip.downcase, prob]
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# deals: array of hashes with 'amount' and 'stage'. Stages not in the table are listed in unknown and not counted.
|
|
26
|
+
def forecast(deals, stages = DEFAULT_STAGES, quota: nil)
|
|
27
|
+
by = Hash.new { |h, k| h[k] = { count: 0, amount: 0.0, weighted: 0.0 } }
|
|
28
|
+
unknown = []
|
|
29
|
+
deals.each do |d|
|
|
30
|
+
stage = d['stage'].to_s.strip.downcase
|
|
31
|
+
amount = Float(d['amount'].to_s.delete(',').strip)
|
|
32
|
+
raise ArgumentError, 'amount cannot be negative' if amount.negative?
|
|
33
|
+
p = stages[stage]
|
|
34
|
+
if p.nil?
|
|
35
|
+
unknown << stage unless unknown.include?(stage)
|
|
36
|
+
next
|
|
37
|
+
end
|
|
38
|
+
b = by[stage]
|
|
39
|
+
b[:count] += 1
|
|
40
|
+
b[:amount] += amount
|
|
41
|
+
b[:weighted] += amount * p
|
|
42
|
+
end
|
|
43
|
+
open_total = by.values.sum { |b| b[:amount] }
|
|
44
|
+
weighted = by.values.sum { |b| b[:weighted] }
|
|
45
|
+
cov = quota && quota.positive? ? open_total / quota : nil
|
|
46
|
+
gap = quota ? quota - weighted : nil
|
|
47
|
+
Result.new(open_total: open_total, weighted: weighted, by_stage: by, unknown: unknown, coverage: cov, gap: gap)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def from_csv(text, stages = DEFAULT_STAGES, quota: nil)
|
|
51
|
+
forecast(CSV.parse(text, headers: true).map(&:to_h), stages, quota: quota)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def render(r, stages = DEFAULT_STAGES)
|
|
55
|
+
out = +''
|
|
56
|
+
stages.each_key do |s|
|
|
57
|
+
next unless r.by_stage.key?(s)
|
|
58
|
+
b = r.by_stage[s]
|
|
59
|
+
out << format("%-12s %3d deals %12.0f open x %.0f%% = %12.0f\n", s, b[:count], b[:amount], stages[s] * 100, b[:weighted])
|
|
60
|
+
end
|
|
61
|
+
out << format("open pipeline %.0f, weighted forecast %.0f\n", r.open_total, r.weighted)
|
|
62
|
+
out << format("pipeline coverage %.1fx, forecast gap to quota %.0f\n", r.coverage, r.gap) if r.coverage
|
|
63
|
+
out << "not counted (stage not in the table): #{r.unknown.join(', ')}\n" unless r.unknown.empty?
|
|
64
|
+
out
|
|
65
|
+
end
|
|
66
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: weighted-pipeline-forecast
|
|
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
|
+
description: "Ruby CLI and library: each open deal counts at the probability of its stage; reports weighted forecast, pipeline coverage against a quota and the gap. Stage probabilities are yours to set."
|
|
13
|
+
email:
|
|
14
|
+
- account@onegtmlab.dev
|
|
15
|
+
executables:
|
|
16
|
+
- weighted-pipeline-forecast
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- LICENSE
|
|
21
|
+
- README.md
|
|
22
|
+
- bin/weighted-pipeline-forecast
|
|
23
|
+
- lib/weighted_pipeline_forecast.rb
|
|
24
|
+
homepage: "https://www.onegtmlab.dev/glossary/sales-forecast"
|
|
25
|
+
licenses:
|
|
26
|
+
- MIT
|
|
27
|
+
metadata:
|
|
28
|
+
homepage_uri: "https://www.onegtmlab.dev/glossary/sales-forecast"
|
|
29
|
+
source_code_uri: "https://github.com/jaizendra-netizen/weighted-pipeline-forecast"
|
|
30
|
+
documentation_uri: "https://www.onegtmlab.dev/glossary/sales-forecast"
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
-
|
|
37
|
+
- ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: "2.7"
|
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
|
+
requirements:
|
|
42
|
+
-
|
|
43
|
+
- ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: "0"
|
|
46
|
+
requirements: []
|
|
47
|
+
rubygems_version: 4.1.0
|
|
48
|
+
specification_version: 4
|
|
49
|
+
summary: Weighted sales forecast and pipeline coverage from a deals CSV
|
|
50
|
+
test_files: []
|