Repository navigation
Description
Problem
Workflow profiles already model the split between a planning instance (where issues live and the customer reads along) and a booking instance (where the worklogs land). What they do not model is the question that follows every month from that split:
How much of the time booked in a period is billable, and how much is covered by a retainer or by warranty?
Today that answer is produced outside budjira, by a per-customer script that:
- re-reads budjira's own credential files directly,
- hardcodes the connection name and the project keys,
- hardcodes the mapping from issue labels to billing categories,
- and re-implements Tempo worklog fetching that
budjiraalready does.
In other words: a satellite that reimplements the host. Every new customer needs a copy, and each copy drifts.
There is a second, less obvious cost. A report that exists only as formatted terminal output has to be parsed by anything that wants to use the numbers — which is exactly how wrong numbers happen. A deterministic command that emits structured data removes that whole class of error.
Proposal
A workflow billing command, driven by an optional billing block in the workflow profile.
Configuration
[[profiles]]
name = "acme-shadow"
planning_connection = "acme-planning"
booking_connection = "acme-booking"
project_mappings = [{ planning_project = "PLAN", booking_project = "BOOK" }]
[profiles.billing]
# label -> bucket. Buckets are free-form; the report groups by them.
categories = { analysis = "billable",
support = "billable",
feature = "billable",
bugfix = "billable",
warranty = "non-billable",
operations = "non-billable",
onboarding = "project" }
# Exactly one category label per issue. Jira cannot enforce this itself.
require_exactly_one = true
# Optional. When absent, the report shows hours only.
rate = 0
currency = "EUR"The categories are deliberately configuration, not code: every customer contract names them differently, and the same tool has to serve several at once.
Command
budjira workflow billing --profile acme-shadow --month 2026-08
budjira workflow billing --profile acme-shadow --from 2026-08-01 --to 2026-09-30
budjira workflow billing --profile acme-shadow --month 2026-08 --group category
budjira workflow billing --profile acme-shadow --validate
budjira --format json workflow billing --profile acme-shadow --month 2026-08
Output grouped by bucket, with per-issue rows (key, category, hours, summary) and a total per bucket — plus an explicit uncategorised bucket, so an unlabelled issue is visible rather than silently absent from the total.
--validate checks label hygiene across the profile's projects without producing a report: issues with no category label, and issues carrying more than one.
Why this fits where it is
Most of the machinery is already there:
WorkflowProfile(budjira/models/workflow.py) is a pydantic model — an optionalbillingsub-model extends it without breaking existing configs.budjira/cli/workflow.pyalready hostsstatus,sprintandbook;billingis a sibling, not a new surface.workflow sprintalready joins planning issues with their booking-side Tempo data across two instances. A billing report is largely a different grouping of the same join, over a date range instead of a sprint.budjira/tempo/client.py::get_worklogsalready covers the date-range fetch.- A global
--format jsonalready exists (budjira/cli/main.py), so the machine-readable half needs no new flag — it just needs the command to return structured data rather than only render it. budjira/services/labels.pyalready exists for the label side.
Details that turned out to matter in practice
- Exactly one category label. Jira happily allows several; a report cannot decide between them. Failing loudly with the offending labels named is better than picking one.
- A separate "project" bucket. Work settled by a one-off fixed fee should appear in the report but outside the monthly total — it is neither billable now nor covered by a retainer.
- The uncategorised bucket is not optional. Silently dropping unlabelled issues from a billing report is the worst possible failure mode.
- Hours without a rate is a useful mode. Not every profile wants money in the output; the billable/non-billable ratio is interesting on its own, and it is the number that shows whether operating effort is growing.
Out of scope
Invoicing, document generation, tax handling, customer-facing exports. This is reporting over data budjira already reaches.
Notes
The per-customer script this would replace has a small test suite around the category mapping and the exactly-one-label rule; that logic is worth porting rather than rewriting.
Activity
f3rdy commentedon Aug 29, 2026
Released in v1.27.0.
budjira workflow billing --profile NAME --month 2026-08(plus--from/--to,--group category,--bucket,--validateand--format json) builds the billable/non-billable report from an optional[profiles.billing]block:categoriesmaps labels to free-form buckets;require_exactly_onefails loudly with the offending labels namedexclude_from_total(default["project"]) keeps fixed-fee buckets visible but outside the grand totalrate/currencyadd amounts; absent orrate = 0gives the hours-only reportuncategorisedbucket — nothing is silently dropped--validatechecks label hygiene across the profile's planning projects and exits 1 on violationsThe join is inverted (Tempo worklogs in the period → booking issue summaries → planning key extraction), so a monthly report costs a handful of API calls regardless of issue count. JSON output follows a deterministic schema (
groups,lines,totals,warnings) for scripts and AI agents.f3rdy commentedon Aug 29, 2026
Field report from configuring this on a real profile the same day it shipped.
The config shape works unchanged. The
[profiles.billing]block from the description above was added to an existing profile verbatim — label→bucket map,require_exactly_one,rate,currency— and the profile still loads. No migration needed for profiles without the block.Currently blocked by #118: the command cannot complete for any profile, because the Tempo query carries a
projectparameter the v4 API rejects with 400. That is upstream of anything this feature does; the report itself was never reached.A cheap acceptance check, once that is fixed. If you already have a per-customer script producing the same split, run both over the same period and compare bucket totals — including the worklog count, so a silently dropped entry shows up rather than hiding inside a rounded hour. Agreement across two independent implementations is a stronger signal than either one alone.
One design decision that earned its keep immediately. The uncategorised bucket is not decoration. While waiting for the feature I reimplemented the same report ad hoc and got a lower billable total — it resolved the shadow ticket from the worklog description rather than from the issue key, so entries whose description lacked the planning-key prefix fell out and landed in "no label". The result looked entirely plausible; only having a second, tested implementation next to it exposed the error.
That is the strongest argument for this living in the tool rather than in a per-customer script: the planning↔booking resolution is a rule that deserves to be implemented correctly once. Anything reassembled per question is wrong per question, and silently so.